~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
feat: add authentication rate limiting and fix account enumeration
LearningCircuit23c9584ec490
diff --git a/pyproject.toml b/pyproject.tomlindex 69b37df215..40f3b0f9d2 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -72,6 +72,7 @@ dependencies = ["rich~=14.2","click~=8.3","flask-login~=0.6",+ "flask-limiter~=3.8","dogpile-cache~=1.5","redis~=7.1","msgpack~=1.1",diff --git a/src/local_deep_research/web/app_factory.py b/src/local_deep_research/web/app_factory.pyindex c56796cce6..dc2f42e246 100644--- a/src/local_deep_research/web/app_factory.py+++ b/src/local_deep_research/web/app_factory.py@@ -10,6 +10,8 @@ from flask import (send_from_directory,)from flask_wtf.csrf import CSRFProtect+from flask_limiter import Limiter+from flask_limiter.util import get_remote_addressfrom loguru import loggerfrom local_deep_research.settings.logger import log_settings@@ -102,6 +104,27 @@ def create_app():# Initialize security headers middlewareSecurityHeaders(app)+ # Initialize rate limiting for security (brute force protection)+ limiter = Limiter(+ app=app,+ key_func=get_remote_address,+ default_limits=["200 per day", "50 per hour"],+ storage_uri="memory://",+ # Configure retry-after header for better UX+ headers_enabled=True,+ )++ # Custom error handler for rate limit exceeded (429)+ @app.errorhandler(429)+ def ratelimit_handler(e):+ return jsonify(+ error="Too many requests",+ message="Too many attempts. Please try again later.",+ ), 429++ # Make limiter available to other modules+ app.limiter = limiter+# Disable CSRF for API routes@app.before_requestdef disable_csrf_for_api():diff --git a/src/local_deep_research/web/auth/routes.py b/src/local_deep_research/web/auth/routes.pyindex 41a9f92763..0da6931f11 100644--- a/src/local_deep_research/web/auth/routes.py+++ b/src/local_deep_research/web/auth/routes.py@@ -15,6 +15,7 @@ from flask import (request,session,url_for,+ current_app,)from loguru import logger@@ -28,6 +29,30 @@ auth_bp = Blueprint("auth", __name__, url_prefix="/auth")session_manager = SessionManager()+# Helper function to apply rate limiting to routes+def apply_rate_limit(limit_string):+ """+ Decorator to apply rate limiting to a route.+ Uses the limiter from current_app.++ Args:+ limit_string: Rate limit string (e.g., "5 per 15 minutes")+ """+ from functools import wraps++ def decorator(f):+ @wraps(f)+ def wrapped(*args, **kwargs):+ limiter = current_app.limiter+ # Apply the limit using the limiter's limit decorator+ limited_func = limiter.limit(limit_string)(f)+ return limited_func(*args, **kwargs)++ return wrapped++ return decorator++@auth_bp.route("/csrf-token", methods=["GET"])def get_csrf_token():"""@@ -45,10 +70,12 @@ def get_csrf_token():@auth_bp.route("/login", methods=["GET", "POST"])+@apply_rate_limit("5 per 15 minutes")def login():"""Login page and handler.Supports browser password managers with standard autocomplete attributes.+ Rate limited to 5 attempts per 15 minutes per IP to prevent brute force attacks."""config = load_server_config()if request.method == "GET":@@ -240,10 +267,12 @@ def login():@auth_bp.route("/register", methods=["GET", "POST"])+@apply_rate_limit("3 per hour")def register():"""Registration page and handler.Creates new encrypted database for user with clear warnings about password recovery.+ Rate limited to 3 attempts per hour per IP to prevent registration spam."""config = load_server_config()if not config.get("allow_registrations", True):@@ -287,8 +316,9 @@ def register():)# Check if user already exists+ # Use generic error message to prevent account enumerationif username and db_manager.user_exists(username):- errors.append("Username already exists")+ errors.append("Registration failed. Please try a different username.")if errors:for error in errors: