Files
docs/py-jwt/mcp/modules/jwtlib.app.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

338 lines
21 KiB
JSON

{
"module": "jwtlib.app",
"content": {
"path": "jwtlib.app",
"docstring": "# Summary\n\nApplication-level authentication logic.\n\nThis module contains **pure authentication and introspection logic** with no\nframework or transport coupling. It is intended to be used by HTTP adapters,\nCLIs, background workers, and other services that require `JWT`-based\nauthentication and user resolution.\n\nNotes:\n **Responsibilities:**\n\n - User registration and login.\n - Stateless logout semantics.\n - Current-user resolution from `JWT`s.\n - Service-to-service token introspection.\n\n **Constraints:**\n\n - This module intentionally does NOT:\n - Define HTTP routes.\n - Manage sessions.\n - Perform request parsing or response formatting.\n - Handle transport-level concerns.",
"objects": {
"AuthError": {
"name": "AuthError",
"kind": "class",
"path": "jwtlib.app.AuthError",
"signature": "<bound method Alias.signature of Alias('AuthError', 'jwtlib.exceptions.AuthError')>",
"docstring": "Base authentication and authorization error.\n\nNotes:\n **Guarantees:**\n\n - All authentication-related exceptions raised by this library\n inherit from this class.\n - Consumers may catch this exception to handle all auth failures\n uniformly."
},
"InvalidToken": {
"name": "InvalidToken",
"kind": "class",
"path": "jwtlib.app.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."
},
"IntrospectResponse": {
"name": "IntrospectResponse",
"kind": "class",
"path": "jwtlib.app.IntrospectResponse",
"signature": "<bound method Alias.signature of Alias('IntrospectResponse', 'jwtlib.models.IntrospectResponse')>",
"docstring": "Result of a token introspection operation.\n\nAttributes:\n active (bool):\n Indicates whether the token is valid and active.\n user (Optional[PublicUser]):\n Public user details if the token is valid; otherwise null.",
"members": {
"active": {
"name": "active",
"kind": "attribute",
"path": "jwtlib.app.IntrospectResponse.active",
"signature": "<bound method Alias.signature of Alias('active', 'jwtlib.models.app.IntrospectResponse.active')>",
"docstring": null
},
"user": {
"name": "user",
"kind": "attribute",
"path": "jwtlib.app.IntrospectResponse.user",
"signature": "<bound method Alias.signature of Alias('user', 'jwtlib.models.app.IntrospectResponse.user')>",
"docstring": null
},
"model_config": {
"name": "model_config",
"kind": "attribute",
"path": "jwtlib.app.IntrospectResponse.model_config",
"signature": "<bound method Alias.signature of Alias('model_config', 'jwtlib.models.app.IntrospectResponse.model_config')>",
"docstring": null
},
"jwt_error": {
"name": "jwt_error",
"kind": "function",
"path": "jwtlib.app.IntrospectResponse.jwt_error",
"signature": "<bound method Alias.signature of Alias('jwt_error', 'jwtlib.models.app.IntrospectResponse.jwt_error')>",
"docstring": null
},
"no_username": {
"name": "no_username",
"kind": "function",
"path": "jwtlib.app.IntrospectResponse.no_username",
"signature": "<bound method Alias.signature of Alias('no_username', 'jwtlib.models.app.IntrospectResponse.no_username')>",
"docstring": null
},
"no_user": {
"name": "no_user",
"kind": "function",
"path": "jwtlib.app.IntrospectResponse.no_user",
"signature": "<bound method Alias.signature of Alias('no_user', 'jwtlib.models.app.IntrospectResponse.no_user')>",
"docstring": null
},
"valid_user": {
"name": "valid_user",
"kind": "function",
"path": "jwtlib.app.IntrospectResponse.valid_user",
"signature": "<bound method Alias.signature of Alias('valid_user', 'jwtlib.models.app.IntrospectResponse.valid_user')>",
"docstring": null
}
}
},
"LoginRequest": {
"name": "LoginRequest",
"kind": "class",
"path": "jwtlib.app.LoginRequest",
"signature": "<bound method Alias.signature of Alias('LoginRequest', 'jwtlib.models.LoginRequest')>",
"docstring": "Payload for authenticating a user and issuing a `JWT`.\n\nAttributes:\n username (str):\n Username identifier.\n password (str):\n Plain-text password to be verified.",
"members": {
"model_config": {
"name": "model_config",
"kind": "attribute",
"path": "jwtlib.app.LoginRequest.model_config",
"signature": "<bound method Alias.signature of Alias('model_config', 'jwtlib.models.app.LoginRequest.model_config')>",
"docstring": null
},
"username": {
"name": "username",
"kind": "attribute",
"path": "jwtlib.app.LoginRequest.username",
"signature": "<bound method Alias.signature of Alias('username', 'jwtlib.models.app.LoginRequest.username')>",
"docstring": null
},
"password": {
"name": "password",
"kind": "attribute",
"path": "jwtlib.app.LoginRequest.password",
"signature": "<bound method Alias.signature of Alias('password', 'jwtlib.models.app.LoginRequest.password')>",
"docstring": null
}
}
},
"LoginResponse": {
"name": "LoginResponse",
"kind": "class",
"path": "jwtlib.app.LoginResponse",
"signature": "<bound method Alias.signature of Alias('LoginResponse', 'jwtlib.models.LoginResponse')>",
"docstring": "Response returned after successful authentication.\n\nAttributes:\n access_token (str):\n `JWT` access token for authenticated requests.\n user (PublicUser):\n Public profile of the authenticated user.",
"members": {
"access_token": {
"name": "access_token",
"kind": "attribute",
"path": "jwtlib.app.LoginResponse.access_token",
"signature": "<bound method Alias.signature of Alias('access_token', 'jwtlib.models.app.LoginResponse.access_token')>",
"docstring": null
},
"user": {
"name": "user",
"kind": "attribute",
"path": "jwtlib.app.LoginResponse.user",
"signature": "<bound method Alias.signature of Alias('user', 'jwtlib.models.app.LoginResponse.user')>",
"docstring": null
},
"model_config": {
"name": "model_config",
"kind": "attribute",
"path": "jwtlib.app.LoginResponse.model_config",
"signature": "<bound method Alias.signature of Alias('model_config', 'jwtlib.models.app.LoginResponse.model_config')>",
"docstring": null
}
}
},
"LogoutResponse": {
"name": "LogoutResponse",
"kind": "class",
"path": "jwtlib.app.LogoutResponse",
"signature": "<bound method Alias.signature of Alias('LogoutResponse', 'jwtlib.models.LogoutResponse')>",
"docstring": "Response returned after a logout operation.\n\nAttributes:\n message (str):\n Human-readable logout confirmation.",
"members": {
"message": {
"name": "message",
"kind": "attribute",
"path": "jwtlib.app.LogoutResponse.message",
"signature": "<bound method Alias.signature of Alias('message', 'jwtlib.models.app.LogoutResponse.message')>",
"docstring": null
},
"model_config": {
"name": "model_config",
"kind": "attribute",
"path": "jwtlib.app.LogoutResponse.model_config",
"signature": "<bound method Alias.signature of Alias('model_config', 'jwtlib.models.app.LogoutResponse.model_config')>",
"docstring": null
}
}
},
"PublicUser": {
"name": "PublicUser",
"kind": "class",
"path": "jwtlib.app.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.app.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.app.PublicUser.username",
"signature": "<bound method Alias.signature of Alias('username', 'jwtlib.models.app.PublicUser.username')>",
"docstring": null
},
"email": {
"name": "email",
"kind": "attribute",
"path": "jwtlib.app.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.app.PublicUser.is_active",
"signature": "<bound method Alias.signature of Alias('is_active', 'jwtlib.models.app.PublicUser.is_active')>",
"docstring": null
}
}
},
"RegisterRequest": {
"name": "RegisterRequest",
"kind": "class",
"path": "jwtlib.app.RegisterRequest",
"signature": "<bound method Alias.signature of Alias('RegisterRequest', 'jwtlib.models.RegisterRequest')>",
"docstring": "Payload for registering a new user account.\n\nAttributes:\n username (str):\n Unique username identifier.\n email (EmailStr, optional):\n User's email address.\n password (str):\n Plain-text password (to be hashed by the repository layer).",
"members": {
"model_config": {
"name": "model_config",
"kind": "attribute",
"path": "jwtlib.app.RegisterRequest.model_config",
"signature": "<bound method Alias.signature of Alias('model_config', 'jwtlib.models.app.RegisterRequest.model_config')>",
"docstring": null
},
"username": {
"name": "username",
"kind": "attribute",
"path": "jwtlib.app.RegisterRequest.username",
"signature": "<bound method Alias.signature of Alias('username', 'jwtlib.models.app.RegisterRequest.username')>",
"docstring": null
},
"email": {
"name": "email",
"kind": "attribute",
"path": "jwtlib.app.RegisterRequest.email",
"signature": "<bound method Alias.signature of Alias('email', 'jwtlib.models.app.RegisterRequest.email')>",
"docstring": null
},
"password": {
"name": "password",
"kind": "attribute",
"path": "jwtlib.app.RegisterRequest.password",
"signature": "<bound method Alias.signature of Alias('password', 'jwtlib.models.app.RegisterRequest.password')>",
"docstring": null
}
}
},
"UserRepository": {
"name": "UserRepository",
"kind": "class",
"path": "jwtlib.app.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.app.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.app.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.app.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.app.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.app.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_current_user": {
"name": "get_current_user",
"kind": "function",
"path": "jwtlib.app.get_current_user",
"signature": "<bound method Alias.signature of Alias('get_current_user', 'jwtlib.utils.get_current_user')>",
"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_user_repository": {
"name": "get_user_repository",
"kind": "function",
"path": "jwtlib.app.get_user_repository",
"signature": "<bound method Alias.signature of Alias('get_user_repository', 'jwtlib.utils.get_user_repository')>",
"docstring": "Return a singleton or new instance of the `UserRepository`.\n\nReturns:\n UserRepository:\n The user repository instance."
},
"get_validated_token_payload": {
"name": "get_validated_token_payload",
"kind": "function",
"path": "jwtlib.app.get_validated_token_payload",
"signature": "<bound method Alias.signature of Alias('get_validated_token_payload', 'jwtlib.utils.get_validated_token_payload')>",
"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."
},
"register_user": {
"name": "register_user",
"kind": "function",
"path": "jwtlib.app.register_user",
"signature": "<bound method Function.signature of Function('register_user', 52, 72)>",
"docstring": "Register a new user.\n\nArgs:\n user (RegisterRequest):\n Registration payload containing username, email, and password.\n repo (UserRepository, optional):\n Optional user repository instance. If not provided, a default\n repository is obtained via dependency utilities.\n\nReturns:\n PublicUser:\n The newly created user as a public user representation."
},
"login_user": {
"name": "login_user",
"kind": "function",
"path": "jwtlib.app.login_user",
"signature": "<bound method Function.signature of Function('login_user', 75, 105)>",
"docstring": "Authenticate a user and issue an access token.\n\nArgs:\n user (LoginRequest):\n Login payload containing username and password.\n repo (UserRepository, optional):\n Optional user repository instance. If not provided, a default\n repository is obtained via dependency utilities.\n\nReturns:\n LoginResponse:\n `LoginResponse` containing the issued access token and related\n metadata.\n\nRaises:\n AuthError:\n If the credentials are invalid."
},
"get_logged_in_user": {
"name": "get_logged_in_user",
"kind": "function",
"path": "jwtlib.app.get_logged_in_user",
"signature": "<bound method Function.signature of Function('get_logged_in_user', 108, 134)>",
"docstring": "Resolve the currently authenticated user from a `JWT`.\n\nArgs:\n token (str):\n `JWT` access token.\n repo (UserRepository, optional):\n Optional user repository instance. If not provided, a default\n repository is obtained via dependency utilities.\n\nReturns:\n PublicUser:\n The authenticated user as a `PublicUser`.\n\nRaises:\n InvalidToken:\n If the token is missing, malformed, or invalid.\n AuthError:\n If the token is valid, but the user cannot be resolved."
},
"logout_user": {
"name": "logout_user",
"kind": "function",
"path": "jwtlib.app.logout_user",
"signature": "<bound method Function.signature of Function('logout_user', 137, 155)>",
"docstring": "Perform a stateless logout.\n\nReturns:\n LogoutResponse:\n `LogoutResponse` containing a logout confirmation message.\n\nNotes:\n **Guarantees:**\n\n - This function does not invalidate tokens server-side. Instead, it\n provides a standardized response indicating that the client must\n discard its token."
},
"introspect_token": {
"name": "introspect_token",
"kind": "function",
"path": "jwtlib.app.introspect_token",
"signature": "<bound method Function.signature of Function('introspect_token', 163, 207)>",
"docstring": "Introspect a `JWT` for service-to-service authentication.\n\nArgs:\n token (str):\n `JWT` access token to introspect.\n repo (UserRepository, optional):\n Optional user repository instance. If not provided, a default\n repository is obtained via dependency utilities.\n\nReturns:\n IntrospectResponse:\n `IntrospectResponse` indicating valid token with user, invalid\n token, or valid token with no user.\n\nNotes:\n **Responsibilities:**\n\n - Validate the provided token and resolve the associated user,\n returning a structured introspection response suitable for\n internal service use.\n\n **Guarantees:**\n\n - This function never raises authentication exceptions. Instead, it\n returns a typed response indicating token validity and user\n presence."
}
}
}
}