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

Gate a route behind a policy ability declared on a resource class.

The middleware evaluates the ability against the resource class, which covers the gates that do not need a loaded row, such as viewAny or create:

class CanCreatePosts(RequirePolicyMiddleware):
    ability = "create"
    resource = Post

Abilities that depend on a concrete row belong in the controller, where the instance already exists:

await Auth.authorizeResource("update", post)
Method __init__ Initialise the middleware with the authorizer.
Async Method handle Evaluate the policy and continue when it allows the operation.
Class Variable __slots__ Declare the instance attribute slots reserved by this class.
Class Variable ability Ability declared by the policy of the resource.
Class Variable resource Resource class protected by the policy.
Instance Variable _authorizer Component resolving and running the policy.
def __init__(self, authorizer: IAuthorizer): (source)

Initialise the middleware with the authorizer.

Parameters
authorizer:orionis.auth.contracts.IAuthorizerComponent resolving and running the policy.
Returns
NoneNo return value.
async def handle(self, request: Request, call_next: NextCallable) -> Response: (source)

Evaluate the policy and continue when it allows the operation.

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 ability or no resource.
orionis.auth.AuthenticationExceptionWhen the request carries no authenticated identity.
orionis.auth.AuthorizationExceptionWhen the policy denies the operation.
__slots__: tuple[str, ...] = (source)

Declare the instance attribute slots reserved by this class.

ability: ClassVar[str] = (source)

Ability declared by the policy of the resource.

resource: ClassVar[type | None] = (source)

Resource class protected by the policy.

_authorizer = (source)

Component resolving and running the policy.