(scope, limit=20, window=60)
| 2169 | |
| 2170 | |
| 2171 | def require_sensitive_request(scope, limit=20, window=60): |
| 2172 | if rate_limited(scope, limit=limit, window=window): |
| 2173 | return jsonify({"status": "error", "message": "Troppe richieste. Riprova tra poco."}), 429 |
| 2174 | csrf = request.headers.get("X-CSRF-Token", "") |
| 2175 | expected = flask_session.get("csrf_token", "") |
| 2176 | if not flask_session.get("admin_authenticated"): |
| 2177 | return jsonify({"status": "error", "message": "Sessione amministratore non valida."}), 401 |
| 2178 | if not expected or not hmac.compare_digest(csrf, expected): |
| 2179 | return jsonify({"status": "error", "message": "CSRF token non valido."}), 403 |
| 2180 | return None |
| 2181 | |
| 2182 | |
| 2183 | def require_authenticated_download(scope, limit=40, window=60): |
no test coverage detected