Slimming down the session size.
Uses the MD5 hash for the unscoped token as well as the scoped token, and removes unused (duplicate) data from the session.
This commit is contained in:
parent
b7c6d9b93e
commit
8a88978154
@ -1,2 +1,2 @@
|
||||
# following PEP 386
|
||||
__version__ = "1.0.3"
|
||||
__version__ = "1.0.4"
|
||||
|
@ -1,5 +1,6 @@
|
||||
""" Module defining the Django auth backend class for the Keystone API. """
|
||||
|
||||
import hashlib
|
||||
import logging
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
@ -10,7 +11,7 @@ from keystoneclient.v2_0.tokens import Token, TokenManager
|
||||
|
||||
from .exceptions import KeystoneAuthException
|
||||
from .user import create_user_from_token
|
||||
from .utils import check_token_expiration
|
||||
from .utils import check_token_expiration, is_ans1_token
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -113,6 +114,9 @@ class KeystoneBackend(object):
|
||||
user = create_user_from_token(request, token, client.management_url)
|
||||
|
||||
if request is not None:
|
||||
if is_ans1_token(unscoped_token.id):
|
||||
hashed_token = hashlib.md5(unscoped_token.id).hexdigest()
|
||||
unscoped_token._info['token']['id'] = hashed_token
|
||||
request.session['unscoped_token'] = unscoped_token.id
|
||||
request.user = user
|
||||
|
||||
|
@ -9,16 +9,11 @@ from .utils import check_token_expiration, is_ans1_token
|
||||
|
||||
|
||||
def set_session_from_user(request, user):
|
||||
request.session['serviceCatalog'] = user.service_catalog
|
||||
request.session['tenant'] = user.tenant_name
|
||||
request.session['tenant_id'] = user.tenant_id
|
||||
if is_ans1_token(user.token.id):
|
||||
hashed_token = hashlib.md5(user.token.id).hexdigest()
|
||||
user.token._info['token']['id'] = hashed_token
|
||||
request.session['token'] = user.token._info
|
||||
request.session['username'] = user.username
|
||||
request.session['user_id'] = user.id
|
||||
request.session['roles'] = user.roles
|
||||
request.session['region_endpoint'] = user.endpoint
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user