Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tenant_id parsing is not working due to different response from API_KEY authentication in some usser #665

Open
biswazr opened this issue Sep 8, 2022 · 2 comments

Comments

@biswazr
Copy link

biswazr commented Sep 8, 2022

self.tenant_id = token["tenant"]["id"]

there are few token which do not generate the needed response

{
  u'access': {
    u'token': {
      u'RAX-AUTH:authenticatedBy': [u'APIKEY'], 
      u'RAX-AUTH:issued': u'2022-09-08T07:07:07.616Z',
      u'expires': u'2022-09-09T06:58:44.616Z',
      u'id': '***REDACTED ***'
    },
u'serviceCatalog': [{u'endpoints': [{u'region': u'IAD', u'publicURL': u'https://global.metrics.api.rackspacecloud.com/v2.0/***REDACTED ***', u'tenantId': u'hybrid:00000'}], u'type': u'rax:cloudmetrics', u'name': u'cloudMetrics'}, {u'endpoints': [{u'publicURL': u'https://monitoring.api.rackspacecloud.com/v1.0/hybrid:***REDACTED ***', u'tenantId': u'hybrid:***REDACTED ***'}], u'type': u'rax:monitor', u'name': u'cloudMonitoring'}], u'user': {u'RAX-AUTH:domainId': u'dedicated:***REDACTED ***', u'RAX-AUTH:phonePinState': u'ACTIVE', u'name': u'***REDACTED ***', u'roles': [{u'id': u'***REDACTED ***', u'description': u'Monitoring Admin Role for Account User', u'name': u'monitoring:admin', u'tenantId': u'hybrid:***REDACTED ***'}, {u'id': u'16', u'description': u'a role that allows a user access to dedicated service methods', u'name': u'dedicated:default', u'tenantId': u'hybrid:***REDACTED ***'}, {u'id': u'***REDACTED ***', u'description': u'A role to grant visibility to a tenant', u'name': u'identity:tenant-access', u'tenantId': u'hybrid:00000'}, {u'id': u'2', u'name': u'identity:default', u'description': u'Default Role.'}], u'RAX-AUTH:phonePin': u'***REDACTED ***', u'email': u'***REDACTED ***', u'RAX-AUTH:sessionInactivityTimeout': u'PT12H', u'RAX-AUTH:defaultRegion': u'IAD', u'RAX-AUTH:contactId': u'***REDACTED ***', u'id': ***REDACTED ***'}}}

Values redacted to hide user detail but the response structure kept as it is

File "/Users/bisw8246/Desktop/repos/py2devtoolsenv2/lib/python2.7/site-packages/pyrax/identity/rax_identity.py", line 83, in authenticate password=password, api_key=api_key, tenant_id=tenant_id) File "/Users/bisw8246/Desktop/repos/py2devtoolsenv2/lib/python2.7/site-packages/pyrax/base_identity.py", line 622, in authenticate self._parse_response(resp_body) File "/Users/bisw8246/Desktop/repos/py2devtoolsenv2/lib/python2.7/site-packages/pyrax/identity/rax_identity.py", line 123, in _parse_response super(RaxIdentity, self)._parse_response(resp) File "/Users/bisw8246/Desktop/repos/py2devtoolsenv2/lib/python2.7/site-packages/pyrax/base_identity.py", line 631, in _parse_response self.tenant_id = token["tenant"]["id"]

@biswazr biswazr changed the title token Access token parsing is not working due to different response from API_KEY authentication Sep 8, 2022
@biswazr biswazr changed the title Access token parsing is not working due to different response from API_KEY authentication Tenant_id parsing is not working due to different response from API_KEY authentication in some usser Sep 8, 2022
@biswazr
Copy link
Author

biswazr commented Sep 8, 2022

soln :

[pyrax/pyrax/base_identity.py]
(

self.tenant_id = token["tenant"]["id"]
)
self.tenant_id = access['serviceCatalog'][0]['endpoints'][0]['tenantId'].split(":")[-1]
self.tenant_name = access['serviceCatalog'][0]['name']

@cardoe
Copy link
Collaborator

cardoe commented Sep 22, 2022

The underlying issue here is that pyrax is for Rackspace's OpenStack Public Cloud services and the user in question doesn't have those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants