Aufgabe 38: CORS & API-Sicherheit #13

Open
opened 2026-06-24 11:13:50 +02:00 by danielkrause · 0 comments
Owner

Ziel

CORS zwischen Article-Server (Port 8890) und Chatbot (Port 5002) korrekt konfigurieren. API-Endpunkte absichern.

Ist-Stand

  • Article-Server auf Port 8890 (/nanobanana?key=..., /publish)
  • Chatbot auf Port 5002 (/api/submission/<id>/set-image)
  • Keine CORS-Header gesetzt → Cross-Origin-Requests blockiert

Akzeptanzkriterien

CORS

  • Access-Control-Allow-Origin: https://chat.datenhimmel.work (oder * für Dev)
  • Access-Control-Allow-Methods: GET, POST, OPTIONS
  • Access-Control-Allow-Headers: Content-Type, Authorization
  • OPTIONS-Preflight-Handling (200 OK)
  • Beide Server: CORS-Header einheitlich

API-Sicherheit

  • /api/*-Endpunkte: Content-Type-Validierung (JSON only)
  • Rate-Limiting: Max 30 Requests/Minute pro IP
  • Request-Size-Limit: Max 10 MB (Bild-Upload)
  • /api/submission/<id>/set-image: Validiere Submission-Existenz

Dateien

  • app.py — Flask-CORS (flask-cors oder manuell)
  • article_server.py — CORS-Header
  • tests/test_cors.py — NEU

Qualität

ruff check . --fix && ruff format . && pytest tests/test_cors.py -v
# Manuell: curl -X OPTIONS -H "Origin: http://localhost:8890" http://localhost:5002/api/submission/1/set-image
## Ziel CORS zwischen Article-Server (Port 8890) und Chatbot (Port 5002) korrekt konfigurieren. API-Endpunkte absichern. ## Ist-Stand - Article-Server auf Port 8890 (`/nanobanana?key=...`, `/publish`) - Chatbot auf Port 5002 (`/api/submission/<id>/set-image`) - Keine CORS-Header gesetzt → Cross-Origin-Requests blockiert ## Akzeptanzkriterien ### CORS - [ ] `Access-Control-Allow-Origin: https://chat.datenhimmel.work` (oder `*` für Dev) - [ ] `Access-Control-Allow-Methods: GET, POST, OPTIONS` - [ ] `Access-Control-Allow-Headers: Content-Type, Authorization` - [ ] OPTIONS-Preflight-Handling (200 OK) - [ ] Beide Server: CORS-Header einheitlich ### API-Sicherheit - [ ] `/api/*`-Endpunkte: Content-Type-Validierung (JSON only) - [ ] Rate-Limiting: Max 30 Requests/Minute pro IP - [ ] Request-Size-Limit: Max 10 MB (Bild-Upload) - [ ] `/api/submission/<id>/set-image`: Validiere Submission-Existenz ### Dateien - `app.py` — Flask-CORS (flask-cors oder manuell) - `article_server.py` — CORS-Header - `tests/test_cors.py` — NEU ### Qualität ```bash ruff check . --fix && ruff format . && pytest tests/test_cors.py -v # Manuell: curl -X OPTIONS -H "Origin: http://localhost:8890" http://localhost:5002/api/submission/1/set-image ```
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: danielkrause/BSN-Chatsystem#13