nat.data_models.user_info#
Structured user identity model supporting multiple credential sources.
Attributes#
Classes#
JWT-derived identity fields extracted from decoded token claims. |
|
Username/password identity. |
|
Resolved user identity, independent of how it was identified. |
Module Contents#
- class JwtUserInfo(/, **data: Any)#
Bases:
pydantic.BaseModelJWT-derived identity fields extracted from decoded token claims.
Registered claims (
sub,iss,aud,exp,iat) per RFC 7519. Identity claims (email,preferred_username,name) per OpenID Connect Core 1.0.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.selfis explicitly positional-only to allowselfas a field name.- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class BasicUserInfo(/, **data: Any)#
Bases:
pydantic.BaseModelUsername/password identity.
The user provides
usernameandpassword. A base64-encodedcredential(base64(username:password)) is derived automatically and used as the identity key for UUID v5 generation.Because the password is part of the identity key, changing a password produces a new
user_idand the user’s prior per-user workflow state becomes inaccessible.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.selfis explicitly positional-only to allowselfas a field name.- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- password: nat.data_models.common.SerializableSecretStr = None#
- class UserInfo(/, **data: Any)#
Bases:
pydantic.BaseModelResolved user identity, independent of how it was identified.
Construct with exactly one identity source:
UserInfo(basic_user=BasicUserInfo(username="alice", password="s3cret")) UserInfo(api_key=SecretStr("sk-service-abc123"))
For runtime credentials (session cookie / JWT), use
UserManageror the_from_*factory classmethods.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.selfis explicitly positional-only to allowselfas a field name.- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- basic_user: BasicUserInfo | None = None#
- api_key: nat.data_models.common.OptionalSecretStr = None#
- _jwt: JwtUserInfo | None = None#
- model_post_init(__context: Any) None#
Override this method to perform additional initialization after
__init__andmodel_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- _set_user_id(identity_key: str) None#
Derive and set the deterministic UUID from an identity source value.
- get_user_details() JwtUserInfo | BasicUserInfo | str | None#
Return the identity-source data used to create this user.
- Returns:
JwtUserInfofor JWT users,BasicUserInfofor username/password users, the raw API key or cookie string for those users, orNoneif no source was set.
- classmethod _from_jwt(jwt_info: JwtUserInfo) UserInfo#