22
33import uuid
44import re
5- from typing import Annotated , Final
5+ from typing import Annotated , Final , Any
66from urllib .parse import unquote
77from strenum import StrEnum # needed for python pre 3.11
88import jwt
2222from .config import env_vars
2323
2424
25- def decode_url_piece (src : str ):
25+ def decode_url_piece (src : str ) -> str :
2626 """Decode encoded URL."""
2727 return unquote (src )
2828
@@ -165,29 +165,29 @@ class BaseUser(BaseModel):
165165 def __init__ (self , usr : str | None , inst : str , access : str , email : str ) -> None :
166166 super ().__init__ (user_id = usr , institution = inst , access_type = access , email = email )
167167
168- def is_datakinder (self ) -> bool :
168+ def is_datakinder (self ) -> Any :
169169 """Whether a given user is a Datakinder."""
170170 return self .access_type and self .access_type == AccessType .DATAKINDER
171171
172- def is_model_owner (self ) -> bool :
172+ def is_model_owner (self ) -> Any :
173173 """Whether a given user is a model owner."""
174174 return self .access_type and self .access_type == AccessType .MODEL_OWNER
175175
176- def is_data_owner (self ) -> bool :
176+ def is_data_owner (self ) -> Any :
177177 """Whether a given user is a data owner."""
178178 return self .access_type and self .access_type == AccessType .DATA_OWNER
179179
180- def is_viewer (self ) -> bool :
180+ def is_viewer (self ) -> Any :
181181 """Whether a given user is a viewer."""
182182 return self .access_type and self .access_type == AccessType .VIEWER
183183
184- def has_access_to_inst (self , inst : str ) -> bool :
184+ def has_access_to_inst (self , inst : str ) -> Any :
185185 """Whether a given user has access to a given institution."""
186186 return self .access_type and (
187187 self .access_type == AccessType .DATAKINDER or self .institution == inst
188188 )
189189
190- def has_full_data_access (self ) -> bool :
190+ def has_full_data_access (self ) -> Any :
191191 """Datakinders, model_owners, data_owners, all have full data access."""
192192 return self .access_type and self .access_type in (
193193 AccessType .DATAKINDER ,
@@ -313,7 +313,9 @@ def authenticate_api_key(api_key_enduser_tuple: str, sess: Session) -> BaseUser:
313313
314314async def get_current_user (
315315 sess : Annotated [Session , Depends (get_session )],
316- token_from_key : Annotated [HTTPAuthorizationCredentials , Depends (oauth2_apikey_scheme )],
316+ token_from_key : Annotated [
317+ HTTPAuthorizationCredentials , Depends (oauth2_apikey_scheme )
318+ ],
317319) -> BaseUser :
318320 """Get the user from a given token."""
319321 credentials_exception = HTTPException (
@@ -322,7 +324,6 @@ async def get_current_user(
322324 headers = {"WWW-Authenticate" : "Bearer" },
323325 )
324326 usrname = None
325- print (token_from_key )
326327 token_from_key = token_from_key .credentials
327328 try :
328329 if not token_from_key :
0 commit comments