ORIONIS API REFERENCE

THE ORIONIS API

Build with clarity.

Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.

module documentation

Persist personal access tokens through the Orionis query builder.

Function _as_datetime Coerce a stored timestamp into a datetime.
Function _decode_abilities Deserialise the abilities stored for a token.
Function _encode_abilities Serialise the abilities of a token for storage.
Function _is_expired Report whether an expiration moment already elapsed.
Function _normalize_abilities Validate credential restrictions without coercing malformed values.
Function _unexpired_tokens Group the nullable expiration constraint for token use.
Function _utc_now Return the current UTC moment as a naive datetime.
Constant _DEFAULT_SECRET_BYTES Default secret bytes value used by repository.
Constant _DEFAULT_TABLE Fallbacks applied when the configuration section is absent.
Constant _MAX_ABILITIES Max abilities value used by repository.
Constant _MAX_NAME_LENGTH Max name length value used by repository.
Constant _MAX_TOKEN_LENGTH Max token length value used by repository.
Constant _TOKEN_COLUMN Column holding the digest of the presented secret.
def _as_datetime(value: object) -> datetime | None: (source)

Coerce a stored timestamp into a datetime.

Queries over a table the builder knows no schema for come back with whatever the driver produced, and SQLite hands timestamps back as plain strings. Normalising here keeps the expiration check correct on every dialect.

Parameters
value:objectRaw value read from a timestamp column.
Returns
datetime.datetime | NoneParsed UTC moment without an offset, or None for SQL NULL.
Raises
orionis.auth.TokenExceptionIf a non-null timestamp is malformed.
def _decode_abilities(value: object) -> frozenset[str] | None: (source)

Deserialise the abilities stored for a token.

Parameters
value:objectRaw value read from the abilities column.
Returns
frozenset[str] | NoneValidated abilities, or None only for a SQL NULL value.
Raises
orionis.auth.TokenExceptionIf the stored payload is not an array of non-empty strings.
def _encode_abilities(abilities: frozenset[str] | None) -> str | None: (source)

Serialise the abilities of a token for storage.

Parameters
abilities:frozenset[str] | NoneAbilities granted to the token.
Returns
str | NoneSorted JSON array, or None for an unrestricted token.
def _is_expired(value: datetime | None) -> bool: (source)

Report whether an expiration moment already elapsed.

Parameters
value:datetime.datetime | NoneNormalised expiration moment of the token.
Returns
boolTrue when the moment is in the past. A missing value means the token never expires on its own.
def _normalize_abilities(abilities: Iterable[str] | None) -> frozenset[str] | None: (source)

Validate credential restrictions without coercing malformed values.

Parameters
abilities:collections.abc.Iterable[str] | NoneExplicit restrictions, or None for an unrestricted credential.
Returns
frozenset[str] | NoneDeduplicated, validated abilities.
Raises
orionis.auth.TokenExceptionIf the input is a string or contains invalid ability names.
def _unexpired_tokens(query: QueryBuilderBase): (source)

Group the nullable expiration constraint for token use.

Parameters
query:orionis.orm.query.base_builder.QueryBuilderBaseNested group assembled by the query builder.
Returns
NoneNo return value.
def _utc_now() -> datetime: (source)

Return the current UTC moment as a naive datetime.

Token columns are declared without a timezone so every dialect stores the same value. Dropping the offset here keeps writes and reads symmetric across SQLite, PostgreSQL and MySQL.

Returns
datetime.datetimeCurrent UTC moment without timezone information.
_DEFAULT_SECRET_BYTES: int = (source)

Default secret bytes value used by repository.

Value
40
_DEFAULT_TABLE: str = (source)

Fallbacks applied when the configuration section is absent.

Value
'personal_access_tokens'
_MAX_ABILITIES: int = (source)

Max abilities value used by repository.

Value
256
_MAX_NAME_LENGTH: int = (source)

Max name length value used by repository.

Value
255
_MAX_TOKEN_LENGTH: int = (source)

Max token length value used by repository.

Value
512
_TOKEN_COLUMN: str = (source)

Column holding the digest of the presented secret.

Value
'token'