arbor_imago.auth package

Submodules

arbor_imago.auth.exceptions module

arbor_imago.auth.exceptions.Base(status_code: int, detail: str, logout: bool) HTTPException[source]
arbor_imago.auth.exceptions.authorization_expired() HTTPException[source]
arbor_imago.auth.exceptions.authorization_type_not_permitted(type: Literal['access_token', 'api_key', 'otp', 'sign_up']) HTTPException[source]
arbor_imago.auth.exceptions.credentials() HTTPException[source]
arbor_imago.auth.exceptions.different_tokens_provided(types: set[str], n: int) HTTPException[source]
arbor_imago.auth.exceptions.improper_format() HTTPException[source]
arbor_imago.auth.exceptions.invalid_otp() HTTPException[source]
arbor_imago.auth.exceptions.missing_authorization() HTTPException[source]
arbor_imago.auth.exceptions.missing_required_claims(claims: set[str]) HTTPException[source]
arbor_imago.auth.exceptions.not_permitted() HTTPException[source]
arbor_imago.auth.exceptions.user_not_found() HTTPException[source]

arbor_imago.auth.utils module

class arbor_imago.auth.utils.GetAuthFromJwtKwargs[source]

Bases: _WithRequiredScopes, _WithOverrideLifetime, _WithPermittedTypes

override_lifetime: NotRequired[timedelta]
permitted_types: NotRequired[set[Literal['access_token', 'api_key', 'sign_up']]]
required_scopes: NotRequired[set[Literal['admin', 'users.read', 'users.write']]]
token: str | None
class arbor_imago.auth.utils.GetAuthFromTableKwargs[source]

Bases: _WithRequiredScopes, _WithOverrideLifetime

auth_credential_service: Type[UserAccessToken] | Type[ApiKey] | Type[OTP]
dt_now: NotRequired[datetime]
override_lifetime: NotRequired[timedelta]
required_scopes: NotRequired[set[Literal['admin', 'users.read', 'users.write']]]
session: AsyncSession
class arbor_imago.auth.utils.GetAuthReturn(*, isAuthorized: bool = False, exception: HTTPException | None = None, user: UserPrivate | None = None, scope_ids: set[int] | None = None, auth_credential: TAuthCredentialInstance_co | None = None)[source]

Bases: BaseModel, Generic[TAuthCredentialInstance_co]

class Config[source]

Bases: object

arbitrary_types_allowed = True
auth_credential: TAuthCredentialInstance_co | None
exception: HTTPException | None
isAuthorized: bool
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

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

scope_ids: set[int] | None
user: UserPrivate | None
class arbor_imago.auth.utils.GetAuthReturn(*, isAuthorized: bool = False, exception: HTTPException | None = None, user: UserPrivate | None = None, scope_ids: set[int] | None = None, auth_credential: TAuthCredentialInstance_co | None = None)[source]

Bases: BaseModel, Generic[TAuthCredentialInstance_co]

class Config[source]

Bases: object

arbitrary_types_allowed = True
auth_credential: TAuthCredentialInstance_co | None
exception: HTTPException | None
isAuthorized: bool
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

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

scope_ids: set[int] | None
user: UserPrivate | None
class arbor_imago.auth.utils.GetAuthReturn(*, isAuthorized: bool = False, exception: HTTPException | None = None, user: UserPrivate | None = None, scope_ids: set[int] | None = None, auth_credential: TAuthCredentialInstance_co | None = None)[source]

Bases: BaseModel, Generic[TAuthCredentialInstance_co]

class Config[source]

Bases: object

arbitrary_types_allowed = True
auth_credential: TAuthCredentialInstance_co | None
exception: HTTPException | None
isAuthorized: bool
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

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

scope_ids: set[int] | None
user: UserPrivate | None
class arbor_imago.auth.utils.GetUserSessionInfoNestedReturn(*, auth: GetUserSessionInfoReturn)[source]

Bases: BaseModel

auth: GetUserSessionInfoReturn
model_config: ClassVar[ConfigDict] = {}

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

class arbor_imago.auth.utils.GetUserSessionInfoReturn(*, user: UserPrivate | None, scope_ids: set[int] | None, access_token: UserAccessTokenPublic | None)[source]

Bases: BaseModel

access_token: UserAccessTokenPublic | None
model_config: ClassVar[ConfigDict] = {}

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

scope_ids: set[int] | None
user: UserPrivate | None
class arbor_imago.auth.utils.LoginWithOTPResponse(*, auth: GetUserSessionInfoReturn)[source]

Bases: GetUserSessionInfoNestedReturn

model_config: ClassVar[ConfigDict] = {}

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

class arbor_imago.auth.utils.MakeGetAuthDepedencyKwargs[source]

Bases: _WithRequiredScopes, _WithOverrideLifetime, _WithPermittedTypes, _WithRaiseExceptions

override_lifetime: NotRequired[timedelta]
permitted_types: NotRequired[set[Literal['access_token', 'api_key', 'sign_up']]]
raise_exceptions: NotRequired[bool]
required_scopes: NotRequired[set[Literal['admin', 'users.read', 'users.write']]]
class arbor_imago.auth.utils.OAuth2PasswordBearerMultiSource(flows: OAuthFlows)[source]

Bases: OAuth2

async arbor_imago.auth.utils.create_otp(session: AsyncSession, user: User, email: Annotated[EmailStr, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=254, pattern=None)] | None = None, phone_number: str | None = None) Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=6, max_length=6, pattern=re.compile('^\\d{6}$'))][source]
async arbor_imago.auth.utils.get_auth_from_auth_credential_jwt(**kwargs: Unpack[GetAuthFromJwtKwargs]) GetAuthReturn[UserAccessToken | ApiKey | SignUp][source]
async arbor_imago.auth.utils.get_auth_from_auth_credential_table_inst(auth_credential_table_inst: TAuthCredentialTableInstance, **kwargs: Unpack[GetAuthFromTableKwargs]) GetAuthReturn[TypeVar][source]
arbor_imago.auth.utils.get_user_session_info(get_authorization_return: GetAuthReturn) GetUserSessionInfoNestedReturn[source]
arbor_imago.auth.utils.is_valid_time_bounds(issued: datetime, expiry: datetime, dt_now: datetime = datetime.datetime(2025, 6, 21, 16, 12, 28, 252224, tzinfo=datetime.timezone.utc), override_lifespan: timedelta | None = None) bool[source]

Validate the time bounds of the issued and expiry dates.

async arbor_imago.auth.utils.login_otp(session: AsyncSession, user: User | None, response: Response, code: Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=6, max_length=6, pattern=re.compile('^\\d{6}$'))]) LoginWithOTPResponse[source]
arbor_imago.auth.utils.make_authenticate_user_with_username_and_password_dependency()[source]
arbor_imago.auth.utils.make_get_auth_dependency(**kwargs: Unpack[MakeGetAuthDepedencyKwargs])[source]
async arbor_imago.auth.utils.send_otp(code: Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=6, max_length=6, pattern=re.compile('^\\d{6}$'))], user: User, email: Annotated[EmailStr, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=254, pattern=None)] | None = None, phone_number: str | None = None)[source]

Module contents