fix(oidc): reject an unrecognized boolean instead of guessing

_env_bool returned the default for anything outside {true,1,yes}, so
BAMBUDDY_OIDC_REQUIRE_EMAIL_VERIFIED=on silently read as OFF and
BAMBUDDY_OIDC_ENABLED=on silently disabled the provider -- the exact
opposite of what .env.example claimed. Unrecognized values now raise
EnvOIDCConfigError, caught in _apply_env_oidc_provider the same way a
bad DEFAULT_GROUP or a ValidationError already is: logged and left
running, never released on a typo.

Also promotes _env_bool to env_bool now that it has a call site in
auth.py, and corrects the boolean-parsing sentence in .env.example.
This commit is contained in:
Marian
2026-08-01 09:17:33 +00:00
parent c547505c64
commit 77c9bdd694
5 changed files with 128 additions and 16 deletions
+2 -2
View File
@@ -35,7 +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.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
@@ -123,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 _env_bool("BAMBUDDY_LOCAL_LOGIN", False)
return env_bool("BAMBUDDY_LOCAL_LOGIN", False)
def _get_client_ip(request: Request) -> str: