Enhance Tenant Context and Access Control Features
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Failing after 0s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Failing after 4m0s
Test Suite / playwright-tests (push) Failing after 3m41s
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Failing after 0s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Failing after 4m0s
Test Suite / playwright-tests (push) Failing after 3m41s
- Introduced `email_verified` and `account_state` attributes in the `TenantContext` to improve user state management. - Updated the `resolve_tenant_context` function to dynamically fetch `email_verified` status from the database and determine `account_state` based on user roles and memberships. - Implemented `assert_min_account_state` checks across various endpoints to enforce access control based on user account status. - Incremented version to 1.1.0 in version.py to reflect these enhancements in tenant context management and access control.
This commit is contained in:
1 parent
7cfbca40bb
commit
30dc30c7aa
21 files changed
+1124
-22
No files matched your search
@@ -37,6 +37,8 @@ from media_rights import assert_rights_for_exercise_link, validate_rights_declar
|
||||
from media_legal_hold import assert_not_under_legal_hold
|
||||
from ai_prompt_context import ExerciseFormAiFocusRow, ExerciseFormAiPromptContext
|
||||
from ai_prompt_job import run_exercise_form_ai_suggestion
|
||||
from account_lifecycle import assert_min_account_state
|
||||
from capabilities import probe_capability
|
||||
from club_features import probe_club_feature_access, resolve_club_id_for_probe
|
||||
|
||||
from exercise_rich_text import (
|
||||
@@ -2318,6 +2320,14 @@ def exercise_ai_suggest_endpoint(
|
||||
KI-Vorschlaege (Kurzfassung und/oder Skill-Zuordnung) ohne Speichern.
|
||||
OPENROUTER_API_KEY erforderlich.
|
||||
"""
|
||||
assert_min_account_state(tenant, "active_member", endpoint="POST /exercises/ai/suggest")
|
||||
probe_capability(
|
||||
tenant,
|
||||
"exercises.ai.suggest",
|
||||
action="suggest",
|
||||
club_id=resolve_club_id_for_probe(tenant),
|
||||
endpoint="POST /exercises/ai/suggest",
|
||||
)
|
||||
probe_club_feature_access(
|
||||
feature_id="ai_calls",
|
||||
action="suggest",
|
||||
@@ -2344,6 +2354,14 @@ def exercise_ai_regenerate_endpoint(
|
||||
tenant: TenantContext = Depends(get_tenant_context),
|
||||
):
|
||||
"""Neu-Anfrage KI fuer eine gespeicherte Uebung; schreibendes Ergebnis nur im Frontend (PUT)."""
|
||||
assert_min_account_state(tenant, "active_member", endpoint="POST /exercises/{id}/ai/regenerate")
|
||||
probe_capability(
|
||||
tenant,
|
||||
"exercises.ai.regenerate",
|
||||
action="regenerate",
|
||||
club_id=resolve_club_id_for_probe(tenant),
|
||||
endpoint="POST /exercises/{id}/ai/regenerate",
|
||||
)
|
||||
probe_club_feature_access(
|
||||
feature_id="ai_calls",
|
||||
action="regenerate",
|
||||
@@ -2436,6 +2454,14 @@ def create_exercise(
|
||||
club_id = tenant.effective_club_id
|
||||
|
||||
if club_id is not None:
|
||||
assert_min_account_state(tenant, "active_member", endpoint="POST /exercises")
|
||||
probe_capability(
|
||||
tenant,
|
||||
"exercises.create",
|
||||
action="create",
|
||||
club_id=int(club_id),
|
||||
endpoint="POST /exercises",
|
||||
)
|
||||
probe_club_feature_access(
|
||||
feature_id="exercises",
|
||||
action="create",
|
||||
@@ -3245,6 +3271,15 @@ async def upload_exercise_media(
|
||||
ex_club = cur.fetchone()
|
||||
media_club_id = ex_club.get("club_id") if ex_club else None
|
||||
if media_club_id is not None:
|
||||
assert_min_account_state(tenant, "active_member", endpoint="POST /exercises/{id}/media")
|
||||
probe_capability(
|
||||
tenant,
|
||||
"exercises.media.upload",
|
||||
action="upload",
|
||||
club_id=int(media_club_id),
|
||||
endpoint="POST /exercises/{id}/media",
|
||||
conn=conn,
|
||||
)
|
||||
probe_club_feature_access(
|
||||
feature_id="exercise_media",
|
||||
action="upload",
|
||||
|
||||
Reference in new issue
Block a user