flask_more_smorest.perms.models.token
Token model for API authentication.
Classes
|
API tokens for user authentication. |
- class flask_more_smorest.perms.models.token.Token(**kwargs)[source]
API tokens for user authentication.
This is a concrete implementation of AbstractToken. For customization, subclass AbstractToken instead of this class.
Permission checks are delegated to the owning user (inherited from AbstractToken).
Example
from sqlalchemy.orm import Mapped, mapped_column
- class CustomToken(AbstractToken):
__tablename__ = “token” custom_field: Mapped[str] = mapped_column(sa.String(100))
- __init__(**kwargs)
Initialize model after checking sub-fields can be created.
- created_at
- id
- updated_at
- user
Relationship to the registered User model.
Uses lazy resolution via lambda to support custom User models registered through init_fms(). The lambda is evaluated during mapper configuration, allowing get_user_model() to return the correct registered User class.
- user_id