Optional "Sign in with Google" with auto-provisioning, fully config-gated: without GOOGLE_CLIENT_ID/SECRET and OAUTH_REDIRECT_URL the routes 404 and the button is hidden, so deployments without SSO are unaffected. - migration 028: users.google_sub (unique) + email; password_hash nullable for OAuth-only accounts - src/auth/google-oauth.js: lazy google-auth-library, ID-token verify, GOOGLE_ALLOWED_DOMAIN enforcement, requires email_verified === true - auth routes: /auth/google (state-CSRF redirect), /auth/google/callback, /auth/google/enabled; reuses establishSession - web-ui: "Sign in with Google" on the login screen (shown only when enabled), friendly callback error handling - .env.example documents all new vars Security hardening (from review of this + the TOTP work): - resolveGoogleUser links ONLY by google_sub, never by email — a Google login can never seize a pre-existing local account (account-takeover fix) - a Google-linked account with TOTP still requires the second factor (ticket in session, /?mfa=1 step) instead of bypassing it - /login/totp now applies the per-IP login backoff - recovery-code consumption is atomic (WHERE used_at IS NULL + rowCount) - concurrent first-login race on google_sub is caught and re-resolved - tests: google-oauth config helpers + google-link takeover/dedup regression Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
65 lines
2.8 KiB
Text
65 lines
2.8 KiB
Text
# Database Configuration
|
|
POSTGRES_DB=wilddragon
|
|
POSTGRES_USER=wilddragon
|
|
POSTGRES_PASSWORD=changeme
|
|
|
|
# Database Connection
|
|
DATABASE_URL=postgres://wilddragon:changeme@db:5432/wilddragon
|
|
|
|
# Redis Configuration
|
|
REDIS_URL=redis://queue:6379
|
|
|
|
# S3 Configuration
|
|
S3_ENDPOINT=https://broadcastmgmt.cloud
|
|
S3_BUCKET=wild-dragon
|
|
S3_ACCESS_KEY=changeme
|
|
S3_SECRET_KEY=changeme
|
|
S3_REGION=us-east-1
|
|
|
|
# Session Configuration
|
|
SESSION_SECRET=changeme
|
|
|
|
# MAM API Configuration
|
|
MAM_API_URL=http://mam-api:3000
|
|
|
|
# Auth — default to ON in production. Setting to 'false' is a dev-only escape
|
|
# hatch that disables all auth checks and attaches a synthetic 'dev' user to
|
|
# every request. Never run with AUTH_ENABLED=false on a network you don't control.
|
|
#
|
|
# RBAC v2 note: with AUTH_ENABLED=true, per-project access is enforced. Service
|
|
# API tokens (capture sidecar, Premiere panel, integrations) must belong to a
|
|
# user with the access they need — an 'admin' user (full access), or a user with
|
|
# the right project grants. A non-admin service token with no grants will get
|
|
# 403 on asset registration (ingest) and streaming. In dev mode the synthetic
|
|
# user is admin, so this only matters once auth is on.
|
|
AUTH_ENABLED=true
|
|
|
|
# CORS allowlist — comma-separated origins that may carry credentials to the API.
|
|
# Same-origin requests via the nginx reverse proxy do not need to be listed here.
|
|
# Leave empty to allow any origin (DEV ONLY).
|
|
ALLOWED_ORIGINS=
|
|
|
|
# Reverse-proxy trust — set 'true' when the API sits behind nginx terminating HTTPS,
|
|
# so secure-cookie + X-Forwarded-Proto behave correctly. ALSO required for accurate
|
|
# per-IP login rate-limiting (otherwise req.ip is always the nginx IP).
|
|
TRUST_PROXY=false
|
|
|
|
# Google OAuth (OIDC) sign-in — OPTIONAL. Leave the client id/secret blank to
|
|
# disable; the "Sign in with Google" button and the /auth/google routes only
|
|
# activate when all three of CLIENT_ID, CLIENT_SECRET, and REDIRECT_URL are set.
|
|
# Create an OAuth 2.0 Client (type: Web application) in Google Cloud Console and
|
|
# add OAUTH_REDIRECT_URL to its authorized redirect URIs.
|
|
GOOGLE_CLIENT_ID=
|
|
GOOGLE_CLIENT_SECRET=
|
|
# Must exactly match a redirect URI on the OAuth client, e.g.
|
|
# https://dragonflight.live/api/v1/auth/google/callback
|
|
OAUTH_REDIRECT_URL=
|
|
# Restrict sign-in to one Google Workspace domain (recommended). First login from
|
|
# an allowed-domain account auto-provisions a NEW 'viewer' account (matched only
|
|
# by Google's stable subject id, never by email — so a Google login can never
|
|
# seize a pre-existing local account). An admin then grants project access.
|
|
# Leave blank to allow any verified Google account to self-provision (NOT advised).
|
|
GOOGLE_ALLOWED_DOMAIN=
|
|
# Note: if a Google-linked account also has TOTP enabled, sign-in still requires
|
|
# the authenticator code (Google is treated as the first factor). Accounts without
|
|
# TOTP complete sign-in in one Google step.
|