Files
evig/.env.example
CatoandClaude Fable 5.1 bbd25803b6 feat(auth): "Sign in with OrangeCat" beside the password login; connect from the profile (#523)
* feat(auth): "Sign in with OrangeCat" beside the password login; connect from the profile

Step D8 of orangecat ADR-0009 ("One account for every door"). evig keeps its
own accounts — staff grants, orders and memberships live here — and lets an
account BE an OrangeCat account by carrying the actor id.

- /auth/login: "Mit OrangeCat anmelden" beside the password form, shown only
  when Auth.js actually mounted the provider (the form asks /api/auth/providers),
  so the button can never be a dead end.
- users.orangecat_actor_id (migration 141, unique): the ONLY cross-product
  key. Never email — OrangeCat's password sign-up does not verify the address,
  so an email match would let anyone who registers the victim's address there
  walk in here. src/lib/auth/orangecat.ts holds the rules, pure and tested:
  a linked actor signs in; a new person gets an account (email unverified,
  like a fresh password registration); an existing unlinked account with that
  email is refused with a message that names the way forward.
- That way forward: "OrangeCat verbinden" on the profile. POST /api/user/orangecat
  mints a signed ten-minute cookie for the signed-in user; the sign-in callback
  reads it and attaches the OrangeCat identity to THAT account and no other.
- Staff is untouched: is_staff stays the sole grant, whatever the sign-in.

Provider config mirrors Solon/Heidi/Loki (client_secret_post, PKCE + state,
openid profile email). Env pair documented in .env.example; the client is
registered on the OrangeCat box with scripts/oauth/register-client.ts.

Verified: the pure module typechecks and its 10 tests pass; prettier and
lint:umlauts clean. A full tsc/lint run was not possible in the sandbox (the
ai-forms GitHub tarball is blocked there); CI is the gate.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QDMxjTqKNLXETMYYuapMa3

* fix(auth): typecheck and docs-path check for the OrangeCat sign-in

- OrangeCatSection: apiFetch may resolve undefined; fall back to the
  hidden state instead of passing undefined to setState (CI tsc).
- CLAUDE.md: name orangecat's ADR-0009 without a path the docs-paths
  checker reads as local.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QDMxjTqKNLXETMYYuapMa3

* fix(auth): OrangeCat section reads the apiFetch envelope; strings in every locale

- apiFetch resolves { success, data?, error? }; the section typed the payload
  as the envelope (CI tsc). Read data on success, treat a refused link intent
  as an error instead of starting the round-trip anyway.
- The nine new strings translated into fr, it, es, ru, ja, ko so the i18n
  audit's baseline stays where it is.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QDMxjTqKNLXETMYYuapMa3

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-29 03:42:06 -07:00

182 lines
6.1 KiB
Bash

# Frontend Environment Configuration
# ====================
# REQUIRED VARIABLES
# ====================
# Admin Authentication (REQUIRED)
# JWT secret for admin session tokens - use a long random string
JWT_SECRET=your_jwt_secret_min_32_characters_long
# Auth.js secret - required for session encryption
AUTH_SECRET=your_auth_secret_min_32_characters_long
# "Sign in with OrangeCat" (orangecat ADR-0009, D8). OrangeCat is the fleet's
# identity root; with this pair set, /auth/login shows the button and the
# profile page offers "Connect OrangeCat". Register the client on the
# OrangeCat box: scripts/oauth/register-client.ts --client evig, redirect
# https://evig.orangecat.ch/api/auth/callback/orangecat. Leave unset to hide.
# ORANGECAT_OAUTH_ISSUER=https://orangecat.ch
# ORANGECAT_OAUTH_CLIENT_ID=evig
# ORANGECAT_OAUTH_CLIENT_SECRET=
# Admin password configuration
# --------------------------
# DEVELOPMENT: Use plain text password (NOT secure, dev only!)
# ADMIN_PASSWORD=your_dev_password
#
# PRODUCTION: Use bcrypt hash (REQUIRED for NODE_ENV=production)
# Generate with: npx bcrypt-cli hash "your-password" 12
# Or: node -e "require('bcrypt').hash('your-password', 12).then(console.log)"
#
# Example bcrypt hash format: $2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4Bq4z.4AqGwq.2Ym
ADMIN_PASSWORD_HASH=
# ====================
# API CONFIGURATION
# ====================
# Content Management System API URL
NEXT_PUBLIC_REBOOT_CONTENT_URL=http://localhost:3001
# CMS API authentication token
REBOOT_CONTENT_TOKEN=your_cms_api_token
# Public site configuration
NEXT_PUBLIC_API_URL=http://localhost:3001
NEXT_PUBLIC_SITE_URL=http://localhost:3000
# ====================
# EMAIL CONFIGURATION (Required for Auth Emails)
# ====================
# IMPORTANT: Email is REQUIRED for user registration, password reset, and verification.
# Choose ONE of the two options below:
# Option 1: SMTP (Recommended for Production)
# -----------------------------------------
# Works with Gmail, SendGrid, AWS SES, Postmark, etc.
# For Gmail: Use App Password (https://support.google.com/accounts/answer/185833)
# For SendGrid: Use API key as password with username "apikey"
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_SECURE=false
EMAIL_USER=your-email@gmail.com
EMAIL_PASS=your-app-password-or-api-key
EMAIL_FROM=noreply@revamp-it.ch
# Option 2: Listmonk (FOSS Alternative)
# -----------------------------------------
# Open-source newsletter + transactional email platform
# Install: https://listmonk.app/docs/installation/
# Uncomment below if using Listmonk instead of SMTP
# LISTMONK_ENABLED=true
# LISTMONK_URL=http://localhost:9090
# LISTMONK_USERNAME=admin
# LISTMONK_PASSWORD=your-listmonk-password
# LISTMONK_FROM_EMAIL=noreply@revamp-it.ch
# LISTMONK_FROM_NAME=RevampIT
# ====================
# DATABASE (Optional)
# ====================
# Database connection string (if needed by frontend)
# Local dev (Docker): postgresql://postgres:postgres@localhost:5433/revampit_cms
# DATABASE_URL=postgresql://postgres:your_password@localhost:5433/revampit_cms
# ====================
# TINACMS (Optional)
# ====================
# TinaCMS configuration - only needed if using TinaCMS
# NEXT_PUBLIC_TINA_CLIENT_ID=your_tina_client_id
# TINA_TOKEN=your_tina_token
# ====================
# ANALYTICS (Optional)
# ====================
# Google Analytics tracking ID
# NEXT_PUBLIC_GA_ID=your_google_analytics_id
# ====================
# SITE METADATA
# ====================
NEXT_PUBLIC_SITE_NAME=RevampIT
NEXT_PUBLIC_SITE_DESCRIPTION=Sustainable Technology for Everyone
# ====================
# AI SERVICES (Optional)
# ====================
# Groq API key (REQUIRED for Hirn AI and AI Produkterfassung)
# Get free key at: https://console.groq.com
GROQ_API_KEY=gsk_xxx
# Transcription service URL (local Whisper)
# Start with: npm run transcription:start
TRANSCRIPTION_URL=http://localhost:5111
# Ollama URL (local LLM - for local embeddings only)
OLLAMA_URL=http://localhost:11434
OLLAMA_MODEL=llama3.2
# ====================
# PAYMENT PROCESSING (Optional)
# ====================
# Payrexx payment gateway (Swiss payment provider)
# Required for marketplace orders and service bookings
# Get credentials at: https://www.payrexx.com
# PAYREXX_INSTANCE=your_instance_name
# PAYREXX_API_SECRET=your_api_secret
# PAYREXX_WEBHOOK_SECRET=your_webhook_secret
# ====================
# FILE STORAGE (Production)
# ====================
# S3-compatible object storage (Hetzner Object Storage) — REQUIRED for
# production image/document uploads. Falls back to local-fs when unset (dev).
# S3_ENDPOINT=https://fsn1.your-objectstorage.com
# S3_REGION=fsn1
# S3_BUCKET=revampit-media
# S3_ACCESS_KEY_ID=your_access_key
# S3_SECRET_ACCESS_KEY=your_secret_key
# S3_PUBLIC_URL=https://media.revampit.orangecat.ch
# S3_FORCE_PATH_STYLE=true
# ====================
# ENVIRONMENT
# ====================
# NODE_ENV is automatically set by Next.js (development, production, test)
# NODE_ENV=development
# ====================
# KIVVI ERP INTEGRATION
# ====================
# Connects RevampIT to Kivvi for inventory records, invoicing, and accounting.
# Without these vars the integration is silently skipped (safe for local dev).
# KIVVI_API_URL=https://kivvi.orangecat.ch
# KIVVI_API_TOKEN=kv_...
# KIVVI_DEFAULT_WAREHOUSE_ID=<warehouse-uuid-from-kivvi-settings>
# Shared secret for the REVERSE sync — Kivvi signs each inbound item-change
# webhook (POST /api/webhooks/kivvi) with a hex HMAC-SHA256 of the raw body in
# the X-Kivvi-Signature header. Must match the endpoint secret configured in
# Kivvi. Unset → the receiver fails closed (rejects all webhooks).
# KIVVI_WEBHOOK_SECRET=<shared-secret-from-kivvi-webhook-settings>
# ====================
# E2E TEST ACCOUNTS
# ====================
# Comma-separated list of account emails whose requests skip the abuse rate
# limits during the prod dual-persona smoke (scripts/e2e-inventory-prod.sh).
# Read by src/config/e2e-test-accounts.ts. Server-only — never NEXT_PUBLIC_.
# UNSET IS THE SAFE DEFAULT: an empty list exempts nobody. Set it only on the
# environment that actually runs the smoke, and only to accounts you control.
# E2E_TEST_ACCOUNT_EMAILS=persona.one@example.com,persona.two@example.org