Skip to content

App

jwtlib.models.app

Authentication request and response models.


Summary

This module defines all typed data models used by the authentication library for user registration, login, logout, and token introspection.

Notes

Model Categories:

1
2
3
- Request payloads used by authentication workflows
- Public response models exposed to consumers
- Introspection responses used for service-to-service authentication

Design Principles:

1
2
3
4
- Fully typed (Pydantic v2)
- Serialization-safe
- Framework-agnostic
- Suitable for both internal logic and external adapters

Classes

IntrospectRequest

Bases: BaseModel

Payload for requesting token introspection.

Attributes:

Name Type Description
token str

JWT access token to introspect.

IntrospectResponse

Bases: BaseModel

Result of a token introspection operation.

Attributes:

Name Type Description
active bool

Indicates whether the token is valid and active.

user Optional[PublicUser]

Public user details if the token is valid; otherwise null.

LoginRequest

Bases: IdentityMixin, PasswordMixin

Payload for authenticating a user and issuing a JWT.

Attributes:

Name Type Description
username str

Username identifier.

password str

Plain-text password to be verified.

LoginResponse

Bases: BaseModel

Response returned after successful authentication.

Attributes:

Name Type Description
access_token str

JWT access token for authenticated requests.

user PublicUser

Public profile of the authenticated user.

LogoutResponse

Bases: BaseModel

Response returned after a logout operation.

Attributes:

Name Type Description
message str

Human-readable logout confirmation.

PublicUser

Bases: IdentityMixin, ActiveStateMixin

Public-facing user representation returned by authentication APIs.

Attributes:

Name Type Description
username str

Unique username identifier.

email EmailStr

User's email address.

is_active bool

Whether the user account is active.

RegisterRequest

Bases: IdentityMixin, PasswordMixin

Payload for registering a new user account.

Attributes:

Name Type Description
username str

Unique username identifier.

email EmailStr

User's email address.

password str

Plain-text password (to be hashed by the repository layer).