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 SessionGuard(ISessionGuard): (source)

Constructor: SessionGuard(app, identities)

View In Hierarchy

Resolve the identity of web requests from the HTTP session.

The guard never implements its own session storage: it reads and writes the session started by StartSessionMiddleware and reachable through request.state.session.

Concurrency

The guard is stateless and safe as a singleton. All per request state lives in the session object owned by the request itself.

Static Method __session Return the session attached to a request, when present.
Method __init__ Initialise the guard from the authentication configuration.
Async Method __restoreRemembered Restore an identity from a persistent credential.
Async Method attempt Validate credentials and start an authenticated session.
Method login Persist an identity in the session of the current request.
Async Method logout Drop the authenticated state from the session.
Async Method resolve Resolve the identity remembered in the session.
Class Variable __slots__ Declare the instance attribute slots reserved by this class.
Instance Variable __csrf_key Session key containing the CSRF token.
Instance Variable __csrf_length Length of newly generated CSRF tokens.
Instance Variable __identities Provider turning a stored identifier into an identity.
Instance Variable __password_key Session key used to retain the authenticated password fingerprint.
Instance Variable __remember Optional request value enabling persistent authentication.
Instance Variable __session_key Session key under which the authenticated identity is stored.
Property name Return the configuration name of this guard.
def __session(request: _http.Request) -> ISession | None: (source)

Return the session attached to a request, when present.

Parameters
request:orionis.http.RequestIncoming HTTP request.
Returns
orionis.session.contracts.ISession | NoneSession started by the web pipeline, or None for routes that do not start one.
def __init__(self, app: IApplication, identities: IIdentityProvider): (source)

Initialise the guard from the authentication configuration.

Parameters
app:orionis.IApplicationApplication exposing the auth.session configuration.
identities:orionis.auth.contracts.IIdentityProviderProvider turning a stored identifier into an identity.
Returns
NoneNo return value.
async def __restoreRemembered(self, request: _http.Request) -> GuardResult | None: (source)

Restore an identity from a persistent credential.

Parameters
request:orionis.http.RequestIncoming request carrying the remember-me credential.
Returns
orionis.auth.entities.GuardResult | NoneAuthenticated session result, or None if restoration fails.
async def attempt(self, request: _http.Request, credentials: Mapping[str, object], *, remember: bool = False) -> IAuthenticatable | None: (source)

Validate credentials and start an authenticated session.

Parameters
request:orionis.http.RequestIncoming HTTP request owning the session.
credentials:collections.abc.Mapping[str, object]Submitted credentials.
remember:bool, optionalPersist a revocable login credential after password verification.
Returns
orionis.auth.contracts.IAuthenticatable | NoneAuthenticated identity, or None when the credentials do not match. The answer never reveals whether the account exists or the password was wrong.
def login(self, request: _http.Request, identity: IAuthenticatable): (source)

Persist an identity in the session of the current request.

Parameters
request:orionis.http.RequestIncoming HTTP request owning the session.
identity:orionis.auth.contracts.IAuthenticatableIdentity to remember for subsequent requests.
Returns
NoneNo return value.
Raises
orionis.auth.AuthExceptionWhen the request has no session, which means the route is not part of the web pipeline, or the identity has no persisted key.
async def logout(self, request: _http.Request): (source)

Drop the authenticated state from the session.

Parameters
request:orionis.http.RequestIncoming HTTP request owning the session.
Returns
NoneNo return value.
async def resolve(self, request: _http.Request) -> GuardResult | None: (source)

Resolve the identity remembered in the session.

A session pointing at an identity that no longer exists is cleaned up so the next request starts as a guest.

Parameters
request:orionis.http.RequestIncoming HTTP request.
Returns
orionis.auth.entities.GuardResult | NoneResolved identity, or None when the request is anonymous.
__slots__: tuple[str, ...] = (source)

Declare the instance attribute slots reserved by this class.

__csrf_key: str = (source)

Session key containing the CSRF token.

__csrf_length: int = (source)

Length of newly generated CSRF tokens.

__identities = (source)

Provider turning a stored identifier into an identity.

__password_key: str = (source)

Session key used to retain the authenticated password fingerprint.

__remember = (source)

Optional request value enabling persistent authentication.

__session_key: str = (source)

Session key under which the authenticated identity is stored.

Return the configuration name of this guard.

Returns
strAlways "session".