Coverage for src / lexigram / contracts / admin / authorizer.py: 100%
5 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-15 18:58 +0800
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-15 18:58 +0800
1"""AdminAuthorizerProtocol — authorization for admin resource operations."""
3from __future__ import annotations
5from typing import Any, Protocol, runtime_checkable
8@runtime_checkable
9class AdminAuthorizerProtocol(Protocol):
10 """Canonical admin-internal authorization protocol.
12 Covers both CRUD-level checks (can_view, can_create, can_update, can_delete)
13 and action-level checks (can_execute_action).
14 """
16 async def can_view(self, user: Any, resource: str, record: Any = None) -> bool: ...
18 async def can_create(self, user: Any, resource: str) -> bool: ...
20 async def can_update(
21 self, user: Any, resource: str, record: Any = None
22 ) -> bool: ...
24 async def can_delete(
25 self, user: Any, resource: str, record: Any = None
26 ) -> bool: ...
28 async def can_execute_action(
29 self, user: Any, resource: str, action: str, record: Any | None = None
30 ) -> bool: ...
33__all__ = ["AdminAuthorizerProtocol"]