Skip to content

Commit

Permalink
Add vnc_api method set_user_roles
Browse files Browse the repository at this point in the history
This allows to manually set the roles of the user in the HTTP header.

Change-Id: Ifdf28ce18de55b3bed3e59de56de415da1839c2f
Partial-Bug: 1546057
  • Loading branch information
Antoine Eiche committed Feb 16, 2016
1 parent dc3ceda commit e18b36e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/api-lib/vnc_api.py
Expand Up @@ -308,7 +308,7 @@ def __init__(self, username=None, password=None, tenant_name=None,
if 'user' in self._user_info:
self._headers['X-API-USER'] = self._user_info['user']
if 'role' in self._user_info:
self._headers['X-API-ROLE'] = self._user_info['role']
self.set_user_roles([self._user_info['role']])

#self._http = HTTPClient(self._web_host, self._web_port,
# network_timeout = 300)
Expand Down Expand Up @@ -1138,4 +1138,12 @@ def set_auth_token(self, token):
self._headers['X-AUTH-TOKEN'] = token
#end set_auth_token

def set_user_roles(self, roles):
"""Park user roles for forwarding to API server for RBAC.
:param roles: list of roles
"""
self._headers['X-API-ROLE'] = (',').join(roles)
#end set_user_roles

#end class VncApi

0 comments on commit e18b36e

Please sign in to comment.