feat: add OIDC/SSO authentication (#3)

Add OpenID Connect (OIDC) authentication alongside existing
username/password login. Users can log in via any standards-compliant
OIDC provider (Keycloak, Authentik, Authelia, Google, Azure AD, Okta)
while preserving full backward compatibility.

- OIDC Fastify plugin with lazy discovery, PKCE, cookie-based sessions
- Login page OIDC button, auth hook updates, settings dialog badges
- 28 integration tests, OIDC setup guide with provider examples
- Fix pre-existing test failures (content-aware-crop, watermark, SVGZ)
- WAL checkpoint fix for SQLite test stability

Closes #3

# Conflicts:
#	apps/api/src/lib/env.ts
#	apps/api/src/routes/tools/watermark-image.ts
#	pnpm-lock.yaml
#	tests/integration/color-palette.test.ts
#	tests/integration/compare.test.ts
#	tests/integration/watermark-image.test.ts
This commit is contained in:
SnapOtter
2026-05-14 22:31:26 +08:00
32 changed files with 3503 additions and 149 deletions
+4 -1
View File
@@ -273,7 +273,10 @@ ENV PORT=1349 \
SESSION_DURATION_HOURS=168 \
LOGIN_ATTEMPT_LIMIT=500 \
LOG_LEVEL=info \
TRUST_PROXY=true
TRUST_PROXY=true \
OIDC_ENABLED=false \
EXTERNAL_URL= \
COOKIE_SECRET=
# NVIDIA Container Toolkit env vars (harmless on non-GPU systems)
ENV NVIDIA_VISIBLE_DEVICES=all \
+14
View File
@@ -37,6 +37,20 @@ services:
- MAX_USERS=${MAX_USERS:-0}
- SESSION_DURATION_HOURS=${SESSION_DURATION_HOURS:-168}
- TRUST_PROXY=${TRUST_PROXY:-true}
# OIDC Authentication (optional)
# - EXTERNAL_URL=https://photos.example.com
# - OIDC_ENABLED=false
# - OIDC_ISSUER_URL=
# - OIDC_CLIENT_ID=
# - OIDC_CLIENT_SECRET=
# - OIDC_SCOPES=openid profile email
# - OIDC_AUTO_CREATE_USERS=true
# - OIDC_DEFAULT_ROLE=user
# - OIDC_AUTO_LINK_USERS=false
# - OIDC_PROVIDER_NAME=
# - OIDC_USERNAME_CLAIM=preferred_username
# - OIDC_CLOCK_TOLERANCE=30
# - COOKIE_SECRET=
restart: unless-stopped
# --- Security hardening ---
mem_limit: 8g
+14
View File
@@ -36,6 +36,20 @@ services:
- MAX_USERS=${MAX_USERS:-0}
- SESSION_DURATION_HOURS=${SESSION_DURATION_HOURS:-168}
- TRUST_PROXY=${TRUST_PROXY:-true}
# OIDC Authentication (optional)
# - EXTERNAL_URL=https://photos.example.com
# - OIDC_ENABLED=false
# - OIDC_ISSUER_URL=
# - OIDC_CLIENT_ID=
# - OIDC_CLIENT_SECRET=
# - OIDC_SCOPES=openid profile email
# - OIDC_AUTO_CREATE_USERS=true
# - OIDC_DEFAULT_ROLE=user
# - OIDC_AUTO_LINK_USERS=false
# - OIDC_PROVIDER_NAME=
# - OIDC_USERNAME_CLAIM=preferred_username
# - OIDC_CLOCK_TOLERANCE=30
# - COOKIE_SECRET=
restart: unless-stopped
# --- Security hardening ---
mem_limit: 4g