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 RequireRoleMiddleware(BaseMiddleware): (source)
Constructor: RequireRoleMiddleware(authorizer)
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 |
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. |
Initialise the middleware with the authorizer.
| Parameters | |
authorizer:orionis.auth.contracts.IAuthorizer | Component evaluating the roles of the request context. |
| Returns | |
None | No return value. |
overrides
orionis.http.BaseMiddleware.handleEvaluate the roles and continue when they are granted.
| Parameters | |
request:orionis.http.Request | Incoming HTTP request, unused by this middleware. |
callorionis.http.NextCallable | Callable advancing to the next layer. |
| Returns | |
orionis.http.Response | Response produced by the rest of the pipeline. |
| Raises | |
orionis.auth.AuthConfigurationException | When the subclass declares no role at all. |
orionis.auth.AuthenticationException | When the request carries no authenticated identity. |
orionis.auth.AuthorizationException | When the identity does not hold the required roles. |
overrides
orionis.http.BaseMiddleware.__slots__Declare the instance attribute slots reserved by this class.