File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 11from datetime import datetime , timezone
22import hashlib
3+ import traceback
34from typing import Tuple
45import 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 )
You can’t perform that action at this time.
0 commit comments