Skip to content

Commit 0f2c84b

Browse files
fix
1 parent 8dbf3af commit 0f2c84b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

gen3workflow/routes/s3.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from datetime import datetime, timezone
22
import hashlib
3+
import traceback
34
from typing import Tuple
45
import urllib.parse
56

@@ -42,6 +43,7 @@ def get_access_token(headers: Headers) -> Tuple[str, str]:
4243
(str, str): the user's access token or "" if not found, and the user's ID if the token is
4344
a client_credentials token
4445
"""
46+
# TODO unit tests for this function
4547
auth_header = headers.get("authorization")
4648
if not auth_header:
4749
return "", ""
@@ -51,13 +53,15 @@ def get_access_token(headers: Headers) -> Tuple[str, str]:
5153
raise HTTPException(HTTP_401_UNAUTHORIZED, err_msg)
5254
try:
5355
if "Credential=" in auth_header: # format 1 (see docstring)
54-
access_key_id = auth_header.split("Credential=")[1].split("/")[0]
56+
access_token = auth_header.split("Credential=")[1].split("/")[0]
57+
user_id = None
5558
else: # format 2 (see docstring)
5659
access_key_id = auth_header.split("AWS ")[1]
5760
access_key_id = ":".join(access_key_id.split(":")[:-1])
58-
access_token, user_id = access_key_id.split(";userId=")
61+
access_token, user_id = access_key_id.split(";userId=")
5962
return access_token, user_id
6063
except Exception as e:
64+
traceback.print_exc()
6165
logger.error(
6266
f"Unexpected format; unable to extract access token from authorization header: {e}"
6367
)

0 commit comments

Comments
 (0)