Skip to content

Commit

Permalink
feat: add checks for JWT scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnacioHeredia committed Jan 25, 2024
1 parent 55baab8 commit c71e918
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions ai4papi/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,18 @@ def get_user_info(token):
f"supported by the project: {MAIN_CONF['auth']['VO']}.",
)

#TODO: uncomment when dashboard is ready (ie. sends email scope) and remove **default=''**
# for k in ['sub', 'iss', 'name', 'email']:
# if user_infos.get(k) is None:
# raise HTTPException(
# status_code=401,
# detail=f"You token should have scopes for {k}.",
# )

# Generate user info dict
for k in ['sub', 'iss', 'name', 'email']:
if user_infos.get(k) is None:
raise HTTPException(
status_code=401,
detail=f"You token should have scopes for {k}.",
)
out = {
'id': user_infos.get('sub'), # subject, user-ID
'issuer': user_infos.get('iss'), # URL of the access token issuer
'name': user_infos.get('name', default=''),
'email': user_infos.get('email', default=''),
'name': user_infos.get('name'),
'email': user_infos.get('email'),
'vos': vos,
}

Expand Down

0 comments on commit c71e918

Please sign in to comment.