Commit Graph

45 Commits

Author SHA1 Message Date
Alexandre Arents 4df09a8c4f Revoke list_events: Add trust sql filter
Currently all token validation evaluate all events
related to trust deletion even if current token is neihter
trust scoped or if trust_ids do not match token trust.
This involves token validation time variation in environment
where trust deletion is high.

This change reduce token validation time and make it stable
during token life cycle by filtering also on trust_id when
querying revocation_event table.

Change-Id: If592599a12035769491eaed3df1541b5afe43e3f
2023-07-12 15:17:55 +02:00
Stephen Finucane 6dfde5b48b requirements: Bump linter requirements
The pep257 dependency does not support Python 3.10 and has been
deprecated in favour of flake8-docstrings. While we're here, we bump the
other linter dependencies and remove a note regarding the order of
dependencies, which is no longer true with the new dependency resolver
introduced in pip 20.3. We also remove an import exception for six.moves
since we no longer use six.

Change-Id: I4aae75f513568126230becf27b2e07d6682d35a1
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-10-26 15:14:21 +03:00
Vishakha Agarwal 4530041931 Remove six usage
This repo does not support Python 2 anymore, so we don't need
six for compatibility between Python2 and 3, convert six usage to Python
3 code.

Change-Id: Icba56808f38277b27af2ae5aac4b8507dee71b3b
2020-01-30 06:06:51 +00:00
Vishakha Agarwal 4b2c456697 Remove unused revoke_by_user_and_project
This patch removes a method that wasn't being
used anymore anywhere except for a single unit
test. Since keystone now validates Fernet
tokens the same way - by rebuilding the token
context at validation time, we no longer need
to persist certain types of revocation events.

Change-Id: Ic9dcc6a5fd40e504ec04dcefab995d03927362bc
partial-bug: #1671887
2018-09-14 04:08:01 +00:00
Morgan Fainberg a4d9a4f13b Convert OS-REVOKE to flask dispatching
Convert OS-REVOKE to flask dispatching.

Change-Id: I2504d4326b8c35fd6d9a0d929afc7e658e9c14f9
Partial-Bug: #1776504
2018-08-01 11:46:25 -07:00
Morgan Fainberg 4ec6bc5a44 Convert Keystone to use Flask
Basic conversion of Keystone's core application to flask framework.

This doesn't add much in the way of flask-specific-isms but should
get keystone running directly under flask. This implementation does
not use paste-deploy.

Change-Id: Ib4c1ed3f645dd55fbfb76395263ecdaf605caae7
2018-06-04 20:14:41 -07:00
Lance Bragstad c7658abfd6 Simplify token persistence callbacks
The INVALIDATE_USER_TOKEN_PERSISTENCE and
INVALIDATE_USER_PROJECT_TOKEN_PERSISTENCE callbacks were meant to
clean up invalid tokens from the token storage layer. Now that the
sql token driver has been removed, we don't need them any more. This
commit removes those notifications and refactors the places where
notifications are still needed, making them more specific and not
eluding to token persistence.

This commit also removes a significant amount of logic from the
assignment API that used to notify the token API when assignments
were deleted. This made sense when tokens were written to disk
because there was an opportunity to invalidate them when users were
removed from projects. This is no longer needed since we do
validation online and we don't persist tokens anymore.

Change-Id: I100b7416e8ba61eb4ea2c2eb4962e952a53ea388
2018-02-16 21:40:07 +00:00
Lance Bragstad d5e9c0b4fe Remove all v2.0 APIs except the ec2tokens API
The only API we're supporting on the v2.0 path until the T release is
the ec2tokens API. This commit removes all routers from the public
and admin v2.0 applications. This includes the extensions API. This
commit also removes unused v2.0 controller logic.

Change-Id: I523c1215899ac9ee605df6bf717643c0ba87c761
Closes-Bug: 1746798
2018-02-06 23:12:55 +01:00
Lance Bragstad 2f9b444ab0 Use keystone.common.provider_api for revoke APIs
This change converts the usage of self.<provider_api> to
keystone.common.providers_api.ProviderAPIs.<provider_api> in manager
and controller logic. This is the correct way to reference
providers from other managers and controllers now that dependency
injection has been eliminated.

Change-Id: I262536f96c5a1944308252ee2834082b66b1a8cd
2017-12-27 17:31:30 +00:00
Morgan Fainberg 81f9fe6fed Remove Dependency Injection
Refactors all of keystone's dependency injection to maintain a
single centralized repository of instantiated objects. This
means that we are no longer having to resolve order. All
objects that need to reference the various manager APIs simply
do so via the __getattr__ built into the Manager common object
or the ProviderAPIMixin object.

This is also the first step towards correcting our tests to
where they cannot run "load_backends" multiple times.

