united-tattoo/.env.example
Nicholai 0d38f81e2c feat(auth): implement custom Nextcloud OAuth with auto-provisioning
Replaced NextAuth's built-in OAuth provider (incompatible with Cloudflare
Workers) with custom OAuth implementation using native fetch API.

Features:
- Custom OAuth flow compatible with Cloudflare Workers edge runtime
- Auto-provisions users from Nextcloud based on group membership
- Group-based role assignment (artists, shop_admins, admins)
- Auto-creates artist profiles for users in 'artists' group
- Seamless integration with existing NextAuth session management

Technical changes:
- Added custom OAuth routes: /api/auth/nextcloud/authorize & callback
- Created Nextcloud API client for user provisioning (lib/nextcloud-client.ts)
- Extended credentials provider to accept Nextcloud one-time tokens
- Added user management functions to database layer
- Updated signin UI to use custom OAuth flow
- Added environment variables for OAuth configuration

Documentation:
- Comprehensive setup guide in docs/NEXTCLOUD-OAUTH-SETUP.md
- Updated CLAUDE.md with new authentication architecture

Fixes: NextAuth OAuth incompatibility with Cloudflare Workers (unenv https.request error)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-23 02:06:14 +00:00

63 lines
2.0 KiB
Plaintext

# Database Configuration
# Use Supabase or Neon PostgreSQL database URL
DATABASE_URL="postgresql://username:password@hostname:port/database"
DIRECT_URL="postgresql://username:password@hostname:port/database"
# Authentication Configuration
# NextAuth.js configuration
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-nextauth-secret-key-here"
# OAuth Providers (Optional)
# Google OAuth
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"
# GitHub OAuth
GITHUB_CLIENT_ID="your-github-client-id"
GITHUB_CLIENT_SECRET="your-github-client-secret"
# Nextcloud Configuration
# Nextcloud instance base URL
NEXTCLOUD_BASE_URL="https://portal.united-tattoos.com"
# Nextcloud CalDAV Integration (Optional)
# Service account credentials for calendar sync
NEXTCLOUD_USERNAME="your-nextcloud-service-account"
NEXTCLOUD_PASSWORD="your-nextcloud-app-password"
NEXTCLOUD_CALENDAR_BASE_PATH="/remote.php/dav/calendars"
# Nextcloud OAuth Authentication
# OAuth app credentials for artist authentication
NEXTCLOUD_OAUTH_CLIENT_ID="your-nextcloud-oauth-client-id"
NEXTCLOUD_OAUTH_CLIENT_SECRET="your-nextcloud-oauth-client-secret"
# Nextcloud group name for auto-provisioning artists (default: "artists")
NEXTCLOUD_ARTISTS_GROUP="artists"
# Nextcloud group name for shop admins (default: "shop_admins")
NEXTCLOUD_ADMINS_GROUP="shop_admins"
# File Storage Configuration
# AWS S3 or Cloudflare R2 for file uploads
AWS_ACCESS_KEY_ID="your-aws-access-key-id"
AWS_SECRET_ACCESS_KEY="your-aws-secret-access-key"
AWS_REGION="us-east-1"
AWS_BUCKET_NAME="your-bucket-name"
# For Cloudflare R2, uncomment and set the endpoint URL
# AWS_ENDPOINT_URL="https://your-account-id.r2.cloudflarestorage.com"
# Application Environment
NODE_ENV="development"
# Email Service Configuration (Optional)
# SMTP configuration for sending emails
SMTP_HOST="smtp.gmail.com"
SMTP_PORT="587"
SMTP_USER="your-email@gmail.com"
SMTP_PASSWORD="your-app-password"
# Analytics (Optional)
# Vercel Analytics ID
VERCEL_ANALYTICS_ID="your-vercel-analytics-id"