{ "module": "jwtlib.repository", "content": { "path": "jwtlib.repository", "docstring": "# Summary\n\nUserRepository: Persistence layer for authentication.\n\nThis module defines the MongoDB-backed repository for managing user records,\nincluding creation, lookup, and credential verification.", "objects": { "BaseRepository": { "name": "BaseRepository", "kind": "alias", "path": "jwtlib.repository.BaseRepository", "signature": "", "docstring": null }, "LoginRequest": { "name": "LoginRequest", "kind": "class", "path": "jwtlib.repository.LoginRequest", "signature": "", "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.repository.LoginRequest.model_config", "signature": "", "docstring": null }, "username": { "name": "username", "kind": "attribute", "path": "jwtlib.repository.LoginRequest.username", "signature": "", "docstring": null }, "password": { "name": "password", "kind": "attribute", "path": "jwtlib.repository.LoginRequest.password", "signature": "", "docstring": null } } }, "PublicUser": { "name": "PublicUser", "kind": "class", "path": "jwtlib.repository.PublicUser", "signature": "", "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.repository.PublicUser.model_config", "signature": "", "docstring": null }, "username": { "name": "username", "kind": "attribute", "path": "jwtlib.repository.PublicUser.username", "signature": "", "docstring": null }, "email": { "name": "email", "kind": "attribute", "path": "jwtlib.repository.PublicUser.email", "signature": "", "docstring": null }, "is_active": { "name": "is_active", "kind": "attribute", "path": "jwtlib.repository.PublicUser.is_active", "signature": "", "docstring": null } } }, "RegisterRequest": { "name": "RegisterRequest", "kind": "class", "path": "jwtlib.repository.RegisterRequest", "signature": "", "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.repository.RegisterRequest.model_config", "signature": "", "docstring": null }, "username": { "name": "username", "kind": "attribute", "path": "jwtlib.repository.RegisterRequest.username", "signature": "", "docstring": null }, "email": { "name": "email", "kind": "attribute", "path": "jwtlib.repository.RegisterRequest.email", "signature": "", "docstring": null }, "password": { "name": "password", "kind": "attribute", "path": "jwtlib.repository.RegisterRequest.password", "signature": "", "docstring": null } } }, "User": { "name": "User", "kind": "class", "path": "jwtlib.repository.User", "signature": "", "docstring": "Internal user persistence model.\n\nAttributes:\n hashed_password (str):\n Secure hash of the user's password.\n\nNotes:\n **Responsibilities:**\n\n - Represents a user record as stored in the database. Includes\n sensitive fields and is strictly confined to the persistence\n layer.\n\n **Guarantees:**\n\n - This model MUST NOT be returned from authentication APIs.\n Consumers should use `PublicUser` instead. Password verification\n is handled by the repository layer.", "members": { "hashed_password": { "name": "hashed_password", "kind": "attribute", "path": "jwtlib.repository.User.hashed_password", "signature": "", "docstring": null } } }, "create_access_token": { "name": "create_access_token", "kind": "function", "path": "jwtlib.repository.create_access_token", "signature": "", "docstring": "Generate a new `JWT` access token.\n\nArgs:\n data (dict):\n Subject data to include in the token payload.\n expires_delta (timedelta, optional):\n Optional expiration override.\n\nReturns:\n str:\n An encoded `JWT` string." }, "hash_password": { "name": "hash_password", "kind": "function", "path": "jwtlib.repository.hash_password", "signature": "", "docstring": "Hash a plain-text password using the configured crypt context.\n\nArgs:\n password (str):\n The plain-text password to hash.\n\nReturns:\n str:\n The secure hash string." }, "verify_password": { "name": "verify_password", "kind": "function", "path": "jwtlib.repository.verify_password", "signature": "", "docstring": "Verify a plain-text password against a stored hash.\n\nArgs:\n plain_password (str):\n The unhashed password provided by the user.\n hashed_password (str):\n The secure hash to verify against.\n\nReturns:\n bool:\n True if the password is valid, False otherwise." }, "UserRepository": { "name": "UserRepository", "kind": "class", "path": "jwtlib.repository.UserRepository", "signature": "", "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.repository.UserRepository.create", "signature": "", "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.repository.UserRepository.get_by_username", "signature": "", "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.repository.UserRepository.get_by_email", "signature": "", "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.repository.UserRepository.get_active_users", "signature": "", "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.repository.UserRepository.authenticate_user", "signature": "", "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." } } } } } }