File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -98,24 +98,18 @@ def read_root() -> Any:
9898async def access_token_from_api_key (
9999 sql_session : Annotated [Session , Depends (get_session )],
100100 form_data : Annotated [OAuth2PasswordRequestForm , Depends ()],
101- api_key_enduser_tuple : str = Security (get_api_key ),
102101) -> Token :
103102 """Generate a token from an API key."""
104- local_session .set (sql_session )
105103
106- user = authenticate_api_key (api_key_enduser_tuple , local_session .get ())
107104 valid = check_creds (form_data .username , form_data .password )
108- print (f"api_key input: { api_key_enduser_tuple } " )
109- print (f"user: { user } " )
110- print (f"valid creds: { valid } " )
111105
112- if not user and not valid :
106+ if not valid :
113107 raise HTTPException (
114108 status_code = status .HTTP_401_UNAUTHORIZED ,
115109 detail = "Invalid API key and credentials" ,
116110 headers = {"WWW-Authenticate" : "X-API-KEY" },
117111 )
118- email = user . email if user else form_data .username
112+ email = form_data .username
119113 access_token_expires = timedelta (
120114 minutes = int (env_vars ["ACCESS_TOKEN_EXPIRE_MINUTES" ])
121115 )
You can’t perform that action at this time.
0 commit comments