Commit Graph

80 Commits

Author SHA1 Message Date
Lance Bragstad 8e85cb1a4d Remove v2.0 auth APIs
This was originally staged to be removed in the T release.
Discussions from the Queens PTG resulted in the ability to remove it
sooner since everything else in v2.0 is gone except the ec2 APIs.

This patch just removes the v2.0 authentication API and the tests
that failed as a result. A subsequent patch will go through and start
removing all the plumbing, fixtures, and testing infrastructure that
is no longer needed.

bp removed-as-of-queens

Change-Id: I4c3e35f3565b4b60ae4d00cc2490bd04aba1a800
2017-09-30 15:31:45 +00:00
Lance Bragstad 139aa015d2 Remove v2.0 token APIs
This commit removes all the v2.0 token APIs with the exception of the
v2.0 authenticate for token API. POST /v2.0/tokens affects so much
stuff that we can do it in a separate patch and hopefully make it
easier for reviewers.

bp removed-as-of-queens

Change-Id: I508e7350c2a2d25c8fb413ea3523633f8939d80f
2017-09-30 15:26:03 +00:00
Lance Bragstad 9eef17930a Remove v2.0 assignment APIs
bp removed-as-of-queens

Change-Id: I29df48b0df39dc0a97e28a6436278734082d5ec7
2017-08-31 22:20:58 +00:00
Gábor Antal c812f53629 Removed unnecessary setUp() calls from unit tests
TrivialFix

Change-Id: I4d4349f70f58b1bb464fcb9b7adf324991b73530
2017-08-01 18:24:03 +02:00
XieYingYun 29eec5ebc0 Remove unnecessary setUp function in testcase
In testcase, setUp will be called automatically. This patch used to
remove setUp functions that do nothing. Besides, it will keep code clean.

Change-Id: Iadb247fd43df8bb9bb0db54492b1bc2dc23cf065
2017-03-30 14:32:58 +08:00
Gage Hugo 2be615ea93 Fix multiple uuid warnings with pycadf
There are multiple pycadf warnings about invalid uuids when
running keystone tests:

