Skip to content

Optional reverse-proxy (forward-auth) authentication mode#2

Open
lucas19919 wants to merge 1 commit into
mainfrom
feat/proxy-forward-auth
Open

Optional reverse-proxy (forward-auth) authentication mode#2
lucas19919 wants to merge 1 commit into
mainfrom
feat/proxy-forward-auth

Conversation

@lucas19919

Copy link
Copy Markdown
Owner

Adds an optional AUTH_MODE=proxy that delegates authentication to an authenticating reverse proxy in front of OpenLeads, so the app can sit behind SSO/MFA without implementing OAuth itself. Works with any forward-auth proxy (Authelia, Authentik, oauth2-proxy, Pomerium, Cloudflare Access, …).

Behaviour

  • AUTH_MODE=password (default) — unchanged: the built-in login form + local accounts.
  • AUTH_MODE=proxy — trusts the identity the proxy forwards in headers:
    • reads the username (and optional groups) from configurable headers,
    • verifies a shared-secret header so a caller bypassing the proxy can't forge an identity (warns at boot if unset),
    • provisions the user on first sight (no signup, no password), and
    • maps a configurable group → admin role, re-synced each request.
    • The login form is disabled; logout redirects to the configured IdP sign-out URL.

No cookie/session in proxy mode — the proxy owns the session; identity is re-read per request.

Config

All new vars are documented in api/.env.example and docs/SETUP.md, and default to the widely-used X-Forwarded-* header set. Nothing is tied to a specific proxy.

Tests

New api/src/proxyAuth.test.ts (7 cases: secret enforcement, JIT provisioning, group→role mapping, role re-sync, password-login disabled for provisioned users). Full suite green (145/145); web typechecks clean.

🤖 Generated with Claude Code

Add AUTH_MODE=proxy to delegate authentication to an authenticating
reverse proxy in front of OpenLeads (Authelia, Authentik, oauth2-proxy,
Pomerium, Cloudflare Access, ...). It reads the user and optional groups
from configurable headers, verifies a shared-secret header to prevent
spoofing, provisions the user on first sight (no password), and maps a
group to the admin role. The built-in login form is disabled in this mode.

Default stays AUTH_MODE=password, so existing installs are unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@lucas19919
lucas19919 force-pushed the feat/proxy-forward-auth branch from 64845f9 to 15d6025 Compare July 25, 2026 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant