Echo

Authentication Setup

Configure user authentication with Better Auth, including OAuth providers

Overview

Echo uses Better Auth for authentication

By default, authentication is optional - you can access the admin panel without logging in during development.

Development Mode:

Set DISABLE_AUTH=true in your .env.local to access admin without authentication.

Configuration

Set up authentication for production

Production Mode

In production, authentication is required. Add these to your environment variables:

# Generate a secure secret:
openssl rand -base64 32
# Add to .env.local:
DISABLE_AUTH=false
BETTER_AUTH_SECRET=your-very-secret-random-string
SITE_URL=https://yourdomain.com

Google OAuth Setup

Allow users to sign in with Google

  1. Go to Google Cloud Console
  2. Create or select a project
  3. Enable Google+ API
  4. Go to CredentialsCreate CredentialsOAuth client ID
  5. Configure OAuth consent screen
  6. Add redirect URI: http://localhost:3000/api/auth/callback/google
  7. Copy credentials to .env.local
GOOGLE_CLIENT_ID=xxx.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-...

GitHub OAuth Setup

Allow users to sign in with GitHub

  1. Go to GitHub → SettingsDeveloper settingsOAuth Apps
  2. Click New OAuth App
  3. Fill in:
    • Application name: Echo Website
    • Homepage URL: http://localhost:3000
    • Authorization callback URL: http://localhost:3000/api/auth/callback/github
  4. Click Register application
  5. Copy credentials to .env.local
GITHUB_CLIENT_ID=...
GITHUB_CLIENT_SECRET=...

User Roles

Admin and user roles

Admin Role

Claim admin access using the admin claim code:

  1. Sign in to your account
  2. Go to /admin/claim
  3. Enter your admin claim code
  4. Your role will be upgraded to admin

User Profile

User profiles are automatically created with fields: userId, displayName, role, avatarUrl, and subscription fields.

Security Best Practices

  • Never commit secrets to version control
  • Use strong BETTER_AUTH_SECRET (32+ characters)
  • Rotate secrets regularly (every 3-6 months)
  • Use HTTPS in production
  • Validate user input on server-side