Skip to content

Commit

Permalink
adding userinfo to introspect
Browse files Browse the repository at this point in the history
  • Loading branch information
costero-e committed Oct 30, 2023
1 parent 3a5a324 commit cf58289
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions permissions/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,24 @@ async def get_user_info(access_token):
content = await resp.text()
dict_content = json.loads(content)
user = dict_content
return user
else:
LOG.error('Content: %s', content)
LOG.error('Invalid token')
raise web.HTTPUnauthorized()


user = None
async with ClientSession(trust_env=True) as session:
headers = { 'Accept': 'application/json', 'Authorization': 'Bearer ' + access_token }
LOG.debug('Contacting %s', idp_user_info)
async with session.get(idp_user_info, headers=headers) as resp:
LOG.debug('Response %s', resp)
if resp.status == 200:
user = await resp.json()
return user
else:
content = await resp.text()
LOG.error('Content: %s', content)
raise web.HTTPUnauthorized()



Expand Down
1 change: 1 addition & 0 deletions permissions/permissions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ new_user:
- GiaB
usuari_creat:
- hola
null: []

0 comments on commit cf58289

Please sign in to comment.