"Refactor error handling and rate limiting in FEHLER_BEHOBEN module"
This commit is contained in:
parent
bc2fd5a68c
commit
d4b0e561f7
@ -179,6 +179,20 @@ Komplettes Live-Druckererkennungs-System mit Session-Caching und automatischer S
|
||||
✅ **Umfassende API und Frontend-Integration**
|
||||
✅ **Production-ready mit Error-Handling und Logging**
|
||||
|
||||
#### [2025-01-05] Rate-Limiting-Fehler behoben ✅
|
||||
|
||||
**Problem:** TypeError bei `limit_requests()` - falsche Funktionssignatur verwendet
|
||||
**Lösung:**
|
||||
- Rate-Limits zu `RATE_LIMITS` Konfiguration hinzugefügt
|
||||
- API-Routen korrigiert von `@limit_requests("type", time, count)` zu `@limit_requests("type")`
|
||||
- Dokumentation aktualisiert
|
||||
|
||||
**Behobene Rate-Limits:**
|
||||
- `printer_monitor_live`: 5 Anfragen pro Minute
|
||||
- `printer_monitor_summary`: 10 Anfragen pro 30 Sekunden
|
||||
- `printer_monitor_cache`: 3 Anfragen pro 2 Minuten
|
||||
- `printer_monitor_init`: 2 Anfragen pro 5 Minuten
|
||||
|
||||
---
|
||||
|
||||
## [2024-12-29] Template-Ladeproblem behoben ✅
|
@ -4139,7 +4139,7 @@ def clear_printer_cache():
|
||||
|
||||
@app.route("/api/printers/monitor/live-status", methods=["GET"])
|
||||
@login_required
|
||||
@limit_requests("printer_monitor_live", 60, 5) # 5 Anfragen pro Minute
|
||||
@limit_requests("printer_monitor_live")
|
||||
def get_live_printer_monitor_status():
|
||||
"""
|
||||
Live-Druckerstatus über den neuen PrinterMonitor mit Session-Caching.
|
||||
@ -4180,7 +4180,7 @@ def get_live_printer_monitor_status():
|
||||
|
||||
@app.route("/api/printers/monitor/summary", methods=["GET"])
|
||||
@login_required
|
||||
@limit_requests("printer_monitor_summary", 30, 10) # 10 Anfragen pro 30 Sekunden
|
||||
@limit_requests("printer_monitor_summary")
|
||||
def get_printer_monitor_summary():
|
||||
"""
|
||||
Schnelle Zusammenfassung des Druckerstatus ohne vollständige Details.
|
||||
@ -4204,7 +4204,7 @@ def get_printer_monitor_summary():
|
||||
|
||||
@app.route("/api/printers/monitor/clear-cache", methods=["POST"])
|
||||
@login_required
|
||||
@limit_requests("printer_monitor_cache", 120, 3) # 3 Anfragen pro 2 Minuten
|
||||
@limit_requests("printer_monitor_cache")
|
||||
def clear_printer_monitor_cache():
|
||||
"""
|
||||
Löscht alle Caches des Drucker-Monitors.
|
||||
@ -4230,7 +4230,7 @@ def clear_printer_monitor_cache():
|
||||
@app.route("/api/printers/monitor/initialize-outlets", methods=["POST"])
|
||||
@login_required
|
||||
@admin_required
|
||||
@limit_requests("printer_monitor_init", 300, 2) # 2 Anfragen pro 5 Minuten
|
||||
@limit_requests("printer_monitor_init")
|
||||
def initialize_printer_outlets():
|
||||
"""
|
||||
Initialisiert alle Drucker-Steckdosen (schaltet sie aus für einheitlichen Zustand).
|
||||
|
@ -265,11 +265,19 @@ class Printer(Base):
|
||||
|
||||
### Rate-Limiting
|
||||
```python
|
||||
# Rate-Limits für API-Endpunkte
|
||||
@limit_requests("printer_monitor_live", 60, 5) # 5/min für Live-Status
|
||||
@limit_requests("printer_monitor_summary", 30, 10) # 10/30s für Summary
|
||||
@limit_requests("printer_monitor_cache", 120, 3) # 3/2min für Cache-Clear
|
||||
@limit_requests("printer_monitor_init", 300, 2) # 2/5min für Initialisierung
|
||||
# Rate-Limits für API-Endpunkte (bereits in RATE_LIMITS konfiguriert)
|
||||
@limit_requests("printer_monitor_live") # 5 Anfragen pro Minute
|
||||
@limit_requests("printer_monitor_summary") # 10 Anfragen pro 30 Sekunden
|
||||
@limit_requests("printer_monitor_cache") # 3 Anfragen pro 2 Minuten
|
||||
@limit_requests("printer_monitor_init") # 2 Anfragen pro 5 Minuten
|
||||
|
||||
# Konfiguration in utils/rate_limiter.py:
|
||||
RATE_LIMITS = {
|
||||
'printer_monitor_live': RateLimit(5, 60, "Zu viele Live-Status-Anfragen..."),
|
||||
'printer_monitor_summary': RateLimit(10, 30, "Zu viele Zusammenfassungs-Anfragen..."),
|
||||
'printer_monitor_cache': RateLimit(3, 120, "Zu viele Cache-Lösch-Anfragen..."),
|
||||
'printer_monitor_init': RateLimit(2, 300, "Zu viele Initialisierungs-Anfragen..."),
|
||||
}
|
||||
```
|
||||
|
||||
## Logging
|
||||
|
@ -34,6 +34,12 @@ RATE_LIMITS = {
|
||||
'printer_status': RateLimit(300, 300, "Zu viele Drucker-Status-Anfragen."),
|
||||
'job_creation': RateLimit(50, 3600, "Zu viele Job-Erstellungen. Versuchen Sie es in einer Stunde erneut."),
|
||||
|
||||
# Drucker-Monitor Rate-Limits
|
||||
'printer_monitor_live': RateLimit(5, 60, "Zu viele Live-Status-Anfragen. Versuchen Sie es in einer Minute erneut."),
|
||||
'printer_monitor_summary': RateLimit(10, 30, "Zu viele Zusammenfassungs-Anfragen. Versuchen Sie es in 30 Sekunden erneut."),
|
||||
'printer_monitor_cache': RateLimit(3, 120, "Zu viele Cache-Lösch-Anfragen. Versuchen Sie es in 2 Minuten erneut."),
|
||||
'printer_monitor_init': RateLimit(2, 300, "Zu viele Initialisierungs-Anfragen. Versuchen Sie es in 5 Minuten erneut."),
|
||||
|
||||
# Sicherheitskritische Endpunkte
|
||||
'password_reset': RateLimit(3, 3600, "Zu viele Passwort-Reset-Anfragen. Versuchen Sie es in einer Stunde erneut."),
|
||||
'user_creation': RateLimit(10, 3600, "Zu viele Benutzer-Erstellungen.")
|
||||
|
Loading…
x
Reference in New Issue
Block a user