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

Require one or more roles before reaching the controller.

Roles are a grouping of permissions, so prefer orionis.auth.middleware.RequirePermissionMiddleware whenever the route protects a concrete capability. Declare the requirement by subclassing:

class MustBeAdmin(RequireRoleMiddleware):
    roles = ("admin",)
Async Method __evaluate Report whether the context satisfies the role requirement.
Method __init__ Initialise the middleware with the authorizer.
Async Method handle Evaluate the roles and continue when they are granted.
Class Variable __slots__ Declare the instance attribute slots reserved by this class.
Class Variable requires_all Whether every role is required, or just one of them.
Class Variable roles Roles the identity must hold.
Instance Variable _authorizer Component evaluating the roles of the request context.
async def __evaluate(self, context: object, required: tuple[str, ...]) -> bool: (source)

Report whether the context satisfies the role requirement.

Parameters
context:objectAuthentication context of the current request.
required:tuple[str, ...]Roles declared by the subclass.
Returns
boolTrue when the requirement is satisfied.
def __init__(self, authorizer: IAuthorizer): (source)

Initialise the middleware with the authorizer.

Parameters
authorizer:orionis.auth.contracts.IAuthorizerComponent evaluating the roles of the request context.
Returns
NoneNo return value.
async def handle(self, request: Request, call_next: NextCallable) -> Response: (source)

Evaluate the roles and continue when they are granted.

Parameters
request:orionis.http.RequestIncoming HTTP request, unused by this middleware.
call_next:orionis.http.NextCallableCallable advancing to the next layer.
Returns
orionis.http.ResponseResponse produced by the rest of the pipeline.
Raises
orionis.auth.AuthConfigurationExceptionWhen the subclass declares no role at all.
orionis.auth.AuthenticationExceptionWhen the request carries no authenticated identity.
orionis.auth.AuthorizationExceptionWhen the identity does not hold the required roles.
__slots__: tuple[str, ...] = (source)

Declare the instance attribute slots reserved by this class.

requires_all: ClassVar[bool] = (source)

Whether every role is required, or just one of them.

roles: ClassVar[tuple[str, ...]] = (source)

Roles the identity must hold.

_authorizer = (source)

Component evaluating the roles of the request context.