diff --git a/server/src/routes/case_actions.rs b/server/src/routes/case_actions.rs index 1d149d8..c0df569 100644 --- a/server/src/routes/case_actions.rs +++ b/server/src/routes/case_actions.rs @@ -57,7 +57,8 @@ impl HasCsrfToken for AnalyzeForm { /// `analysis_input_v1.json`; otherwise writes `analysis_input_v{N+1}.json` /// where N is the current latest document version. The worker picks up the /// new input and produces `document_v{version}.md`. Available to all logged-in -/// users (no admin check). Race protection via `create_new` on the input file. +/// users; the optional `backend` form field is admin-only. Race protection +/// via `create_new` on the input file. pub async fn handle_analyze_case( user: AuthenticatedWebUser, State(config): State>, @@ -72,6 +73,13 @@ pub async fn handle_analyze_case( )); } + // Backend selection is admin-only. A non-empty field on a non-admin + // session indicates tampering or a stale tab after a role downgrade, + // and is rejected with 403 instead of silently falling back to default. + if !form.backend.is_empty() && !user.is_admin() { + return Err(AppError::Forbidden("Backend-Wahl nur für Admins".into())); + } + // Resolve the requested backend. Empty string falls back to the default // backend; an unknown id is rejected as a 400 so the user notices the // misconfiguration instead of silently getting a different model. diff --git a/server/templates/case_page.html b/server/templates/case_page.html index 2007448..f143670 100644 --- a/server/templates/case_page.html +++ b/server/templates/case_page.html @@ -438,11 +438,18 @@
{% call csrf::field(csrf_token) %} - Analysieren mit: + +
+ {% if is_admin %} +
+ {% call csrf::field(csrf_token) %} + {% for b in backends %} - + {% endfor %}
+ {% endif %} {% else if llm_missing && !has_document %} Kein LLM-Backend verfügbar — IONOS_API_KEY setzen. {% endif %} {% if is_admin %} @@ -474,7 +481,34 @@
{% call csrf::field(csrf_token) %} - Neu analysieren mit: + +
+ {% if is_admin %} +
+ {% call csrf::field(csrf_token) %} + {% for b in backends %} {% endfor %}
+ {% endif %} {% endif %}
@@ -591,6 +626,20 @@
+ {% call csrf::field(csrf_token) %} + + +
+ {% if is_admin %} +
{% call csrf::field(csrf_token) %} {% endfor %}
+ {% endif %}
{% when None %} {% if analyzing %}
Wird analysiert …