tiny_pacs_identity.users
Database-backed user registry component.
Keeps the users that incoming associations authenticate as in the
database. Passwords are stored salted and hashed (see
tiny_pacs_identity.hashing), never in plaintext; the
UserIdentityAuth component consumes the
records when enforcing a device’s identity policy.
Create and maintain users with the users CLI subcommands against the
offline database before starting a server that requires identity.
Module Attributes
Maximum length of a login name (size of the database column) |
Classes
|
Component that keeps user accounts in the database. |
|
Configuration of the |
- tiny_pacs_identity.users.MAX_USERNAME_LENGTH = 64
Maximum length of a login name (size of the database column)
- class tiny_pacs_identity.users.UsersConfig(*, on: bool = False)[source]
Bases:
ComponentConfigConfiguration of the
Userscomponent.The component has no settings of its own; this model exists so the component provides its own config type to the loader like every other component.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class tiny_pacs_identity.users.Users(bus: EventBus, config: UsersConfig | dict[str, Any])[source]
Bases:
Component[UsersConfig]Component that keeps user accounts in the database.
Handles the following events:
Component initialization.
- Parameters:
bus (trolleybus.EventBus) – event bus
config (UsersConfig or dict) – component configuration
- config_model
alias of
UsersConfig
- migrations(_: None = None) ComponentMigrations[source]
Returns schema migrations of the component tables
- Returns:
component migrations
- Return type:
- user_add(payload: Mapping[str, Any]) UserModel[source]
Handles UserAdd event
- Parameters:
payload (Mapping) –
usernameandpasswordmapping- Returns:
the created user record
- Return type:
- Raises:
ValueError – raised for missing, invalid or duplicate usernames and for empty passwords
- user_set_password(payload: Mapping[str, Any]) UserModel[source]
Handles UserSetPassword event
- Parameters:
payload (Mapping) –
usernameandpasswordmapping- Returns:
the updated user record
- Return type:
- Raises:
ValueError – raised for a missing or unknown username and for an empty password
- user_remove(username: str) bool[source]
Handles UserRemove event
- Parameters:
username (str) – login name of the user to remove; normalized like in every other handler (stripped, validated)
- Returns:
whether the user existed and was removed
- Return type:
- Raises:
ValueError – raised for a missing, empty or oversized username