Adding roles as comma seperated values on a single header.
This commit is contained in:
parent
38b977efd2
commit
c13a04f1ee
|
@ -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")
|
||||
|
|
|
@ -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}
|
||||
|
|
Loading…
Reference in New Issue