This forces any/all managers to properly run super()
as the way to register the api is via __init__.

This eliminates all use of the @dependency.requires and
@dependency.provides decorators, simplifying the objects
all around.

Any instantiations of a Manager after keystone is running
will now generate an error, ensuring everything for keystone
is running before handling requests. An exception is for
CLI and CLI tests, as the CLI may directly instantiate
managers and will not lock the registry.

Change-Id: I4ba17855efd797c0db9f4824936b49e4bff54b6a
2017-12-13 10:59:39 -08:00
Jorge Munoz 8eb29c37d1 Validate disabled domains and projects online
Keystone's performance degrades as the `revocation_event` table grows
in size. This patch reduces the total number of events written to the
table by not persisting events when a domain or project is disabled.

The main reason for persisting a revocation event when a project or
domain is disabled is to make sure tokens associated to those targets
are considered invalid. Instead of relying on revocation events, we
can check if the project or domain is enabled when we validate the
token. We take the same approach when we validate a user's role
assignments instead of relying on an ever-growing database table.

Co-Authored-By: Lance Bragstad <lbragstad@gmail.com>

Closes-Bug: 1524030
Change-Id: I76330567e0df2d9f2af88ef9b6b98b8c379e7406
2017-11-27 23:06:10 +00:00
Richard Avelar 14ff6e467e Remove unused revoke_by_domain_role_assignment
This patch removes a method that wasn't being used anymore anywhere
except for a single unit test. In addition, we no longer need to store
the revocation event when the token provider API will rebuild the
token context at validation time. Some of the test coverage for this
behavior can be located here:
https://github.com/openstack/keystone/blob/master/keystone/tests/unit/test_v3_assignment.py#L1175-L1177
https://github.com/openstack/keystone/blob/master/keystone/tests/unit/test_v3_assignment.py#L1191-L1193
https://github.com/openstack/keystone/blob/master/keystone/tests/unit/test_v3_assignment.py#L1311

Change-Id: I1ee53f15ec6b2dae10bfbd0fc3435e018f26f04b
partial-bug: 1671887
2017-03-24 15:22:04 +00:00
Richard Avelar 259d4d4179 Remove unused revoke_by_project_role_assignment
This patch removes a method that wasn't being used anymore anywhere
except for a single unit test. In addition, we no longer need to store
the revocation event when the token provider API will rebuild the
token context at validation time, and this revocation method isn't being
exposed to an external API.

Among some of the test coverage for this can be found here:
https://github.com/openstack/keystone/blob/master/keystone/tests/unit/test_v3_auth.py#L2030-L2060

Change-Id: Ie92b238b0968a23bca3f0f57879369ea74298b8d
partial-bug: 1671887
2017-03-24 15:21:03 +00:00
Richard Avelar 07966bbee4 Remove unnecessary revocation events revoke grant
With [1], we no longer need revoke_by_grant callback. It isn't being
used anywhere and token providers rebuild tokens at validation time.

[1]: https://review.openstack.org/#/c/447562/

Change-Id: I4e7e2f29d3db0eb8486173d4fb9134d61aab6dab
partial-bug: 1671887
2017-03-24 15:21:03 +00:00
Richard Avelar 890b1d4325 Remove unnecessary revocation events
With [0], we no longer need role_assignment callback. It isn't being
used anywhere and token providers rebuild tokens at validation time.
Some links to show test coverage for role_assignment:
https://github.com/openstack/keystone/blob/master/keystone/tests/unit/test_auth.py#L526-L553
https://github.com/openstack/keystone/blob/master/keystone/tests/unit/test_v3_auth.py#L2993
https://github.com/openstack/keystone/blob/master/keystone/tests/unit/test_v3_auth.py#L3179
https://github.com/openstack/keystone/blob/master/keystone/tests/unit/test_v3_auth.py#L3329
https://github.com/openstack/keystone/blob/master/keystone/tests/unit/test_v3_auth.py#L3610
https://github.com/openstack/keystone/blob/master/keystone/tests/unit/test_v3_assignment.py#L31-L33

[0]: https://review.openstack.org/#/c/447562/

Change-Id: If690c8ff8466e8568a8c9dc4463f341adb675630
partial-bug: 1671887
2017-03-24 15:21:03 +00:00
Lance Bragstad 939881b77f Don't persist revocation events when deleting a role
This is no longer needed since the token provider API will
rebuild the token context at validation time. The revocation event
is not needed and we no longer need to store it.

Change-Id: I91315f620534974ab1102d693fbdff45e4ae8887
partial-bug: 1671887
2017-03-23 03:11:25 +00:00
Ubuntu 9f8e412e49 Don't persist rev event when deleting access token
This is no longer needed since the token provider API will
rebuild the token context at validation time. The revocation event
is not needed and we no longer need to store it.

