Handle missing SECRET in auth flow
Lint / Lint (push) Successful in 44s
Tests / Go backend (push) Successful in 39s
Docker / Docker Build & Push (push) Successful in 3m30s
Tests / Dashboard checks (push) Successful in 46s

This commit is contained in:
Gabriel20xx committed 2026-09-15 23:27:42 +02:00
1 parent 07e25a3cf3
commit eb67f251d8
4 files changed
+43 -7

No files matched your search

@@ -92,6 +92,7 @@ ERR_FEATURE_REQUIRES_AUTHGUARD = "This feature requires AUTHGUARD_URL to be conf
# never this error - so every caller can safely report this same message
# rather than a generic "internal error" indistinguishable from any other bug.
ERR_AUTHGUARD_UNAVAILABLE = "Unable to reach the authentication service. Please try again shortly."
ERR_SECRET_NOT_SET = "SECRET environment variable is not set."
# _LOCAL_PROFILE is the fixed placeholder identity every handler reports when
# auth is disabled (get_client(request) returns None, i.e. AUTHGUARD_URL was
@@ -242,6 +243,7 @@ def build_auth_router(
legacy_cookie_name: str = "",
secure_cookie: bool = False,
cookie_name: str = DEFAULT_COOKIE_NAME,
configuration_error: str | None = None,
) -> APIRouter:
"""Builds a ready-to-mount APIRouter implementing the full standardized
AuthGuard-proxy surface (no prefix baked in - mount it at "/api/auth",
@@ -250,6 +252,10 @@ def build_auth_router(
router = APIRouter()
def _ensure_configured() -> None:
if configuration_error:
raise HTTPException(status_code=500, detail=configuration_error)
def _enabled(client: Optional[AuthClient]) -> bool:
return client is not None
@@ -328,6 +334,7 @@ def build_auth_router(
store: ProxyStore = Depends(get_store), # noqa: B008
client: Optional[AuthClient] = Depends(get_client), # noqa: B008
) -> dict[str, Any]:
_ensure_configured()
login_required = await store.login_required()
if not _enabled(client):
return {"user": _user_payload(_LOCAL_PROFILE), "authRequired": login_required}
@@ -363,6 +370,7 @@ def build_auth_router(
store: ProxyStore = Depends(get_store), # noqa: B008
client: Optional[AuthClient] = Depends(get_client), # noqa: B008
) -> dict[str, Any]:
_ensure_configured()
if not _enabled(client):
return {
"setupRequired": False,