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.

class documentation

class TokenGuard(IGuard): (source)

Constructor: TokenGuard(tokens, identities)

View In Hierarchy

Resolve the identity of API requests from a personal access token.

The token travels in the standard header:

Authorization: Bearer <token>

Tokens are opaque, revocable and optionally expiring. No signed payload such as a JWT is involved, so revocation is immediate.

Concurrency

The guard is stateless and safe as a singleton. The only write it performs is the last_used_at update, issued as a single statement where the last writer legitimately wins.

Method __init__ Initialise the guard with its collaborators.
Async Method resolve Resolve the identity owning the presented access token.
Class Variable __slots__ Declare the instance attribute slots reserved by this class.
Instance Variable __identities Provider turning a token owner into an identity.
Instance Variable __tokens Store used to look tokens up and mark them as used.
Property name Return the configuration name of this guard.
def __init__(self: Self, tokens: IAccessTokenRepository, identities: IIdentityProvider): (source)

Initialise the guard with its collaborators.

Parameters
tokens:orionis.auth.contracts.IAccessTokenRepositoryStore used to look tokens up and mark them as used.
identities:orionis.auth.contracts.IIdentityProviderProvider turning a token owner into an identity.
Returns
NoneNo return value.
async def resolve(self: Self, request: _http.Request) -> GuardResult | None: (source)

Resolve the identity owning the presented access token.

Parameters
request:orionis.http.RequestIncoming HTTP request.
Returns
orionis.auth.entities.GuardResult | NoneResolved identity together with the abilities of the token, or None when the request carries no usable token.
__slots__: tuple[str, ...] = (source)

Declare the instance attribute slots reserved by this class.

__identities = (source)

Provider turning a token owner into an identity.

__tokens = (source)

Store used to look tokens up and mark them as used.

Return the configuration name of this guard.

Returns
strAlways "token".