Authorization Port¶
authorization_port
¶
Inbound port for authorization and permission checking.
Responsibilities
- Check whether a user has a specific permission.
- Evaluate resource-level access control.
- Retrieve effective permissions and roles for a user.
Non-Responsibilities
- Authenticate users (handled externally).
- Enforce business rules (handled by validation or domain).
AuthorizationPort
¶
Bases: InboundPort
Inbound port for authorization decisions.
Class Type Parameters:
| Name | Bound or Constraints | Description | Default |
|---|---|---|---|
AuthorizationCheckContext
|
The application-defined context for authorization checks. |
required |
Responsibilities
- Evaluate permissions against an authorization context.
- Support resource-level and global permission checks.
- Expose user roles and effective permissions.
Non-Responsibilities
- Manage user identities or credentials.
- Define permission hierarchies (delegated to domain or configuration).
Example
Source code in src/forging_blocks/application/ports/inbound/authorization_port.py
check_permission(context: AuthorizationCheckContext, permission: Permission) -> bool
abstractmethod
async
¶
Evaluate whether permission is granted in context.
check_resource_permission(context: AuthorizationCheckContext, resource: str, action: str) -> bool
abstractmethod
async
¶
Evaluate whether action on resource is permitted in context.