AP0.3: Capability Registry, Entitlements-Snapshot und require_capability.
Deploy Development / deploy (push) Successful in 33s
Test Suite / pytest-backend (push) Failing after 4s
Test Suite / k6 /api/health Baseline (push) Has been skipped
Test Suite / playwright-smoke (push) Has been skipped
Test Suite / lint-backend (push) Successful in 1s
Test Suite / compose-smoke (push) Has been skipped
Deploy Development / deploy (push) Successful in 33s
Test Suite / pytest-backend (push) Failing after 4s
Test Suite / k6 /api/health Baseline (push) Has been skipped
Test Suite / playwright-smoke (push) Has been skipped
Test Suite / lint-backend (push) Successful in 1s
Test Suite / compose-smoke (push) Has been skipped
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
f9c207c4f6
commit
910b1d7e07
19 files changed
+788
-8
No files matched your search
+20
-2
@@ -1,8 +1,10 @@
|
||||
"""Current user and tenant context endpoints."""
|
||||
"""Current user, tenant context and entitlements endpoints."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from auth import get_session, require_auth, set_session_active_tenant
|
||||
from capabilities import require_capability
|
||||
from entitlements import build_entitlements_snapshot
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from pydantic import BaseModel
|
||||
from tenant_context import TenantContext, get_tenant_context, list_user_tenants, require_tenant_context, resolve_tenant_context
|
||||
@@ -34,10 +36,26 @@ def get_my_context(ctx: TenantContext = Depends(get_tenant_context)):
|
||||
|
||||
@router.get("/context/required")
|
||||
def get_my_context_with_tenant(ctx: TenantContext = Depends(require_tenant_context)):
|
||||
"""Example endpoint requiring an active tenant — for tests and AP0.3 prep."""
|
||||
"""Endpoint requiring an active tenant."""
|
||||
return ctx.to_dict()
|
||||
|
||||
|
||||
@router.get("/entitlements")
|
||||
def get_my_entitlements(ctx: TenantContext = Depends(get_tenant_context)):
|
||||
return build_entitlements_snapshot(ctx)
|
||||
|
||||
|
||||
@router.get("/admin/demo")
|
||||
def admin_demo(ctx: TenantContext = Depends(require_capability("kairo.admin.access"))):
|
||||
"""Example endpoint protected by require_capability."""
|
||||
return {
|
||||
"ok": True,
|
||||
"message": "Portal-Admin Capability bestätigt",
|
||||
"user_id": ctx.user_id,
|
||||
"tenant_id": ctx.tenant_id,
|
||||
}
|
||||
|
||||
|
||||
@router.post("/tenant")
|
||||
def switch_tenant(body: SwitchTenantRequest, session: dict = Depends(require_auth)):
|
||||
ok = set_session_active_tenant(session["token"], body.tenant_id)
|
||||
|
||||
Reference in new issue
Block a user