Skip to content

Utils

jwtlib.utils

Auth Utilities: Token validation and user resolution

This module provides high-level helpers for validating JWT payloads and resolving users, intended for use in dependency injection or middleware.

get_current_user async

get_current_user(token: str, repo: Optional[UserRepository] = None) -> PublicUser

Validate token and return authenticated public user.

Raises:

Type Description
InvalidToken

If the token is missing, malformed, or invalid.

UserNotFound

If the token is valid, but the user does not exist in the repository.

get_validated_token_payload

get_validated_token_payload(token: str) -> TokenPayload

Validate a JWT and return a typed payload.

Raises:

Type Description
JWTError

if the token is invalid or malformed