Skip to content

Commit

Permalink
update get_username
Browse files Browse the repository at this point in the history
  • Loading branch information
NotChristianGarcia committed Nov 22, 2024
1 parent 5945a1f commit 79fc201
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions service/api_pods_podid_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,13 @@ def is_logged_in(cookies):
return False, None, None


def get_username(token):
def get_username(tapis_domain, token):
"""
Validate a Tapis JWT, `token`, and resolve it to a username.
"""
headers = {'Content-Type': 'text/html'}
# call the userinfo endpoint
url = f"{conf['primary_site_admin_tenant_base_url']}/v3/oauth2/userinfo"
url = f"https://{tapis_domain}/v3/oauth2/userinfo"
headers = {'X-Tapis-Token': token}
try:
rsp = requests.get(url, headers=headers)
Expand Down Expand Up @@ -477,7 +477,9 @@ def callback(pod_id_net, request: Request):
except Exception as e:
raise Exception(f"Error generating Tapis token; debug: {e}")

username = get_username(token)
logger.debug(f"GET /pods/{pod_id_net}/auth/callback - pod_auth_callback, token: {token}")

username = get_username(tapis_domain=tapis_domain, token=token)

response = make_response(redirect(os.environ['FRONT_URL'], code=302))

Expand Down

0 comments on commit 79fc201

Please sign in to comment.