Change-Id: I4dc766981a29b0afd0a44718c1c5d81155163982
partial-bug: 1671887
2017-03-21 15:56:48 +00:00
Eric Brown 30d9095d28 Use https for docs.openstack.org references
The openstack.org pages now support https and our references to
the site should by default be one signed by the organization.

Change-Id: I30a462e03d1fd7852511e22cac34c6bc0e8917f4
2017-01-30 16:05:08 -08:00
Morgan Fainberg 6f1079586e Do not call `to_dict` outside of a session context
Do not call `to_dict` outside of a session context as if to_dict
interacts with lazy-loaded relationships it can cause errors. For
the most part these are edge-cases and unlikely to happen.

A couple FIXMEs were added to restructure the calls to allow for
`to_dict` to be moved into a method that will act within a session
context.

Change-Id: I769c2cdea1b08a780093d27cdc70bce9f004017b
2017-01-25 06:12:20 +00:00
“Richard 9e84371461 Improve check_token validation performance
This patch improves check_token validation performance by only pulling
revocation events based on the token issued_at value, taking advantage
of the table index. In this way, only a subset of relevant events will
be returned for validation.

Benchmarks can be seen at [1], but included here as well:

Time per Request for Old Method
-------------------------------
10 revokes at 7.908
100 revokes at 18.224
1,000 revokes at 110.155
10,000 revokes at 1998.220

Time per Request New Method
---------------------------
10 revokes at 17.636ms,
100 revokes at 17.279ms,
1,000 revokes at 17.370,
10,000 revokes w/all revokes issued before token at 17.263 (best case)
10,000 revokes w/all revokes after token creation 44.934ms (worst case)

[1] https://gist.github.com/csrichard1/4b7b8527ee5a6565a84956cff33cf29b

Change-Id: I9c2f067d870d542ec5909eaf8b24ded07b75f433
Partial-Bug: 1524030
2016-10-13 15:39:54 +00:00
Ronald De Rose 477189d0c5 Add revocation event indexes
This patch adds indexes to the revocation_event table as part of an
effort to improve performance during token validation.

Partial-Bug: 1524030
Change-Id: I73ff077bb6dc3ca8821f8cc14639bf986517d158
2016-10-13 15:38:36 +00:00
Steve Martinelli 810e15689b Remove stable driver interfaces
bp removed-as-of-ocata

Change-Id: I4672cf7d9d72ef725212085972dbcd90db0e47cf
2016-09-28 17:18:37 +00:00
David Stanek 42eda48c78 Distributed cache namespace to invalidate regions
dogpile.cache's region invalidation is not designed to work across
processes. This patch enables distributed invalidation of keys in a
region.

Instead of using a static cache key, we use the original cache key
and append a dynamic value to it. This value is looked up in
memcached using the region name as a key. So anytime the value of
the region key changes the cache keys in that region are
effectively invalidated.

Closes-Bug: #1590779
Change-Id: Ib80d41d43ef815b37282d72ad68e7aa8e1ff354e
2016-08-29 16:38:55 +00:00
Dave Chen dd63146cf1 Update `href` for keystone extensions
Since the API docs have been moved to api-ref, and the docs maintained
in keystone-specs repo have been moved to attic. The href attribute
that points to old `specs.openstack.org` will not be a valid link, this
patch update them to point to the new site.

Change-Id: Idc4995509d262c74ce6d49c6c18b6452fae186d6
2016-08-22 11:09:43 +08:00
Mikhail Nikolaenko e8022f3d31 Retry revocation on MySQL deadlock
Added wrapper for revoke method that makes additional attempts on
deadlock.

Change-Id: I506c6b432d4d23619237a32414d0039c749cd8b6
Closes-Bug: #1604862
2016-08-03 15:51:11 +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
Jenkins 6589ac6b69 Merge "Replace revoke tree with linear search" 2016-05-25 15:13:43 +00:00
Adam Young 75abc21ecf Replace revoke tree with linear search
The RevokeTree was built out of an attempt to optimize the search for
a match between a candidate token and the list of revocation events.
The performance proved to be poor, mostly due to the cost of creating
and checking hash values.

The RevokeTree code is also so complex that most of the team could not
understand it or troubleshoot it.  There are some subtle bugs due to
race conditions with revocation events, and it is impossible to track
them down due to the code complexity.

This change replaces the tree based search with a linear search through
the list of revocation events.  A failure-to-match will pass through
the entire list.  A revoked token should match on O(n/2) comparisons.

With the past year of Fernet tokens in deployment, the feedback is that
the number of revocation events is small, and they only are kept for
the lifetime of the tokens (usually 1-8 hours) so the linear search is
not expected to slow down token validations in live deployments.

Future work will also reduce the number of revocation events.

