app.auth_utils

User authentication dependencies and utilities.

Functions

get_current_user([user_token, service_token])

Dependency that extracts and validates the current user from the token.

require_authenticated_user([current_user])

Dependency that requires an authenticated user.

Classes

CurrentUser(email, user_id, is_authenticated)

Represents the currently authenticated user.

class app.auth_utils.CurrentUser(email, user_id, is_authenticated, is_anonymous=False, is_service_token=False, display_name=None, name=None)[source]

Bases: object

Represents the currently authenticated user.

Parameters:
  • email (str)

  • user_id (str)

  • is_authenticated (bool)

  • is_anonymous (bool)

  • is_service_token (bool)

  • display_name (str | None)

  • name (str | None)

app.auth_utils.get_current_user(user_token=Depends(dependency=<function get_user_token>, use_cache=True, scope=None), service_token=Header(None))[source]

Dependency that extracts and validates the current user from the token.

Checks both Authorization header (user token) and X-Kumiho-Token (service token). User tokens take precedence if both are present.

Parameters:
  • user_token (Optional[str]) – The user’s Firebase token from Authorization header

  • service_token (Optional[str]) – The service token from X-Kumiho-Token header

Return type:

CurrentUser

Returns:

CurrentUser object

app.auth_utils.require_authenticated_user(current_user=Depends(dependency=<function get_current_user>, use_cache=True, scope=None))[source]

Dependency that requires an authenticated user.

Raises 401 if the user is not authenticated. Use this for endpoints that require login.

Parameters:

current_user (CurrentUser) – The current user from get_current_user dependency

Return type:

CurrentUser

Returns:

CurrentUser object (guaranteed to be authenticated)

Raises:

HTTPException – 401 if user is not authenticated