mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-21 00:21:49 +00:00
docs(auth_v2): one-line docstrings on AuthSecurity Security() entrypoints (D1)
This commit is contained in:
parent
8302f55995
commit
4ec48302a5
1 changed files with 5 additions and 0 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue