florist.api.routes.server.auth module

FastAPI server routes for authentication.

async check_default_user_token(token, request)[source]

Validate the default user against the token.

Parameters:
  • token (str) – (str) The token to validate the current user.

  • request (Request) – (Request) The request object.

Return type:

AuthUser

Returns:

(AuthUser) The current authenticated user.

Raise:

(HTTPException) If the token is invalid.

get_client_token(client_info, request)[source]

Retrieve a valid client token.

Checks if the client has a valid token in the request.app.clients_auth_tokens dictionary by checking it against the connect client endpoint. If it does, then it returns the token. If it does not, then it will call the authentication endpoint for the client to get a valid token, store it in the request.app.clients_auth_tokens dictionary, and then return the token.

Parameters:
  • client_info (ClientInfo) – (ClientInfo) The client information object.

  • request (Request) – (Request) The FastAPI request object.

Return type:

Token

Returns:

(Token) A valid client token.

async login_for_access_token(form_data, request)[source]

Make a login request to get an access token.

Parameters:
  • form_data (OAuth2PasswordRequestForm) – (OAuth2PasswordRequestForm) The form data from the login request.

  • request (Request) – (Request) The request object.

Return type:

Token

Returns:

(Token) The access token.

Raise:

(HTTPException) If the user does not exist or the password is incorrect.