To ensure interoperability, identifiersshould be a valid uuid.
  warnings.warn('Invalid uuid. To ensure interoperability, identifiers'

This changes multiple fixtures within default_fixtures to use valid
uuids for their 'id' values. Also changed load_fixtures to build
the fixtures based on the default_fixtures' 'name' value, rather
than 'id'. Replaced many instances of invalid hard-coded ids to use
random uuids, default_fixture ids, or 'default'.

Co-Authored-By: Tin Lam <tinlam@gmail.com>

Change-Id: Ic4fff30c306561b71288712480f073aba1fccbde
Closes-Bug: #1659053
Depends-On: I58bba04c21c2d24fd37850c9ecc6fac99deb3fc4
2017-02-08 21:16:43 -06:00
Lance Bragstad 4c095ccf2f refactor the token controller
The token controller had quite a few case statements depending on
which type of authentication was required based on the format of the
authenticate request.

This commit uses the generator pattern to give the
token.controllers.Auth.authenticate() method the right authentication
object based on the format of the request. Each authentication method
just implements an `authenticate()` method that returns a tuple of
information.

Change-Id: I11f508dd55c910b122c4102a96252041f76d6224
2016-11-11 17:43:56 +00:00
Lance Bragstad e361a3ad8e Use issue_v3_token instead of issue_v2_token
This is following the same pattern we applied to the token validation
path by collapsing the v3 and v2.0 paths together. Here we are going
to use issue_v3_token and translate the response to a v2.0 format.

This is going to allow us the ability to simplify the token provider
interface, remove duplicate logic, and isolate specific v2.0 and v3
token-isms into specific areas.

One of the existing test cases changes to assert an Unauthorized
exception when a trustee is disabled, instead of a Forbidden exception.
The switch is because the behavior is consistent with regular users
trying to authenticate with a token when their user is disabled (a 401
is expected). We're making that behavior consistent when a trustee is
disabled.

A subsequent patch will remove issue_v2_token entirely.

Change-Id: I191ce36b2f11f7353e2e3d601af1bda96987613b
2016-11-11 17:43:41 +00:00
Steve Martinelli 8a66ef6354 Remove support for PKI and PKIz tokens
This is the first step of several to remove PKI token support in
keystone. A large issue in removing PKI support is support for the
revocation list must be maintained.

This patch removes support for the token format, it's surrounding tests
and examples that are generated. Additionally, some wording has been
changed around the CLI and config options to make the distinction
between keys and certs used for PKI tokens and those used for getting
the revocation list (a list of tokens that are revoked, which is signed).

Future patches will:

- Remove the keystone-manage commands for generating certs

- Modify the revocation list (at /auth/tokens/OS-PKI/revoked) to return
a 403 if pki is not configured (instead of raising a 500). We cannot
remove the API as that would break an API contract.

- Options to configure PKI will be marked as deprecated

- If PKI is configured a normal signed list will be returned (same
behavior as today)

- Follow up patch to keystonemiddleware will make sure auth_token does
not rely on the revocation api at all.

Related-Bug: 1626778
Related-Bug: 1626779

Co-Authored-By: Boris Bobrov <bbobrov@mirantis.com>
bp removed-as-of-ocata
Change-Id: Icf1ebced44a675c88fb66a6c0431208ff5181574
2016-11-01 22:05:01 +00:00
Lance Bragstad 71134fbe1c One validate method to rule them all...
Regardless of persistence requirements or format, let's perform
token validation one way.

This simplifies the validation path of the token provider API.

Change-Id: Idb5de4459fd8bf83973ed74fccc275a64873c88c
2016-10-12 15:03:12 +00:00
Lance Bragstad 52bde3cf08 Remove validate_v2_token() method
Instead of using validate_v2_token, we can effectively use the
validate_v3_token method and translate the v3 response to a v2 one.

This is a step towards simplifying the token provider API.

Change-Id: Iccb8349e0710288adb107d55437a4ff50d074b1c
2016-10-12 14:34:23 +00:00
Lance Bragstad 9aec18b0f2 Use validate_v3_token instead of validate_token
The token provider has about 3 different ways to validate a token.
This since all 3 methods validate tokens in a very similar way we
should consolidate the behavior by collapsing the calls.

This is an effort to simplify the token provider API.

Change-Id: I32b94ce6fad29774d32639459fd17691ba427520
2016-10-05 15:06:55 +00:00
Lance Bragstad 7f3f596351 Fix the belongsTo query parameter
The belongsTo query parameter is only supported by the v2.0
token validation API. It would check the ID of the project passed
to the belongsTo parameter against the project a token was scoped to.

This commit corrects the implementation, tests, and adds
documentation. It also moves the check to keystone.token.controller
since belongsTo is a v2-ism and doesn't belong in the
keystone.token.provider.

Closes-Bug: 1627085
Closes-Bug: 1626794
Change-Id: I4a06a498112b81093d7e5ef3142bb1e2d0f78138
2016-09-23 21:05:16 +00:00
David Stanek acde6ff5b3 Add edge case tests for disabling a trustee
This commit introduces two tests that ensures if a trustee of a
trust-scoped token is disabled, keystone will emit a Forbidden
exception. Regardless of the token provider, keystone should have
a consistent behavior. In order to test this, the test had to be
implemented differently for each token provider, specifically for
persistent and non-persistent tokens.

Co-Authored-By: Lance Bragstad <lbragstad@gmail.com>
Change-Id: Iaf04a26c9f60eb68bbd56b941ff76c893c144cb8
2016-09-13 16:16:58 +00:00
Ji-Wei fe12aaf135 Fix order of arguments in assertIs
Some tests used incorrect order for the assertIs function. The correct
order expected by testtools is:

  assertIs(expected, observed, message='')

For more details, see the testtools docs [1]

[1] http://testtools.readthedocs.io/en/latest/api.html#testtools.TestCase.assertIs

Change-Id: I7184cb566ede3d571c745c93b838131a87c17b75
2016-09-09 12:58:43 +00:00
Alexander Makarov 7260b55cfc Pre-cache new tokens
Since tokens are most often used right after being created,
cache them to bypass redundant validation.
The patch uses dogpile.cache internal functionality so some
calls may look strange

Implements bp pre-cache-tokens

Change-Id: I2e720eed6b0066738181afd1cbf73c5ff4d876f5
2016-08-31 20:14:53 +03:00
Jenkins f74df8da1a Merge "Make KeyRepository shareable" 2016-08-21 05:27:53 +00:00
Lance Bragstad fab5f82683 Make KeyRepository shareable
Because sharing is caring... and it helps us test credential encryption by
allowing us to reuse the KeyRepository fixture for credentials and fernet.

bp credential-encryption
Change-Id: I50a4e663385a0070ee1fd2c83c2fe5913f5a0ad0
2016-08-18 15:21:55 +00:00
David Stanek ecbeae5325 Removes use of freezegun in test_auth tests
The tests are already using the oslo_utils TimeFixture to manage time. Using
freezegun seems to be redundant.

Change-Id: I1162214ebbeba9276c5c47e094df91a16bb74658
2016-08-17 13:37:57 +00:00
David Stanek 25d2f8e2ee Removes a redundant test from FernetAuthWithTrust
It turns out that the behaviour tests by
test_trust_get_token_fails_if_trustee_disabled is not actually different
between Fernet and UUID if the tokens are properly revoked. The original
test didn't ensure that any time had passed between creating and revoking
a token. This adds a new test showing the different behaviour and modifies
the existing test to works.

Previously this test would fail intermittently when hitting a second
boundary.

If the creation and revocation happen in the same second then Fernet will
indeed respond with a Forbidden. If the revocation happens at least one
second after it will response with the expected Unauthorized.

Change-Id: I31e55e92cd745c34254e96491f97112ff0513baf
2016-08-17 13:36:29 +00:00
Lance Bragstad 3efd271fbc Make all token provider behave the same with trusts
Change-Id: I0a4fefe34a0c6912200d256e7bc3cbef66b34a16
2016-08-03 20:51:22 +00:00
Lance Bragstad b77c5b789f Make AuthWithTrust testable against uuid and fernet
We should make AuthWithTrust something that is tested against both the uuid
token provider and the fernet token provider. This helps us move towards making
fernet the default token provider.

This is an effort to break https://review.openstack.org/#/c/258650 into
smaller, more reviewable pieces.

Co-Authored-By: Raildo Mascena <raildo@lsd.ufcg.edu.br>
Co-Authored-By: Adam Young <ayoung@redhat.com>

Change-Id: I0fd2187421fc677e7d422d4b449eec3056a134e9
Partial-Bug: 1561054
2016-07-26 15:12:15 +00:00
Jenkins fc3585276f Merge "refactor: inherit AuthWithRemoteUser for other providers" 2016-07-25 22:34:05 +00:00
Jenkins d57602c947 Merge "Run AuthWithToken against all token providers" 2016-07-25 22:22:48 +00:00
Lance Bragstad e9fc581440 refactor: inherit AuthWithRemoteUser for other providers
This commit makes it so that the AuthWithRemoteUser class no longer inherits
from other tests cases. Instead it inherits from `object` and I've added
several other classes that setup each token provider to test the cases in
AuthWithRemoteUser.

This helps us move towards making Fernet the default token provider.

Co-Authored-By: Raildo Mascena <raildo@lsd.ufcg.edu.br>
Co-Authored-By: Adam Young <ayound@redhat.com>

Change-Id: I3ae63c8ff50a897ef0ae6e8129abc02e5b93747c
Partial-Bug: 1561054
2016-07-21 18:21:28 +00:00
Lance Bragstad 241d33d7a6 Run AuthWithToken against all token providers
This makes AuthWithToken inherit directly from `object` and introduces other
test classes with specific test setup for each format to inherit AuthWithToken.
This will make the switch to Fernet as default provider easier.

This fix was originally a part of https://review.openstack.org/#/c/258650 but
this is an attempt to break 258650 into smaller, more reviewable, pieces.

Co-Authored-By: Raildo Mascena <raildo@lsd.ufcg.edu.br>
Co-Authored-By: Adam Young <ayound@redhat.com>

Change-Id: I87a12160e31b2467af01dc8e7b01cc59d5907675
Partial-Bug: 1561054
2016-07-21 18:21:28 +00:00
Jamie Lennox b3e065efaa Remove get_user_id in trust controller
The get_user_id function relied on the token model in auth_context -
which amongst other things means it would fail with a tokenless auth
context. This can be replaced with user_id from the request.context.

Normally I try not to mix in cleanups, but whilst doing this and
changing variables in list_trusts a small reshuffle and some whitespace
just made the whole thing actually readable.

Change-Id: I5b64210fc797961b422a0ab9a1b4cee078fe6a0f
2016-07-14 18:28:30 +10:00
Jenkins a6af6b4dd8 Merge "Use request instead of context in v2 auth" 2016-07-06 10:27:57 +00:00
Jamie Lennox e7fc0932a1 Use request instead of context in v2 auth
In an ongoing effort to rid ourselves of the context_dict push the
request object further into the v2 auth controllers.

Change-Id: I01e4a857da06448b951e4840636c175fe85498c3
2016-07-04 15:36:20 +10:00
David Stanek 4bbb151dfb Use skip_test_overrides everywhere we feature skip
Use skip_test_overrides instead of using skipTest for skipping tests
that are not implemented by a particular backend. Then the tests will
let us know that they can be removed when the skipped test is removed.

This change also found one test could be removed.

Change-Id: I3d6aa0719d2365f65cd1b9b6d6f83be4c5bea2bc
2016-07-03 13:01:30 +00:00
Jamie Lennox ef70f52bef Use request.params instead of context['query_string']
The context['query_string'] is just a dictionary copy of the original
params object that comes from a request. Just use the existing params
instead.

Change-Id: I0ecd7a09e36b39a105c150b3affcbbcd26a544c2
2016-06-29 04:46:57 +10:00
Dolph Mathews d9c6b50a3a Replace keystone.common.config with keystone.conf package
keystone.common.config is 1200+ lines of super dense, merge-conflict
prone, difficult to navigate, and finicky to maintain code. Let's follow
nova's lead and break it down into more manageable modules.

This patch creates a new Python package, keystone.conf, and moves all of
our configuration options into it, mirroring nova's nova.conf package.

There are a couple special modules in keystone.conf introduced here as
well:

- keystone.conf.__init__: This causes all of Keystone options to be
  registered on import, so consumers of keystone.conf don't have
  races with config initialization code while trying to use
  oslo_config.cfg.CONF directly (keystone.conf replaces all uses for
  oslo_config.cfg.CONF in keystone).

- keystone.conf.base: Keystone's [DEFAULT] group options. I'd prefer
  this to be called 'default.py', but I'm just copying nova's lead here.

- keystone.conf.opts: The entry point for oslo.config itself.

- keystone.conf.constants: There are a few constants (deprecation
  messages, default paths, etc) that are used by multiple configuration
  modules, so they need to live in a common place.

Change-Id: Ia3daffe3fef111b42de203762e966cd14d8927e2
2016-06-24 17:02:15 +00:00
Jamie Lennox da6ea7e224 Pass a request to controllers instead of a context
Instead of the unformed context dictionary pass a full request object
with access to the context_dict so that existing functions still work.
After this we can replace smaller usages of the context dict with
functions and properties on the request directly.

Change-Id: Ibe822ed7c76a24a7d31d98ce62f873a01e5fb213
2016-06-08 14:56:52 +10:00
Steve Martinelli 3965fbef4d remove deprecated revoke_by_expiration function
revoke_by_expiration is only useful if a token does not have an
audit_id or audit_chain_id. tokens always have an audit ID, so
this function seems redundant. it was also deprecated in the
J release, with no timeline for its removal

Change-Id: Ieb92a70ab782fa8ceb59dc807ea8647587be9e2b
bp: removed-as-of-newton
2016-05-22 14:39:58 +00:00
Lance Bragstad 0d376025ba Fix fernet audit ids for v2.0
The fernet token provider was doing some weird things with audit ids that
caused token rescoping to not work because audit ids were never pulled from the
original token. This commit also enables some tests for v2.0 authentication
with the Fernet as the token provider.

Closes-Bug: 1577558
Change-Id: Iffbaf505ef50a6c6d97c5340645acb2f6fda7e0e
2016-05-04 07:05:39 +00:00
kylin7-sg c08884d9c9 Typo fix in tests
autenticate to authenticate

Change-Id: Ib7f8bd8b91c36819a3b202aa14a341e259f6e357
2016-04-18 10:52:46 +08:00
Navid Pustchi aabc213040 Fix D401 PEP8 violation.
Currently tox ignores D401 (401: First line should be in imperative mood).
This change removes it and make keystoneauth docstring compliantwith it.

Change-Id: I136cf810f47c4c19f29216907a63f226930b5082
Partial-Bug: 1570049
2016-04-14 20:08:52 +00:00
Brant Knudson e6890afb38 Reference config values at runtime
Configuration values can be changed at runtime, therefore the
tests should not use the value that was set at import time
since the value might have been changed.

Change-Id: Ib2baa0da12c5b7f13a3f757fb3faea9da3b0c467
2016-02-24 11:31:28 -06:00
Tin Lam 2bad130bf4 Removing H405 violations from keystone
Keystone's tox.ini contains an "ignore" entry for H405 violations:
multi line docstring summary not separated with an empty line.
All violations of H405 should be fixed so that H405 can be removed
from the ignore list.

Change-Id: I1b2aae0cabc20909cf3b0a405d5e31c5d91148b2
Closes-Bug: #1482773
2016-02-21 03:47:55 -05:00
Julien Danjou 40c3942c12 wsgi: fix base_url finding
The current wsgi.Application.base_url() function does not work correctly
if Keystone runs on something like "http://1.2.3.4/identity" which is now
a default in devstack.

This patch fixes that by using wsgiref.util to parse environment
variable set in WSGI mode to find the real base url and returns the
correct URL. The following environment variables will be used to
produce the effective base url:

  HTTP_HOST
  SERVER_NAME
  SERVER_PORT
  SCRIPT_NAME

Closes-Bug: #1381961
Change-Id: I111c206a8a751ed117c6869f55f8236b29ab88a2
2016-02-16 22:48:08 +00:00
Lance Bragstad 5c51dbbc0a Consolidate the fernet provider validate_v2_token()
When the Fernet token provider was implemented, it extended the
provider.common.py:BaseProvider class. It also overrode most all common methods
the BaseProvider implemented. Other token providers in Keystone (like the UUID
an PKI providers) just implemente a _get_token_id method because token ids may
be different across providers.

This commit also removes validate_v2_token from Fernet provider This method was
no longer being used so it makes sense to remove the duplicate code.

Change-Id: Iddc77f9cb9b2fd69a3e55c32668b808efe9239a1
2016-02-10 17:28:32 +00:00
Jenkins fbf4eccb29 Merge "Add support for strict url safe option on new projects and domains" 2016-01-19 22:58:55 +00:00
Henry Nash 60b52c1248 Add support for strict url safe option on new projects and domains
Building on the earlier patch that provdided the 'new' url name
restriction, this patch adds the 'strict' open that prevents
authenticating to projects and domains with unsafe names.

A release note and config documentation is also added that covers
both this and the earlier patch.

Partially Implements: blueprint url-safe-naming

Change-Id: Ie69025e7759bae1067e05d9190bede192a5e6830
2016-01-19 03:47:31 +00:00
Jenkins a44a29a66f Merge "Remove comments on enforcing endpoints for trust" 2016-01-07 03:05:56 +00:00
Jenkins a4adca6c50 Merge "Config option for insecure responses" 2016-01-06 09:08:58 +00:00
Samuel de Medeiros Queiroz 99814a8df9 Remove comments on enforcing endpoints for trust
Back in the Grizzly version of OpenStack, we introduced Trusts
(I5745f4d9a4180b59671a143a55ed87019e98ec76).

At the time, we had an idea that we would do future work with Trusts
and Endpoints in the regard of limiting what went into Tokens. Hence we
have left TODO notes.

Now that we have the endpoint filtering API, the old idea does not make
sense anymore.

This commit removes those invalid TODO comments.

Change-Id: I25c606bb67a5d5b9f2194c8fb2c7df26170f88eb
2015-12-09 11:58:31 -03:00
Sean Perry df360b8ca0 Use unit.new_project_ref consistently
Replace all hand created project refs with calls to new_project_ref().
In unit tests, rename 'tenant' variables to 'project' where appropriate.
Change-Id: Id6d0462ba527c6950db1d25f19cb25dfaf01a002
2015-11-30 19:31:50 +00:00
Brant Knudson a751604fe0 Merge keystone.config into keystone.common.config
Having two places for config stuff is confusing. There should only
be the one place for config stuff, keystone.common.config.

Change-Id: I83cae5d2140639df228025851ceb3f90c21af08a
2015-11-19 08:24:51 -06:00
Brant Knudson 2afad4dc30 Config option for insecure responses
oslo.log's "debug" option was co-opted to also indicate that the
responses should include more information. A separate config
option should be used instead so that deployers don't mistakenly
expose themselves to security issues.

The debug option still is used for what it does in oslo.log and
how it works on all other projects -- if you're not using a log
config file it sets the base logger to debug.

SecurityImpact

Change-Id: Icf8dd2f0b88abc89092d487bbcefb525960c4ec6
Closes-Bug: 1479523
2015-11-19 08:16:07 -06:00
Sean Perry 5784285e9f Use unit.new_user_ref consistently
Replace all hand created user refs with calls to new_user_ref().

Note: LDAP live testing code will be updated in a follow on patch.
They require more testing before submission.

Change-Id: I73b1d869534ac3a1bcd2404ef1dd3a0d5b7ea518
2015-11-17 19:20:33 +00:00