Integrations
UniAuth connects with external services for email delivery, SMS, social login providers, event notifications, user provisioning, and caching. This page walks through each integration point with setup instructions and configuration examples.
Email (SMTP)
UniAuth uses SMTP for transactional email paths. SMTP acceptance means only that the configured transport accepted a dispatch request, not that a message reached an inbox. Email OTP dispatch success is reported only after literal acceptance. On refusal or exception, UniAuth attempts to retire the exact new proof and does not publish successful proof issuance or transport acceptance; if retirement is not acknowledged, proof state is unknown. Anonymous requests retain their generic response-shape acknowledgement.
Configuration
You can configure SMTP in two ways: through environment variables or through the Admin Panel.
Option 1: Environment variables
# .env.local
SMTP_HOST=smtp.sendgrid.net
SMTP_PORT=587
SMTP_USER=apikey
SMTP_PASS=SG.xxxxxxxxxxxxxxxxxxxxx
SMTP_SECURE=false
EMAIL_FROM=noreply@yourdomain.comOption 2: Admin Panel
Ask your administrator to configure SMTP settings via the Admin Panel. Saved settings are stored in the database and are used only when SMTP_HOST is absent or empty. When SMTP_HOST is non-empty, the runtime selects the complete environment SMTP tuple and does not fill missing companion values from saved settings.
Supported Providers
| Provider | SMTP Host | Port | Notes |
|---|---|---|---|
| SendGrid | smtp.sendgrid.net | 587 | Use apikey as username, API key as password |
| Mailgun | smtp.mailgun.org | 587 | SMTP credentials from Mailgun dashboard |
| Amazon SES | email-smtp.us-east-1.amazonaws.com | 587 | Use SMTP credentials (not IAM keys) |
| Postmark | smtp.postmarkapp.com | 587 | Server API token as both username and password |
| Gmail | smtp.gmail.com | 587 | Requires App Password (not your Google password) |
Console Fallback
Without SMTP, some non-OTP compatibility email paths may log message content to the server console for local development. Console output is not delivery. Email OTP dispatch success requires literal configured-transport acceptance. On refusal or exception, UniAuth attempts to retire the exact new proof and does not publish successful proof issuance or transport acceptance; if retirement is not acknowledged, proof state is unknown. Anonymous requests retain their generic response-shape acknowledgement.
Tip: For local development, you can also use a service like Mailtrap or Ethereal to capture emails in a test inbox without sending real messages.
SMS delivery providers
UniAuth can route SMS OTP delivery through configured Twilio, AWS SNS, or MessageBird providers. Availability, sender support, and destination coverage depend on the selected provider and deployment.
Configuration
- Choose Twilio, AWS SNS, or MessageBird and validate the provider's supported sender and destination profiles.
- Configure the selected provider through the admin settings or documented server environment settings; never place provider credentials in client code.
- Configure routing rules deliberately. UniAuth selects the first usable matching rule; when no rules exist, it selects the first configured provider in Twilio, AWS SNS, then MessageBird order.
- Review the effective route and test an E.164 destination in every deployment profile before enabling SMS MFA.
How It Works
For local-code routes, UniAuth stores a time-bounded AES-256-GCM-encrypted code record and asks the selected provider to deliver the OTP. Twilio Verify retains provider-side challenge state instead. A generic API acknowledgement is neither delivery nor handset proof. Once a provider is selected, a failed dispatch is not automatically retried through another provider.
A successful code exchange shows access to the routed destination during the validity window; it does not establish ownership of the phone number or the person's identity.
Note: When no usable provider route is configured, SMS MFA is unavailable. TOTP and email OTP are separate methods and are not automatic SMS fallbacks.
Social Login — Google
Allow users to sign in with their Google account. UniAuth handles the full OAuth 2.0 flow with PKCE (S256 code challenge) for security.
Setup
- Go to the Google Cloud Console → APIs & Services → Credentials.
- Click Create Credentials → OAuth client ID.
- Select Web application as the application type.
- Under Authorized redirect URIs, add:
https://uniauth.id/api/auth/oauth/callback - Configure the OAuth consent screen with your app name, logo, and authorized domains.
- Copy the Client ID and Client Secret.
# .env.local
GOOGLE_CLIENT_ID=123456789-abcdefghijklmnop.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-xxxxxxxxxxxxxxxxxxxxxxxOnce configured, the "Sign in with Google" button appears automatically on the login and registration pages. When a user signs in with Google for the first time, a new UniAuth account is created and linked. Subsequent sign-ins match the Google email to the existing account.
Social Login — GitHub
Allow users to sign in with their GitHub account. Like Google, this uses OAuth 2.0 with PKCE for secure token exchange.
Setup
- Go to GitHub Settings → Developer settings → OAuth Apps.
- Click New OAuth App.
- Set the Homepage URL to your UniAuth instance URL (e.g.,
https://uniauth.id). - Set the Authorization callback URL to:
https://uniauth.id/api/auth/oauth/callback - Copy the Client ID and generate a Client Secret.
# .env.local
GITHUB_CLIENT_ID=Iv1.abcdef1234567890
GITHUB_CLIENT_SECRET=abcdef1234567890abcdef1234567890abcdef12The "Sign in with GitHub" button appears on the login page once credentials are configured. GitHub provides the user's name, email, and avatar, which are used to populate the UniAuth profile on first sign-in.
Note: If a user has a private email on GitHub, UniAuth requests the user:email scope to access their primary verified email address.
Webhooks
Signed best-effort POST notifications are currently produced only for user.created, user.login, user.logout, user.updated, and user.deleted. user.password_changed, oauth.client_created, and oauth.consent_granted are configurable only and are not emitted; delivery is not transactional or guaranteed real-time.
Overview
Each subscription targets a public URL. Verify X-UniAuth-Signature over the exact raw request bytes, process idempotently, and reconcile authoritative state. Failures receive at most three total attempts; duplicates, delays, and loss remain possible.
For complete webhook documentation, including event types, payload formats, signature verification, and retry behavior, see the Webhooks Guide.
Signed runtime envelope
// Incoming webhook payload
POST https://your-app.com/webhooks/uniauth
Content-Type: application/json
X-UniAuth-Signature: sha256=7d38cdd689735b008b3c702edd92eea23791c5f6...
{
"event": "user.created",
"timestamp": "2025-01-15T10:30:00Z",
"data": {
"userId": "550e8400-e29b-41d4-a716-446655440000",
"email": "newuser@example.com"
}
}SCIM Provisioning
SCIM (System for Cross-domain Identity Management) enables automatic user provisioning and deprovisioning from external identity providers such as Okta, Azure AD, and OneLogin.
Overview
When SCIM is enabled for an organization, the external IdP can automatically create, update, and deactivate user accounts in UniAuth. This eliminates manual account management for organizations using a centralized identity provider.
Enterprise tier: SCIM provisioning is an Enterprise-tier capability, configured per organization from the org admin area — an org owner mints and rotates the SCIM token under the org's SSO/provisioning settings rather than per OAuth client.
Inbound SSO is also Enterprise: letting your workforce sign in through your own IdP — inbound SAML (UniAuth as SAML Service Provider) and OIDC federation — is likewise an Enterprise capability, enabled per organization from the org admin area. See the Admin Guide for the org admin (self-serve) walkthrough.
UniAuth implements the SCIM 2.0 protocol at the /api/scim/* endpoints. SCIM tokens are configured per organization (Enterprise tier) from the org admin area. For full SCIM documentation, consult the API Reference.
Supported Operations
- Create User — Provision a new account when a user is assigned in the external IdP
- Update User — Sync profile changes (name, email) from the external IdP
- Deactivate User — Disable the account when the user is unassigned or removed
- List Users — Enumerate provisioned users for sync verification
Redis
By default, UniAuth uses in-memory rate limiting, which works well for single-instance deployments. For multi-instance or high-availability setups, you can enable Redis-backed distributed rate limiting.
Configuration
# .env.local
REDIS_URL=redis://localhost:6379
# With authentication:
REDIS_URL=redis://:your-password@redis.example.com:6379
# With TLS (e.g., AWS ElastiCache, Upstash):
REDIS_URL=rediss://:your-password@redis.example.com:6380What Redis Provides
- Distributed rate limiting — Rate limit counters are shared across all UniAuth instances, ensuring consistent enforcement
- Persistence across restarts — In-memory rate limit counters reset when the server restarts; Redis-backed counters survive restarts
- Horizontal scaling — Required if you run multiple UniAuth instances behind a load balancer
Tip: Redis is optional. If REDIS_URL is not set, UniAuth falls back to in-memory rate limiting automatically. This is perfectly fine for single-server deployments.
OAuth Clients (Sign in with UniAuth)
UniAuth is a full OAuth 2.0 Authorization Server and OpenID Connect Provider. Third-party applications can integrate "Sign in with UniAuth" to authenticate their users.
Registering an Application
Developers can register their own OAuth applications from the Account → Developer Console (up to 10 apps per user).
When registering a client, you provide:
- Application name — Displayed on the consent screen
- Redirect URIs — Allowed callback URLs after authorization
- Scopes — Which user data the app can request (
openid,profile,email,phone,address) - Grant types — Supported flows (authorization code, refresh token, device code; client credentials is limited Beta and admin-configured only)
Integration Flow
Once registered, use the standard OAuth 2.0 Authorization Code flow with PKCE:
// 1. Redirect user to UniAuth authorization endpoint
https://uniauth.id/api/oauth/authorize?
response_type=code&
client_id=YOUR_CLIENT_ID&
redirect_uri=https://your-app.com/callback&
scope=openid profile email&
state=RANDOM_STATE&
code_challenge=PKCE_CHALLENGE&
code_challenge_method=S256
// 2. User authenticates and consents
// 3. UniAuth redirects back with an authorization code
https://your-app.com/callback?code=AUTH_CODE&state=RANDOM_STATE
// 4. Exchange the code for tokens
POST https://uniauth.id/api/oauth/token
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code&
code=AUTH_CODE&
redirect_uri=https://your-app.com/callback&
client_id=YOUR_CLIENT_ID&
client_secret=YOUR_CLIENT_SECRET&
code_verifier=PKCE_VERIFIERFor comprehensive OAuth/OIDC documentation including discovery endpoints, token formats, pairwise subject identifiers, and SDK integration guides, see the OAuth2 / OIDC documentation and SDK documentation.
Integration Summary
| Integration | Required | Configuration | Fallback |
|---|---|---|---|
| Email (SMTP) | Recommended | Environment variables or Admin Panel | Console logging |
| SMS delivery / MFA | For SMS 2FA only | Admin settings or server environment | SMS 2FA unavailable |
| Google OAuth | Optional | Environment variables | Google login hidden |
| GitHub OAuth | Optional | Environment variables | GitHub login hidden |
| Webhooks | Optional | Admin Panel | No event notifications |
| SCIM | Optional | Org admin area (Enterprise, per organization) | Manual user management |
| Redis | For multi-instance | Environment variables | In-memory rate limiting |
| OAuth Clients | Optional | Developer Console or Admin Panel | No third-party SSO |
UniAuth is designed to work with minimal configuration. Only PostgreSQL and the core environment variables (DB_*, JWT_SECRET, ENCRYPTION_KEY) are required to get started. All other integrations can be added incrementally as your needs grow.