Change-Id: Ib6a686494e897840b09d134ecf1ca50ce712f281
2016-05-24 13:11:30 -04: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
Ronald De Rose 47529d0e32 Move the revoke abstract base class out of core
This patch moves the revoke abstract base class out of core and into
backends/base.py

This removes dependencies where backend code references code in the
core. The reasoning being that the core should know about the backend
interface, but the backends should not know anything about the core
(separation of concerns). And part of the risk here is a potential for
circular dependencies.

Partial-Bug: #1563101

Change-Id: I0550e0fedfb28b16e9803d225df4d2337e6c65e6
2016-05-18 02:38:00 +00:00
Navid Pustchi 2c4f948db0 Fix D400 PEP257
Currently tox ignores D401.
D400: First line should end with a period.
This change removes it and make keystone docstring compliantwith it.

Change-Id: I9a9520e69701718ff471eebbcc52199dacdd9c68
2016-04-21 15:25:34 +00: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
Ronald De Rose 34db9c0e53 Add auto-increment int primary key to revoke.backends.sql
Modified the revocation_event id column to be an auto-incremented
integer.  The id column was a varchar(64), however it is only used
internally and an integer column will help with large deletes.

Change-Id: Ibbac98ec50583579ca8fcb8f928d4882f571b07c
Closes-Bug: 1290625
2016-03-09 20:38:45 +00:00
Morgan Fainberg 0eba0e0477 Use requst local in-process cache per request
Use a request local cache, where possible, to offload requests
to the backend.

Change-Id: I8b744f75f21e9dd669a735a7717fd0d044d6d8ed
Depends-On: I6d1d28f5b974e79d44d1e86ea53c666e3f5771df
2016-02-24 13:34:46 -08:00
Grzegorz Grasza 0e156737d0 Use the new enginefacade from oslo.db
EngineFacade is deprecated. This partially switches keystone to
use oslo.db.sqlalchemy.enginefacade. 'get_session' and 'get_engine'
methods are still used in sql migrations and related tests.

Change-Id: I221232d50821fe2adb9881f237f06714003ce79d
Partial-Bug: #1490571
2016-02-24 08:20:12 -08:00
Raildo Mascena d32d9de2aa Avoid `None` as a redundant argument to dict.get()
`dict.get()` returns `None` by default, if a key wasn't found.
Removing `None` as second argument to avoid redundancy.

Change-Id: I810854f50257b9dc805248ff1017521cc82d5d73
2016-02-15 13:40:50 -03:00
David Stanek 2896901691 Removed deprecated revoke KVS backend
it has been deprecated since the Icehouse release

bp: removed-as-of-mitaka
Change-Id: I988fcd1f823fa82b197b3ca2c322d64da296fc9a
2016-01-25 01:08:15 -08:00
Chaozhe.Chen 87eb9d8687 Trival: Remove unused logging import
In some files, oslo_log.log has been imported but not used.
So remove it.

Change-Id: I0cdd50fd764cfab503c1a0dd3c79d9f295eaeb8a
2015-12-26 15:14:25 +08:00
Jenkins 292ca5b105 Merge "Remove exposure of routers at package level" 2015-12-10 00:40:22 +00:00
Samuel de Medeiros Queiroz dbbea6b5c5 Update extensions links
Extensions links are out-of-date. They are either
invalid or pointing to an old repository [1].

This patch fixes such links.

[1] https://github.com/openstack/identity-api

Change-Id: I6cd461b3ba24a042fd188d6398212ded582eb365
2015-12-07 17:13:33 -03:00
Samuel de Medeiros Queiroz e64a1b5891 Remove exposure of routers at package level
Keystone API routers are exposed at their package
level (in __init__.py files). This causes them to
be unnecessarily executed each time something
whithin that package is used.

For example, simply importing
keystone.federation.constants would make the
federation routers code to be executed.

This patch remove routers exposure from package
level and import them directly in services.py,
which is the single place that needs them.

Change-Id: If68184c871ac77659ad2e64aa5f0aafac7a4bf70
2015-12-03 15:06:56 -03:00
Dave Chen 5070039812 Using the right format to render the docstring correctly
There are several issues in the docstring, the format is not
correct, not using the full path of class etc.

This patch corrects all of them, so the docstring will be rendered
correctly.

Change-Id: I04d5818f38b5e75b6f6197ef5e13dcd64ed91bf4
2015-11-24 04:37:14 +00:00
Steve Martinelli 32b70d15c4 Move revoke extension into core
Remove revoke as an extension and move it to a core resource.
For now we leave the database migrations in the extension directory
until we have a general policy for merging these into core.

DocImpact: update keystone-paste and remove revoke from pipeline

Change-Id: I2d6f425a508b7acb4b4d079e4387f25bf7555683
Implements: bp move-extensions
2015-11-18 15:14:07 +00:00