Update after bug:1515255
[openstack-build/django_openstack_auth-build.git] / centos7 / rpm / SOURCES / 0007-Configurable-token-hashing.patch
1 From 4ff5ab56b6ad6f17cf51da48d2e847f4b445e6f5 Mon Sep 17 00:00:00 2001
2 From: lin-hua-cheng <os.lcheng@gmail.com>
3 Date: Mon, 13 Jul 2015 15:51:58 -0700
4 Subject: [PATCH] Configurable token hashing
5
6 Provide an option for operator to turn off token
7 hashing to be performed by horizon.
8
9 In some deployment where PKI token format is used
10 for keystone, token hashing causes issue and results
11 to 401 error in horizon.
12
13 Change-Id: I187b1486db2e453fd49298e1478e30abe97e54fe
14 Closes-Bug: #1473588
15 (cherry picked from commit ece924a79d27ede1a8475d7f98e6d66bc3cffd6c)
16 ---
17  openstack_auth/user.py | 6 ++++--
18  1 file changed, 4 insertions(+), 2 deletions(-)
19
20 diff --git a/openstack_auth/user.py b/openstack_auth/user.py
21 index 132e37b..77325de 100644
22 --- a/openstack_auth/user.py
23 +++ b/openstack_auth/user.py
24 @@ -23,6 +23,7 @@ from openstack_auth import utils
25  
26  
27  LOG = logging.getLogger(__name__)
28 +_TOKEN_HASH_ENABLED = getattr(settings, 'OPENSTACK_TOKEN_HASH_ENABLED', True)
29  
30  
31  def set_session_from_user(request, user):
32 @@ -81,8 +82,9 @@ class Token(object):
33          # Token-related attributes
34          self.id = auth_ref.auth_token
35          self.unscoped_token = unscoped_token
36 -        if (keystone_cms.is_asn1_token(self.id)
37 -                or keystone_cms.is_pkiz(self.id)):
38 +        if (_TOKEN_HASH_ENABLED and
39 +                (keystone_cms.is_asn1_token(self.id)
40 +                    or keystone_cms.is_pkiz(self.id))):
41              algorithm = getattr(settings, 'OPENSTACK_TOKEN_HASH_ALGORITHM',
42                                  'md5')
43              hasher = hashlib.new(algorithm)