docs(auth_v2): one-line docstrings on AuthSecurity Security() entrypoints (D1)

This commit is contained in:
Yassin Kortam 2026-06-10 19:10:08 -07:00
parent 8302f55995
commit 4ec48302a5

View file

@ -70,6 +70,7 @@ class AuthSecurity:
async def principal(
self, security_scopes: SecurityScopes, request: Request
) -> Principal:
"""Resolve the caller to a Principal, enforcing scheme OR and required scopes."""
credential = None
for authenticator in self.authenticators:
credential = await authenticator.authenticate(request)
@ -87,6 +88,8 @@ class AuthSecurity:
return principal
def require_roles(self, *allowed: Role) -> Callable[..., object]:
"""Security() dependency that admits a principal holding any allowed role (hierarchy-aware)."""
async def dependency(
principal: Annotated[Principal, Security(self.principal)],
) -> Principal:
@ -97,6 +100,8 @@ class AuthSecurity:
return dependency
def require_permission(self, obj: str, act: str) -> Callable[..., object]:
"""Security() dependency that admits a principal whose roles permit obj/act via Casbin."""
async def dependency(
principal: Annotated[Principal, Security(self.principal)],
) -> Principal: