From be19461470e2f12a98c6f1f470fdd01c34bbe6c1 Mon Sep 17 00:00:00 2001 From: Marian Date: Fri, 31 Jul 2026 13:12:44 +0000 Subject: [PATCH] refactor(auth): reuse oidc_env's truthy-bool helper for BAMBUDDY_LOCAL_LOGIN _local_login_env_bypass() re-inlined the same {"true", "1", "yes"} set oidc_env._env_bool already enforces, so the typo-guard existed in two places. oidc_env has no module-scope import of models (its model imports are lazy inside apply_env_oidc_provider), so importing _env_bool at module scope here is not a cycle -- confirmed by importing backend.app.main and this module directly. --- backend/app/api/routes/auth.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/app/api/routes/auth.py b/backend/app/api/routes/auth.py index d72ecc384..9e4e0fa43 100644 --- a/backend/app/api/routes/auth.py +++ b/backend/app/api/routes/auth.py @@ -35,6 +35,7 @@ from backend.app.core.auth import ( security, ) from backend.app.core.database import async_session, get_db +from backend.app.core.oidc_env import _env_bool from backend.app.core.permissions import ALL_PERMISSIONS from backend.app.models.auth_ephemeral import AuthEphemeralToken, AuthRateLimitEvent, EventType, TokenType from backend.app.models.group import Group @@ -122,7 +123,7 @@ def _local_login_env_bypass() -> bool: an install whose SSO provider is unreachable. Accepted truthy values: ``true``, ``1``, ``yes`` (case-insensitive). """ - return os.environ.get("BAMBUDDY_LOCAL_LOGIN", "").strip().lower() in {"true", "1", "yes"} + return _env_bool("BAMBUDDY_LOCAL_LOGIN", False) def _get_client_ip(request: Request) -> str: