Adding roles as comma seperated values on a single header.

This commit is contained in:
Yogeshwar Srikrishnan 2011-06-02 14:11:58 -05:00
parent 38b977efd2
commit c13a04f1ee
2 changed files with 13 additions and 6 deletions

View File

@ -76,8 +76,8 @@ class EchoApp(object):
print ' Tenant :', self.envr['HTTP_X_TENANT']
if 'HTTP_X_GROUP' in self.envr:
print ' Group :', self.envr['HTTP_X_GROUP']
if 'HTTP_X_ROLES' in self.envr:
print ' Roles :', self.envr['HTTP_X_ROLES']
if 'HTTP_X_ROLE' in self.envr:
print ' Roles :', self.envr['HTTP_X_ROLE']
accept = self.envr.get("HTTP_ACCEPT", "application/json")

15
keystone/auth_protocols/auth_token.py Normal file → Executable file
View File

@ -167,8 +167,14 @@ class AuthProtocol(object):
self._decorate_request('X_USER', claims['user'])
if 'group' in claims:
self._decorate_request('X_GROUP', claims['group'])
if 'roles' in claims:
self._decorate_request('X_ROLES', claims['roles'])
if 'roles' in claims and len(claims['roles']) > 0:
if claims['roles'] != None:
roles = ''
for role in claims['roles']:
if len(roles) > 0:
roles += ','
roles += role
self._decorate_request('X_ROLE', roles)
self.expanded = True
#Send request downstream
@ -267,8 +273,9 @@ class AuthProtocol(object):
#first_group = token_info['auth']['user']['groups']['group'][0]
roles =[]
role_refs =token_info["auth"]["user"]["roleRefs"]
for role_ref in role_refs:
roles.append(role_ref["roleId"])
if role_refs != None:
for role_ref in role_refs:
roles.append(role_ref["roleId"])
verified_claims = {'user': token_info['auth']['user']['username'],
'tenant': token_info['auth']['user']['tenantId'], 'roles':roles}