Files
docs/py-jwt/mcp/modules/jwtlib.utils.json
Vishesh 'ironeagle' Bangotra a32eeaf2b4 feat: serve docs flat at /<repo>/ with no redirects
- collect.py copies each repo's built site contents directly to a
  top-level <repo>/ dir (was libs|apis|wiki/<repo>/site nesting)
- nginx uses `index index.html lib/index.html api/index.html` so
  /dagpipe/ -> lib/index.html, /auth-server/ -> api/index.html are
  served internally with no redirects
- _index regenerates links against the flat layout
  (/dagpipe/lib/, /auth-server/api/, /mongo-ops/, /blog/...)
- config.yml static entries point at vendored blog/ + media-manager/
- Dockerfile copies per-repo dirs flat into the nginx html root
- removed stale libs/, apis/, wiki/, tutorials/ category trees
2026-09-11 21:32:30 +05:30

162 lines
10 KiB
JSON

{
"module": "jwtlib.utils",
"content": {
"path": "jwtlib.utils",
"docstring": "# Summary\n\nAuth Utilities: Token validation and user resolution.\n\nThis module provides high-level helpers for validating `JWT` payloads and\nresolving users, intended for use in dependency injection or middleware.",
"objects": {
"JWTError": {
"name": "JWTError",
"kind": "alias",
"path": "jwtlib.utils.JWTError",
"signature": "<bound method Alias.signature of Alias('JWTError', 'jose.JWTError')>",
"docstring": null
},
"InvalidToken": {
"name": "InvalidToken",
"kind": "class",
"path": "jwtlib.utils.InvalidToken",
"signature": "<bound method Alias.signature of Alias('InvalidToken', 'jwtlib.exceptions.InvalidToken')>",
"docstring": "Raised when a `JWT` is missing, malformed, expired, or invalid.\n\nNotes:\n **Guarantees:**\n\n - This error indicates that the provided token cannot be used to\n authenticate a request."
},
"UserNotFound": {
"name": "UserNotFound",
"kind": "class",
"path": "jwtlib.utils.UserNotFound",
"signature": "<bound method Alias.signature of Alias('UserNotFound', 'jwtlib.exceptions.UserNotFound')>",
"docstring": "Raised when a valid token does not map to an existing user.\n\nNotes:\n **Guarantees:**\n\n - Indicates that authentication succeeded at the token level, but\n the associated user record could not be resolved."
},
"PublicUser": {
"name": "PublicUser",
"kind": "class",
"path": "jwtlib.utils.PublicUser",
"signature": "<bound method Alias.signature of Alias('PublicUser', 'jwtlib.models.PublicUser')>",
"docstring": "Public-facing user representation returned by authentication APIs.\n\nAttributes:\n username (str):\n Unique username identifier.\n email (EmailStr, optional):\n User's email address.\n is_active (bool):\n Whether the user account is active.",
"members": {
"model_config": {
"name": "model_config",
"kind": "attribute",
"path": "jwtlib.utils.PublicUser.model_config",
"signature": "<bound method Alias.signature of Alias('model_config', 'jwtlib.models.app.PublicUser.model_config')>",
"docstring": null
},
"username": {
"name": "username",
"kind": "attribute",
"path": "jwtlib.utils.PublicUser.username",
"signature": "<bound method Alias.signature of Alias('username', 'jwtlib.models.app.PublicUser.username')>",
"docstring": null
},
"email": {
"name": "email",
"kind": "attribute",
"path": "jwtlib.utils.PublicUser.email",
"signature": "<bound method Alias.signature of Alias('email', 'jwtlib.models.app.PublicUser.email')>",
"docstring": null
},
"is_active": {
"name": "is_active",
"kind": "attribute",
"path": "jwtlib.utils.PublicUser.is_active",
"signature": "<bound method Alias.signature of Alias('is_active', 'jwtlib.models.app.PublicUser.is_active')>",
"docstring": null
}
}
},
"TokenPayload": {
"name": "TokenPayload",
"kind": "class",
"path": "jwtlib.utils.TokenPayload",
"signature": "<bound method Alias.signature of Alias('TokenPayload', 'jwtlib.models.TokenPayload')>",
"docstring": "Decoded `JWT` payload.\n\nAttributes:\n sub (str):\n Subject claim identifying the user (typically a username or user ID).\n exp (int):\n Expiration time as a Unix timestamp (seconds since epoch).\n\nNotes:\n **Responsibilities:**\n\n - Represents the validated claims extracted from a `JWT` after\n signature verification. This model is used internally to enforce\n required claims and provide a typed interface to token data.\n\n **Guarantees:**\n\n - This model assumes the `JWT` signature has already been verified.\n No authorization decisions should be made solely on this model.\n Additional claims may exist but are intentionally ignored.",
"members": {
"sub": {
"name": "sub",
"kind": "attribute",
"path": "jwtlib.utils.TokenPayload.sub",
"signature": "<bound method Alias.signature of Alias('sub', 'jwtlib.models.security.TokenPayload.sub')>",
"docstring": null
},
"exp": {
"name": "exp",
"kind": "attribute",
"path": "jwtlib.utils.TokenPayload.exp",
"signature": "<bound method Alias.signature of Alias('exp', 'jwtlib.models.security.TokenPayload.exp')>",
"docstring": null
}
}
},
"UserRepository": {
"name": "UserRepository",
"kind": "class",
"path": "jwtlib.utils.UserRepository",
"signature": "<bound method Alias.signature of Alias('UserRepository', 'jwtlib.repository.UserRepository')>",
"docstring": "MongoDB-backed repository for `User` documents.\n\nNotes:\n **Responsibilities:**\n\n - Manage user persistence (CRUD).\n - Handle credential verification and token issuance.",
"members": {
"create": {
"name": "create",
"kind": "function",
"path": "jwtlib.utils.UserRepository.create",
"signature": "<bound method Alias.signature of Alias('create', 'jwtlib.repository.UserRepository.create')>",
"docstring": "Create a new user record.\n\nArgs:\n user_create (RegisterRequest):\n Registration data including prospective password.\n\nReturns:\n PublicUser:\n A PublicUser representation of the created user."
},
"get_by_username": {
"name": "get_by_username",
"kind": "function",
"path": "jwtlib.utils.UserRepository.get_by_username",
"signature": "<bound method Alias.signature of Alias('get_by_username', 'jwtlib.repository.UserRepository.get_by_username')>",
"docstring": "Retrieve a user by their unique username.\n\nArgs:\n username (str):\n The username to search for.\n\nReturns:\n Optional[User]:\n The User document if found, otherwise None."
},
"get_by_email": {
"name": "get_by_email",
"kind": "function",
"path": "jwtlib.utils.UserRepository.get_by_email",
"signature": "<bound method Alias.signature of Alias('get_by_email', 'jwtlib.repository.UserRepository.get_by_email')>",
"docstring": "Retrieve a user by their unique email address.\n\nArgs:\n email (str):\n The email address to search for.\n\nReturns:\n Optional[User]:\n The User document if found, otherwise None."
},
"get_active_users": {
"name": "get_active_users",
"kind": "function",
"path": "jwtlib.utils.UserRepository.get_active_users",
"signature": "<bound method Alias.signature of Alias('get_active_users', 'jwtlib.repository.UserRepository.get_active_users')>",
"docstring": "List all active users with pagination.\n\nArgs:\n skip (int):\n Number of records to skip.\n limit (int):\n Maximum number of records to return.\n\nReturns:\n List[User]:\n A list of active User documents."
},
"authenticate_user": {
"name": "authenticate_user",
"kind": "function",
"path": "jwtlib.utils.UserRepository.authenticate_user",
"signature": "<bound method Alias.signature of Alias('authenticate_user', 'jwtlib.repository.UserRepository.authenticate_user')>",
"docstring": "Verify user credentials and prepare a login response.\n\nArgs:\n user_auth (LoginRequest):\n Login credentials.\n\nReturns:\n dict | None:\n A dictionary containing the access token and public user if successful, otherwise None."
}
}
},
"get_jwt_payload": {
"name": "get_jwt_payload",
"kind": "function",
"path": "jwtlib.utils.get_jwt_payload",
"signature": "<bound method Alias.signature of Alias('get_jwt_payload', 'jwtlib.security.get_jwt_payload')>",
"docstring": "Decode and validate a `JWT`, returning a strongly-typed payload.\n\nArgs:\n token (str):\n The `JWT` string to decode.\n\nReturns:\n TokenPayload:\n The decoded and typed token payload.\n\nRaises:\n JWTError:\n If the token is invalid, expired, or malformed."
},
"get_user_repository": {
"name": "get_user_repository",
"kind": "function",
"path": "jwtlib.utils.get_user_repository",
"signature": "<bound method Function.signature of Function('get_user_repository', 24, 32)>",
"docstring": "Return a singleton or new instance of the `UserRepository`.\n\nReturns:\n UserRepository:\n The user repository instance."
},
"get_current_user": {
"name": "get_current_user",
"kind": "function",
"path": "jwtlib.utils.get_current_user",
"signature": "<bound method Function.signature of Function('get_current_user', 38, 73)>",
"docstring": "Validate token and return authenticated public user.\n\nArgs:\n token (str):\n The `JWT` string to validate.\n repo (UserRepository, optional):\n The user repository to use for resolution.\n\nReturns:\n PublicUser:\n The resolved and validated user object.\n\nRaises:\n InvalidToken:\n If the token is missing, malformed, or invalid.\n UserNotFound:\n If the token is valid, but the user does not exist in the\n repository."
},
"get_validated_token_payload": {
"name": "get_validated_token_payload",
"kind": "function",
"path": "jwtlib.utils.get_validated_token_payload",
"signature": "<bound method Function.signature of Function('get_validated_token_payload', 79, 100)>",
"docstring": "Validate a `JWT` and return a typed payload.\n\nArgs:\n token (str):\n The `JWT` string to validate.\n\nReturns:\n TokenPayload:\n The validated and typed token payload.\n\nRaises:\n JWTError:\n If the token is invalid or malformed."
}
}
}
}