EqualifyEverything / equalify-reflow

feat(auth): optional viewer auth layer (PR1: none + basic + scaffold)
Adds a pluggable, optional authentication layer for the viewer. The OSS default (AUTH_MODE=none) preserves today's open behaviour exactly. When operators flip AUTH_MODE=basic, the viewer requires username/password login, and the session cookie short-circuits the existing API key middleware. API keys remain a parallel auth path for programmatic clients regardless of mode. Backend - src/auth/ — AuthMode/Identity/Provider Protocol; NoneAuthProvider, BasicAuthProvider (argon2id); SessionAuthMiddleware with sliding-window cookie re-issue; signed-cookie session via itsdangerous; double-submit CSRF; structured auth_event audit logger; /api/v1/auth/{config,login,logout,me} router; CLI helper for hashing passwords. - src/config.py — adds AUTH_* fields with a model_validator that fails fast at startup when per-mode env is missing or malformed. - src/main.py — wires SessionAuthMiddleware conditionally and registers cookieAuth alongside APIKeyHeader in custom_openapi(). - src/middleware/api_key_auth.py — short-circuits when request.state.identity is set; gates the same-origin shortcut on AUTH_MODE=none so it cannot silently defeat the new gate. - src/middleware/logging_middleware.py — adds user_sub/email/provider fields to response logs when an identity is present. - src/services/session_store.py + src/api/pipeline_viewer.py — pipeline sessions now carry identity_sub/provider_id; SSE session event payload surfaces the user. Viewer - clients/viewer/src/auth/ — AuthContext + apiFetch + LoginPage + CallbackPage + RequireAuth. - viewer-main.tsx wraps routes in <AuthProvider>; six fetch sites migrated to apiFetch (handles credentials, CSRF echo, 401 redirect). OIDC / SSO landing in PR2 — generic OIDCAuthProvider with Microsoft Entra as a config preset; scaffolding (config schema, route shape, viewer LoginPage rendering) is in place from this PR. Tests - 21 unit + 11 integration tests; full unit suite (553) passes; no regressions in existing api_key_auth or middleware tests. Docs - New docs/how-to/enable-basic-auth.md. - Extended docs/reference/authentication.md and docs/explanation/authentication-design.md. - AGENTS.md gains a workflows row. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Blake Bertuccelli-Booth Blake Bertuccelli-Booth committed on May 7, 2026, 05:06 PM
Showing 46 changed files +2377 additions -46 deletions
M AGENTS.md +1
M Makefile +8
M src/config.py +92 -1
M src/main.py +22 -5
M uv.lock +47 -1
Browse files at this commit →