From 6eaf9f11f20fc61b8ac2611f9e31591fb7f52ef3 Mon Sep 17 00:00:00 2001 From: Antoine Eiche Date: Tue, 16 Feb 2016 12:47:46 +0100 Subject: [PATCH] Add vnc_api method set_user_roles (and only set_user_roles) This allows to manually set the roles of the user in the HTTP header. Conflicts: src/api-lib/vnc_api.py Partial-Bug: 1546057 (cherry picked from commit e18b36e5a9587f45e9291d77453480fcba985798) Change-Id: I1aa133431e42b4aeb02944ea1420bf13b232f98d (cherry picked from commit 364bb09ad78850917bda68e0bde8e47cf29a8b19) --- src/api-lib/vnc_api.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/api-lib/vnc_api.py b/src/api-lib/vnc_api.py index 0771a217457..de87f41a5a2 100644 --- a/src/api-lib/vnc_api.py +++ b/src/api-lib/vnc_api.py @@ -275,7 +275,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) @@ -808,4 +808,12 @@ def resource_list(self, obj_type, parent_id=None, parent_fq_name=None, return resource_objs #end resource_list + 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