Skip to content

~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.

Updated to add support for disabling authentication using an environm… (#801)

tombii9dda466b87f0
diff --git a/src/local_deep_research/defaults/default_settings.json b/src/local_deep_research/defaults/default_settings.json
index d32288bf4b..aac3c073a6 100644
--- a/src/local_deep_research/defaults/default_settings.json
+++ b/src/local_deep_research/defaults/default_settings.json
@@ -177,6 +177,20 @@
"value": true,
"visible": true
},
+ "app.allow_registrations": {
+ "category": "app_interface",
+ "description": "Allow new user registrations through the web interface.",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Allow Registrations",
+ "options": null,
+ "step": null,
+ "type": "APP",
+ "ui_element": "checkbox",
+ "value": true,
+ "visible": true
+ },
"llm.llamacpp_f16_kv": {
"category": null,
"description": "Setting for llm.llamacpp_f16_kv",
diff --git a/src/local_deep_research/web/auth/routes.py b/src/local_deep_research/web/auth/routes.py
index 08e7fe06bc..52a427a042 100644
--- a/src/local_deep_research/web/auth/routes.py
+++ b/src/local_deep_research/web/auth/routes.py
@@ -22,6 +22,7 @@ from ...database.auth_db import get_auth_db_session
from ...database.encrypted_db import db_manager
from ...database.models.auth import User
from .session_manager import SessionManager
+from ..server_config import load_server_config
auth_bp = Blueprint("auth", __name__, url_prefix="/auth")
session_manager = SessionManager()
@@ -33,13 +34,16 @@ def login():
Login page and handler.
Supports browser password managers with standard autocomplete attributes.
"""
+ config = load_server_config()
if request.method == "GET":
# Check if already logged in
if session.get("username"):
return redirect(url_for("index"))
return render_template(
- "auth/login.html", has_encryption=db_manager.has_encryption
+ "auth/login.html",
+ has_encryption=db_manager.has_encryption,
+ allow_registrations=config.get("allow_registrations", True),
)
# POST - Handle login
@@ -50,7 +54,9 @@ def login():
if not username or not password:
flash("Username and password are required", "error")
return render_template(
- "auth/login.html", has_encryption=db_manager.has_encryption
+ "auth/login.html",
+ has_encryption=db_manager.has_encryption,
+ allow_registrations=config.get("allow_registrations", True),
), 400
# Try to open user's encrypted database
@@ -61,7 +67,9 @@ def login():
logger.warning(f"Failed login attempt for username: {username}")
flash("Invalid username or password", "error")
return render_template(
- "auth/login.html", has_encryption=db_manager.has_encryption
+ "auth/login.html",
+ has_encryption=db_manager.has_encryption,
+ allow_registrations=config.get("allow_registrations", True),
), 401
# Check if user has settings loaded (first login after migration)
@@ -191,6 +199,11 @@ def register():
Registration page and handler.
Creates new encrypted database for user with clear warnings about password recovery.
"""
+ config = load_server_config()
+ if not config.get("allow_registrations", True):
+ flash("New user registrations are currently disabled.", "error")
+ return redirect(url_for("auth.login"))
+
if request.method == "GET":
return render_template(
"auth/register.html", has_encryption=db_manager.has_encryption
diff --git a/src/local_deep_research/web/server_config.py b/src/local_deep_research/web/server_config.py
index 28b3dfa4fe..695a735869 100644
--- a/src/local_deep_research/web/server_config.py
+++ b/src/local_deep_research/web/server_config.py
@@ -55,6 +55,12 @@ def load_server_config() -> Dict[str, Any]:
"checkbox",
default=True,
),
+ "allow_registrations": get_typed_setting_value(
+ "app.allow_registrations",
+ saved_config.get("allow_registrations"),
+ "checkbox",
+ default=True,
+ ),
}
return config
@@ -102,5 +108,9 @@ def sync_from_settings(settings_snapshot: Dict[str, Any]) -> None:
config["debug"] = settings_snapshot["app.debug"]
if "web.use_https" in settings_snapshot:
config["use_https"] = settings_snapshot["web.use_https"]
+ if "app.allow_registrations" in settings_snapshot:
+ config["allow_registrations"] = settings_snapshot[
+ "app.allow_registrations"
+ ]
save_server_config(config)
diff --git a/src/local_deep_research/web/templates/auth/login.html b/src/local_deep_research/web/templates/auth/login.html
index be28406e16..a4cab5e9af 100644
--- a/src/local_deep_research/web/templates/auth/login.html
+++ b/src/local_deep_research/web/templates/auth/login.html
@@ -589,7 +589,9 @@
</form>
<div class="auth-links">
+ {% if allow_registrations %}
<p>Don't have an account? <a href="{{ url_for('auth.register') }}">Register here</a></p>
+ {% endif %}
<div class="browser-hint">
<i class="fas fa-info-circle"></i>
<span>Your browser can save your password for easy login</span>
diff --git a/tests/auth_tests/test_auth_routes.py b/tests/auth_tests/test_auth_routes.py
index d4a2609517..725c3e7810 100644
--- a/tests/auth_tests/test_auth_routes.py
+++ b/tests/auth_tests/test_auth_routes.py
@@ -351,3 +351,51 @@ class TestAuthRoutes:
data = response.get_json()
assert data["authenticated"] is True
assert data["username"] == "testuser"
+
+ def test_blocked_registration_get(self, client, monkeypatch):
+ """Test that GET register redirects when registrations are disabled."""
+
+ def mock_load_config():
+ return {"allow_registrations": False}
+
+ monkeypatch.setattr(
+ "src.local_deep_research.web.auth.routes.load_server_config",
+ mock_load_config,
+ )
+
+ response = client.get("/auth/register", follow_redirects=False)
+ assert response.status_code == 302
+ assert "/auth/login" in response.location
+
+ def test_blocked_registration_post(self, client, monkeypatch):
+ """Test that POST register redirects and doesn't create user when disabled."""
+
+ def mock_load_config():
+ return {"allow_registrations": False}
+
+ monkeypatch.setattr(
+ "src.local_deep_research.web.auth.routes.load_server_config",
+ mock_load_config,
+ )
+
+ response = client.post(
+ "/auth/register",
+ data={
+ "username": "testuser_blocked",
+ "password": "testpassword123",
+ "confirm_password": "testpassword123",
+ "acknowledge": "true",
+ },
+ follow_redirects=False,
+ )
+
+ assert response.status_code == 302
+ assert "/auth/login" in response.location
+
+ # Check no user was created
+ auth_db = get_auth_db_session()
+ user = (
+ auth_db.query(User).filter_by(username="testuser_blocked").first()
+ )
+ assert user is None
+ auth_db.close()