deps#

Dependencies for the endpoints.

The goal is to create all dependencies using a Config class so that the app can be configured differently for testing and production.




Functions#

filter_valid_token

Return the token if it is valid, otherwise return None.

get_authorized_user_email_or_anon

raises AuthServiceError

if the token is not wellformed

get_current_user

Retrieve the data of the current user from the database.

filter_valid_token()#

async rootski.main.deps.filter_valid_token(request: starlette.requests.Request, credentials: fastapi.security.http.HTTPAuthorizationCredentials = Security(HTTPBearer)) Optional[str][source]#

Return the token if it is valid, otherwise return None. None is taken to be the anon user.

get_authorized_user_email_or_anon()#

async rootski.main.deps.get_authorized_user_email_or_anon(request: starlette.requests.Request, token: str = Depends(filter_valid_token)) str[source]#
Raises

AuthServiceError – if the token is not wellformed

get_current_user()#

async rootski.main.deps.get_current_user(request: starlette.requests.Request, email: str = Depends(get_authorized_user_email_or_anon)) rootski.schemas.user.User[source]#

Retrieve the data of the current user from the database.