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
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__ |
Undocumented |
| Class Variable | requires |
Undocumented |
| Class Variable | roles |
Undocumented |
| Instance Variable | _authorizer |
Undocumented |
Initialise the middleware with the authorizer.
| Parameters | |
authorizer:IAuthorizer | Component evaluating the roles of the request context. |
| Returns | |
None | The middleware keeps no per request state. |
overrides
orionis.http.BaseMiddleware.handleEvaluate the roles and continue when they are granted.
| Parameters | |
request:Request | Incoming HTTP request, unused by this middleware. |
callNextCallable | Callable advancing to the next layer. |
| Returns | |
Response | Response produced by the rest of the pipeline. |
| Raises | |
AuthConfigurationException | When the subclass declares no role at all. |
AuthenticationException | When the request carries no authenticated identity. |
AuthorizationException | When the identity does not hold the required roles. |