Merge "Isolate token caching into its own region"
This commit is contained in:
commit
1f6bbf6c0b
|
@ -41,6 +41,7 @@ def load_backends():
|
||||||
cache.configure_cache(region=revoke.REVOKE_REGION)
|
cache.configure_cache(region=revoke.REVOKE_REGION)
|
||||||
cache.apply_invalidation_patch(region=revoke.REVOKE_REGION,
|
cache.apply_invalidation_patch(region=revoke.REVOKE_REGION,
|
||||||
region_name=revoke.REVOKE_REGION.name)
|
region_name=revoke.REVOKE_REGION.name)
|
||||||
|
cache.configure_cache(region=token.provider.TOKENS_REGION)
|
||||||
|
|
||||||
# Ensure that the identity driver is created before the assignment manager
|
# Ensure that the identity driver is created before the assignment manager
|
||||||
# and that the assignment driver is created before the resource manager.
|
# and that the assignment driver is created before the resource manager.
|
||||||
|
|
|
@ -20,6 +20,7 @@ import datetime
|
||||||
import sys
|
import sys
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from oslo_cache import core as oslo_cache
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
import six
|
||||||
|
@ -39,7 +40,11 @@ from keystone.token import utils
|
||||||
|
|
||||||
CONF = keystone.conf.CONF
|
CONF = keystone.conf.CONF
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
MEMOIZE = cache.get_memoization_decorator(group='token')
|
|
||||||
|
TOKENS_REGION = oslo_cache.create_region()
|
||||||
|
MEMOIZE_TOKENS = cache.get_memoization_decorator(
|
||||||
|
group='token',
|
||||||
|
region=TOKENS_REGION)
|
||||||
|
|
||||||
# NOTE(morganfainberg): This is for compatibility in case someone was relying
|
# NOTE(morganfainberg): This is for compatibility in case someone was relying
|
||||||
# on the old location of the UnsupportedTokenVersionException for their code.
|
# on the old location of the UnsupportedTokenVersionException for their code.
|
||||||
|
@ -287,11 +292,11 @@ class Manager(manager.Manager):
|
||||||
LOG.debug('Unable to validate token: %s', e)
|
LOG.debug('Unable to validate token: %s', e)
|
||||||
raise exception.TokenNotFound(token_id=token_id)
|
raise exception.TokenNotFound(token_id=token_id)
|
||||||
|
|
||||||
@MEMOIZE
|
@MEMOIZE_TOKENS
|
||||||
def validate_non_persistent_token(self, token_id):
|
def validate_non_persistent_token(self, token_id):
|
||||||
return self.driver.validate_non_persistent_token(token_id)
|
return self.driver.validate_non_persistent_token(token_id)
|
||||||
|
|
||||||
@MEMOIZE
|
@MEMOIZE_TOKENS
|
||||||
def _validate_token(self, token_id):
|
def _validate_token(self, token_id):
|
||||||
if not token_id:
|
if not token_id:
|
||||||
raise exception.TokenNotFound(_('No token in the request'))
|
raise exception.TokenNotFound(_('No token in the request'))
|
||||||
|
@ -312,11 +317,11 @@ class Manager(manager.Manager):
|
||||||
return self.driver.validate_v2_token(token_ref)
|
return self.driver.validate_v2_token(token_ref)
|
||||||
raise exception.UnsupportedTokenVersionException()
|
raise exception.UnsupportedTokenVersionException()
|
||||||
|
|
||||||
@MEMOIZE
|
@MEMOIZE_TOKENS
|
||||||
def _validate_v2_token(self, token_id):
|
def _validate_v2_token(self, token_id):
|
||||||
return self.driver.validate_v2_token(token_id)
|
return self.driver.validate_v2_token(token_id)
|
||||||
|
|
||||||
@MEMOIZE
|
@MEMOIZE_TOKENS
|
||||||
def _validate_v3_token(self, token_id):
|
def _validate_v3_token(self, token_id):
|
||||||
return self.driver.validate_v3_token(token_id)
|
return self.driver.validate_v3_token(token_id)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue