From an audit of the Authentik login, run against a fake OIDC provider: - Session fixation: the session id wasn't changed at sign-in, so one planted beforehand (from another page on the domain) became signed in as the victim. It is regenerated now. - Requests from another origin: SameSite=Lax doesn't stop another app on the same parent domain, and a body-less POST (stop a guest, rotate a token) needs no preflight. Every POST/PUT/PATCH/DELETE, and GET /auth/logout, is refused when Sec-Fetch-Site (or, for older browsers, Origin) says it came from elsewhere. The agent endpoint is exempt: it uses a token. - ID token signature: openid-client checks a token's claims but, as OIDC allows for a token from the token endpoint, not its signature, so the login rested on HTTPS to Authentik alone. The signature is now verified against the provider's published keys (jose, now a declared dependency). - SESSION_SECRET: production refuses to start without one (the fallback is in the source code) and warns when it is the .env.example placeholder or short. - Response headers: frame-ancestors 'none', X-Frame-Options, nosniff, Referrer-Policy; the framework name is no longer sent. - A failed sign-in shows a plain page and is audited (session / login_failed, with address and reason, no tokens); sign-in is limited to 20 attempts a minute per address so the audit log and session store can't be flooded. - A failed OIDC discovery (provider down at the first sign-in) was remembered until restart; it is retried now. Tests run the real app against the fake provider; switching each fix off in turn makes the matching tests fail. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
35 lines
1.7 KiB
Bash
35 lines
1.7 KiB
Bash
# Public URL the app is reachable at (used for OIDC redirect_uri and cookie behavior).
|
|
APP_BASE_URL=https://homelab.example.lan
|
|
|
|
# Random long string used to sign session cookies. Generate with:
|
|
# node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
|
|
# Required in production: without it the app refuses to start (the alternative is a value that is
|
|
# in the source code). Changing it signs everyone out.
|
|
SESSION_SECRET=change-me-to-a-random-64-char-hex-string
|
|
|
|
# 32-byte (64 hex char) key used to encrypt stored integration API tokens, and the
|
|
# notification channels' credentials (Gotify/ntfy tokens, SMTP password, webhook
|
|
# secret), at rest (AES-256-GCM). Generate the same way as SESSION_SECRET.
|
|
# Losing/changing this key makes those stored credentials unreadable.
|
|
CREDENTIALS_ENCRYPTION_KEY=change-me-to-a-random-64-char-hex-string
|
|
|
|
# Port docker-compose publishes on the host (container always listens on 3000).
|
|
HOST_PORT=3000
|
|
|
|
# Optional, for the arm64 compose files (docker-compose.arm64*.yml): registry image and tag.
|
|
#IMAGE_REPO=gitea.labsconnect.se/bobban/homelabmanager-homelab-manager
|
|
#ARM64_TAG=arm64
|
|
|
|
# --- Authentik OIDC application/provider ---
|
|
# Create an OAuth2/OIDC "Provider" in Authentik with:
|
|
# Redirect URI: <APP_BASE_URL>/auth/callback
|
|
# Scopes: openid, email, profile
|
|
# then create an "Application" using that provider, and assign the users/groups
|
|
# who should be able to sign in. Copy the provider's values below.
|
|
AUTHENTIK_ISSUER_URL=https://authentik.example.lan/application/o/homelab-manager/
|
|
AUTHENTIK_CLIENT_ID=
|
|
AUTHENTIK_CLIENT_SECRET=
|
|
|
|
# Notification channels (Gotify, ntfy, SMTP, webhook) are configured in-app
|
|
# under Settings, not here.
|