Skip to content

Nube Auth is configured through environment variables and SDK options.

SDK Configuration

typescript
import { NubeAuthClient } from '@nube-auth/sdk';

const nubeAuth = new NubeAuthClient({
  // Required
  appId: 'your-app-id',
  
  // API URL (defaults to hosted Nube Auth)
  apiUrl: 'https://api.nubeauth.com',
  
  // Optional: Custom redirect URI
  redirectUri: 'https://yourapp.com/auth/callback',
  
  // Optional: Storage for tokens (defaults to localStorage)
  storage: localStorage,
});

Environment Variables

For self-hosted deployments, configure these environment variables:

Core Settings

bash
# Application
NODE_ENV=production
PORT=3001

# Database
DATABASE_URL=postgresql://user:password@localhost:5432/nube-auth

# Redis
REDIS_URL=redis://localhost:6379

Authentication

bash
# JWT secrets (generate secure random strings)
JWT_SECRET=your-jwt-secret
SESSION_SECRET=your-session-secret

# OAuth: Google
GOOGLE_CLIENT_ID=your-client-id
GOOGLE_CLIENT_SECRET=your-client-secret

# OAuth: GitHub
GITHUB_CLIENT_ID=your-client-id
GITHUB_CLIENT_SECRET=your-client-secret

Session Settings

bash
# Session duration (seconds)
SESSION_TTL=31536000  # 365 days

# Rolling session extension
SESSION_ROLLING=true
SESSION_ROLLING_TTL=86400  # 1 day

OAuth Provider Setup

Google

  1. Go to Google Cloud Console
  2. Create OAuth 2.0 credentials
  3. Add authorized redirect URI: https://your-domain/auth/callback/google
  4. Set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET

GitHub

  1. Go to GitHub Developer Settings
  2. Create a new OAuth App
  3. Set callback URL: https://your-domain/auth/callback/github
  4. Set GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET

Next Steps

Released under the MIT License.