Table of Contents
How to Add Enterprise SSO to Supabase in 2026: Step-by-Step Guide
Quick Answer
To add Enterprise SSO (Single Sign-On) to Supabase in 2026, you have three options: (1) Supabase's native SAML 2.0 support (Team/Enterprise plan), (2) a custom SSO proxy using Next.js API routes that verify tokens from your identity provider like id.misar.io, or (3) a third-party auth provider like Auth0 or Clerk that wraps Supabase Auth. This guide covers all three methods, with a focus on the most flexible approach used by production platforms like misar.blog.
TL;DR — The three methods:
- Native Supabase SSO — Enable SAML in Supabase dashboard ($75/month Team plan). Easiest but limited customization.
- Custom SSO proxy — Full control, any identity provider, costs only development time. Harder to build but more flexible.
- Third-party auth wrapper — Auth0/Clerk as middleware. $0-200/month additional cost, adds dependency.
Why Enterprise SSO Matters in 2026
Enterprise Single Sign-On has shifted from "nice to have" to "dealbreaker" for B2B SaaS platforms. In 2026:
- 89% of enterprises require SSO for any new SaaS vendor (Gartner 2025)
- Companies using SSO reduce password-related support tickets by 70%
- Security compliance frameworks (SOC 2, ISO 27001, HIPAA) increasingly mandate SSO support
- Google Workspace and Microsoft 365 are the most common identity providers across enterprises
For Supabase-based applications, implementing SSO is critical for moving upmarket. Without it, enterprise deals stall at the security review stage.
How Supabase Auth Works (Quick Primer)
Supabase Auth uses GoTrue, a Go-based authentication server that supports email/password, magic links, OAuth (Google, GitHub, etc.), and phone auth. It stores sessions in the auth.users table and issues JWTs that your application validates.
For SSO, Supabase introduced SAML 2.0 support in late 2024, but it has limitations:
- Requires Supabase Team plan or higher ($75/month)
- Supports SAML only (not OpenID Connect natively)
- Limited to one identity provider per project
- No built-in session bridging between multiple apps
For platforms that need cross-domain SSO (e.g., logging into blog.misar.io via id.misar.io), a custom approach is necessary.
Method 1: Native Supabase SAML SSO (Easiest)
Prerequisites
- Supabase Team plan ($75/month) or Enterprise plan
- A SAML 2.0 identity provider (Okta, Azure AD, Google Workspace, OneLogin)
- Domain ownership verification
Step-by-Step
Step 1: Upgrade to Team Plan Go to your Supabase dashboard > Settings > Subscription. Upgrade to Team plan at $75/month.
Step 2: Configure SAML in Supabase
- Navigate to Authentication > Settings > SAML 2.0
- Add your domain (e.g.,
company.com) - Download Supabase's SAML metadata XML or copy the ACS (Assertion Consumer Service) URL and Entity ID
Step 3: Configure Your Identity Provider In Okta/Azure AD/Google Workspace:
- Create a new SAML application
- Set the ACS URL to
https://<project>.supabase.co/auth/v1/sso/saml/acs - Set the Entity ID to
https://<project>.supabase.co/auth/v1/sso/saml - Configure attribute mapping (email is required; name and avatar are optional)
- Upload or paste Supabase's metadata or download the IdP metadata XML
Step 4: Upload IdP Metadata to Supabase
- Download the metadata XML from your identity provider
- In Supabase dashboard > Authentication > SAML 2.0, upload the metadata
- Map attributes:
email,name,avatar_url
Step 5: Enable SSO Login on Your Frontend
import { supabase } from './supabaseClient'
async function signInWithSSO() {
const { data, error } = await supabase.auth.signInWithSSO({
domain: 'company.com', // Auto-detects the IdP
})
window.location.href = data.url // Redirects to IdP login
}
Limitations of this approach:
- If you need SSO across multiple domains (e.g., app.company.com, blog.company.com), you need a separate SAML configuration per subdomain
- No custom session handling — Supabase manages everything
- Limited to SAML — no OpenID Connect
Method 2: Custom SSO Proxy (Most Flexible)
This is the approach used by production multi-tenant platforms like misar.blog. It uses a standalone SSO service that verifies tokens and bridges sessions to Supabase.
Architecture
User → App → SSO Service (id.example.com) → Identity Provider
↓
Verifies token → Returns session
↓
Supabase Auth → setSession()
Prerequisites
- A Next.js API route or standalone server
- A shared JWT secret between SSO service and apps
- An SSO provider (Okta, Azure AD, or custom OAuth2)
Step-by-Step Implementation
Step 1: Create the SSO Endpoint
Create an API route that verifies tokens from your identity provider:
// app/api/auth/sso/route.ts
import { NextRequest, NextResponse } from 'next/server'
import { createClient } from '@supabase/supabase-js'
async function verifySSOTokenWithServer(token: string, audience: string) {
const response = await fetch(
`${process.env.SSO_VERIFY_URL}?token=${token}&audience=${audience}`
)
if (!response.ok) return { success: false }
return response.json()
}
export async function POST(request: NextRequest) {
const { token, audience } = await request.json()
const result = await verifySSOTokenWithServer(token, audience)
if (!result.success) {
return NextResponse.json({ error: 'Invalid token' }, { status: 401 })
}
const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.SUPABASE_SERVICE_ROLE_KEY!
)
await supabase.auth.setSession({
access_token: result.session.access_token,
refresh_token: result.session.refresh_token,
})
return NextResponse.json({ success: true, session: result.session })
}
Step 2: Frontend Login Flow
async function ssoLogin() {
// Redirect to SSO provider
window.location.href = `${SSO_URL}/authorize?redirect_uri=${encodeURIComponent(
window.location.origin + '/auth/callback'
)}`
}
// In callback handler
async function handleSSOCallback(token: string) {
const response = await fetch('/api/auth/sso', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ token, audience: 'myapp.com' }),
})
const data = await response.json()
if (data.success) {
// User is now authenticated via Supabase
window.location.href = '/dashboard'
}
}
Step 3: Shared Supabase Session
The key insight: once your SSO service creates a Supabase session with setSession(), the client can use that same session for authenticated API calls. This works because Supabase sessions are JWTs that include the user's identity.
Cross-domain SSO example:
// Cookie configuration for cross-subdomain SSO
// Set cookie on .misar.blog so all subdomains share the session
document.cookie = `sb-session=${session}; domain=.misar.blog; path=/; secure; samesite=lax`
Advantages of this approach:
- Works with any identity provider (SAML, OIDC, OAuth2)
- Cross-domain SSO across multiple apps
- Custom session handling and token refresh
- No Supabase plan upgrade needed
- Full control over authentication flow
Method 3: Third-Party Auth Wrapper (Balance of Ease and Flexibility)
Use Auth0, Clerk, or WorkOS as middleware between your app and Supabase. These services handle SSO configuration, identity provider integration, and token management.
Using Clerk + Supabase
- Set up Clerk with your identity provider (Okta, Azure AD, Google Workspace)
- Configure Clerk's Supabase integration using Clerk's JWT template
- Clerk generates Supabase-compatible JWTs after SSO login
- Use Clerk's session in your Supabase client
Using Clerk + Supabase (Simplest Setup)
Clerk provides the easiest Supabase SSO integration. Its Supabase JWT template generates tokens that Supabase accepts natively, eliminating the need for custom session bridging code.
Setup steps:
- Enable your identity provider in Clerk dashboard
- Create a Supabase JWT template in Clerk
- Install Clerk's React SDK and wrap your app
- Use Clerk's useAuth() hook to get the Supabase token
- Pass it to supabase.auth.setSession()
Total setup time: 2-4 hours for a developer familiar with both platforms. Clerk handles the complexity of 10+ identity provider configurations, so you only configure once and your app supports Okta, Azure AD, Google Workspace, OneLogin, and custom SAML providers simultaneously.
Using Auth0 + Supabase
- Configure Auth0 as your SSO gateway
- Set up Auth0's Supabase integration (custom SAML or OAuth2 bridge)
- Auth0 generates Supabase JWTs via Rules or Actions
- Pass the Auth0 token to Supabase
setSession()
Pricing:
| Service | Free Tier | Paid Starting |
|---|---|---|
| Auth0 | 7,000 users | $32/month |
| Clerk | 10,000 users | $25/month |
| WorkOS | Free SSO | $99/month for SAML |
Comparison of Methods
| Feature | Native Supabase SSO | Custom SSO Proxy | Third-Party Wrapper |
|---|---|---|---|
| Setup complexity | Low | High | Medium |
| Supabase plan required | Team+ ($75/mo) | Free tier OK | Free tier OK |
| Provider flexibility | SAML only | Any (SAML/OIDC/OAuth) | Any |
| Cross-domain SSO | Limited | Yes | Via wrapper |
| Custom session control | No | Full | Limited |
| Maintenance | None | You own it | Vendor handles |
| Security audit | Easy | Complex | Medium |
| Cost (beyond Supabase) | $0 | Dev time | $25-99/month |
Security Best Practices
- Use HTTP-only, Secure, SameSite cookies for session tokens
- Implement a redirect circuit breaker — limit SSO redirects to prevent infinite loops (misar.blog uses a
misar_redirect_countcookie with a max of 5 redirects before bailing to/?error=redirect_loop) - Always validate tokens server-side — never trust client-side assertions alone
- Use short-lived access tokens (15 minutes) with long-lived refresh tokens (30 days)
- Log all SSO events — track logins, failures, and token refreshes
- Rate limit the SSO endpoint — prevent brute force and token replay attacks
Real-World Implementation: misar.blog SSO
Misar.blog (misar.blog) uses a custom SSO architecture with a dedicated service at id.misar.io. The flow:
- User clicks "Sign in with SSO" on misar.blog
- Redirected to
id.misar.iofor authentication - After successful login,
id.misar.ioissues a signed JWT - misar.blog verifies the JWT via its
/api/auth/ssoendpoint - On success, it calls
supabase.auth.setSession()with the provided tokens - The user is authenticated across all services under the
misar.blogdomain
This architecture supports cross-TLD SSO where users authenticate once and access all Misar AI products — blog, mail, social, dev, and more.
Integrating Supabase with enterprise SSO is just one piece of the puzzle. For a complete enterprise-grade stack, consider using an Open AI-compatible API like Assisters (assisters.dev) to add AI features to your authenticated application. An LLM gateway in front of your AI models ensures consistent authentication and usage tracking across your enterprise deployment.
For teams building AI-powered features for their SaaS products, an AI-powered blogging platform like Misar.Blog (misar.blog) demonstrates how SSO + content management can deliver enterprise-grade publishing with proper access controls.
Troubleshooting Common Issues
| Issue | Cause | Solution |
|---|---|---|
| "Domain not verified" | SAML domain mismatch | Ensure the domain in Supabase matches the IdP exactly |
| "Invalid audience" | ACS URL mismatch | Copy the exact ACS URL from Supabase to your IdP |
| Redirect loop | Cookie misconfiguration | Implement a redirect counter cookie |
| Session not persisting | Cookie domain mismatch | Set cookie domain to root domain (.example.com) |
| Token expired | Short expiry + no refresh | Implement automatic token refresh with supabase.auth.onAuthStateChange() |
FAQs
Q: Does Supabase Free plan support SSO?
A: No. SSO (SAML) requires the Team plan at $75/month or Enterprise. However, you can implement a custom SSO proxy (Method 2) on any plan.
Q: Can I use OpenID Connect instead of SAML?
A: Not natively with Supabase's SSO feature. Supabase supports SAML 2.0 only for SSO. For OpenID Connect, use the custom SSO proxy approach (Method 2) or a third-party wrapper (Method 3).
Q: Can I integrate multiple identity providers?
A: Supabase supports one SAML provider per project. For multiple IdPs, use a custom SSO proxy with a routing layer (e.g., route @company1.com to Okta, @company2.com to Azure AD).
Q: Is the custom SSO proxy secure?
A: Yes, when implemented correctly. Use JWT verification, HTTPS-only transport, short-lived tokens, and rate limiting. The misar.blog implementation handles thousands of enterprise authentications daily.
Q: What if I need SSO for mobile apps?
A: Supabase's native SAML SSO works with web views and mobile apps via redirect-based flows. For the custom approach, use ASWebAuthenticationSession (iOS) or Custom Tabs (Android) for the SSO flow.
Q: How do I test SSO locally?
A: Configure a local identity provider (Dex or Keycloak in Docker), set up your local Supabase instance, and use ngrok to expose your local server for SAML callbacks. Or use Supabase's local emulator with mock SSO endpoints.
Last updated: January 2026. Supabase features and pricing may change. Always verify against current Supabase documentation.
Frequently Asked Questions
Quick answers to common questions about this topic.
