Dependencies¶
sentinel_auth.dependencies
¶
FastAPI dependency helpers for extracting auth context from requests.
get_current_user(request)
¶
Extract the authenticated user from request state (set by JWTAuthMiddleware).
Source code in sdk/src/sentinel_auth/dependencies.py
get_workspace_id(user=Depends(get_current_user))
¶
Extract the workspace ID from the current user's JWT context.
get_workspace_context(user=Depends(get_current_user))
¶
Extract full workspace context from the current user's JWT.
Source code in sdk/src/sentinel_auth/dependencies.py
require_role(minimum_role)
¶
Dependency factory that enforces a minimum workspace role.
Usage
@router.post("/things") async def create_thing(user: AuthenticatedUser = Depends(require_role("editor"))): ...
Source code in sdk/src/sentinel_auth/dependencies.py
require_action(role_client, action)
¶
Dependency factory that enforces an RBAC action via the identity service.
Usage
@router.get("/reports/export") async def export(user: AuthenticatedUser = Depends(require_action(roles, "reports:export"))): ...