Skip to content

Commit

Permalink
Skip sharing if tenant id missing from token. This should handle
Browse files Browse the repository at this point in the history
domain or project scoped token. Also fix bug in vnc api V3 token
generation

Change-Id: I336b3a8d79d76817cfc09d25ee941abd54fa15f6
Fixes-Bug: #1612531
  • Loading branch information
Deepinder Setia committed Aug 13, 2016
1 parent 496935f commit a22cac0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/api-lib/vnc_api.py
Expand Up @@ -243,15 +243,15 @@ def __init__(self, username=None, password=None, tenant_name=None,
' "password":{' + \
' "user":{' + \
' "name": "%s",' % (self._username) + \
' "domain": { "id": "%s" },' % (self._domain_name) + \
' "domain": { "name": "%s" },' % (self._domain_name) + \
' "password": "%s"' % (self._password) + \
'}' + \
'}' + \
'},' + \
' "scope":{' + \
' "project":{' + \
' "domain": { "id": "%s" },' % (self._domain_name) + \
' "name": "%s"' % (self._username) + \
' "domain": { "name": "%s" },' % (self._domain_name) + \
' "name": "%s"' % (self._tenant_name) + \
'}' + \
'}' + \
'}' + \
Expand Down
9 changes: 2 additions & 7 deletions src/config/api-server/vnc_cfg_api_server.py
Expand Up @@ -2891,13 +2891,8 @@ def _list_collection(self, obj_type, parent_uuids=None,

# include objects shared with tenant
env = get_request().headers.environ
tenant_name = env.get(hdr_server_tenant()) or 'default-project'
tenant_fq_name = ['default-domain', tenant_name]
try:
tenant_uuid = self._db_conn.fq_name_to_uuid('project', tenant_fq_name)
shares = self._db_conn.get_shared_objects(obj_type, tenant_uuid)
except NoIdError:
shares = []
tenant_uuid = env.get('HTTP_X_PROJECT_ID')
shares = self._db_conn.get_shared_objects(obj_type, tenant_uuid) if tenant_uuid else []
owned_objs = set([obj_uuid for (fq_name, obj_uuid) in result])
for (obj_uuid, obj_perm) in shares:
# skip owned objects already included in results
Expand Down

0 comments on commit a22cac0

Please sign in to comment.