harp_apps.dashboard.settings.auth

Inheritance diagram of harp_apps.dashboard.settings.auth

class BasicAuthSettings[source]

Bases: Configurable

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.

classmethod model_always_shown_defaults(data)[source]

This validator overcomes the behaviour of model_dump(exclude_defaults=True, exclude_unset=True) and forces some defaults to be dumped everytime.

async acheck(username, password)[source]

Same as check(), without blocking the event loop. Successful checks are remembered for a while.

check(username, password)[source]

Blocking check (hashing is slow by design), prefer acheck() from the event loop.

algorithm: Annotated[Literal['pbkdf2_sha256', 'argon2', 'plaintext'], BeforeValidator(func=_check_algorithm, json_schema_input_type=PydanticUndefined), FieldInfo(annotation=NoneType, required=False, default='pbkdf2_sha256', description='Hashing algorithm used for passwords. «plaintext» is for tests only.')]
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'hide_input_in_errors': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

type: Literal['basic']
users: Annotated[dict[str, User], BeforeValidator(func=_load, json_schema_input_type=PydanticUndefined), FieldInfo(annotation=NoneType, required=False, default_factory=dict, description='Users list.')]
class NoAuthSettings[source]

Bases: Configurable

Explicit opt-out: the dashboard is served without any authentication.

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.

classmethod model_always_shown_defaults(data)[source]

Same as for basic authentication: the type must survive dumps that exclude defaults.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'hide_input_in_errors': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

type: Literal['none']
class User[source]

Bases: Configurable

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', 'hide_input_in_errors': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

password: Annotated[SecretStr, PlainSerializer(func=_serialize_secret, return_type=str, when_used=always)]