Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Supabase 7 min read How-to mediumAdept

What is SAML? A practical guide to the authentication protocol

SAML is an XML-based protocol that lets an identity provider such as GSuite, Okta or Active Directory vouch for users to a service provider, enabling enterprise single sign-on. Before SSO works, both sides exchange X.509 certificates, entity IDs, ACS/SLO/redirect URLs and attribute mappings, mostly via SAML Metadata XML documents, though allowed email domains and attributes still need manual agreement. Both SP-initiated and IdP-initiated flows are covered, followed by Supabase's signInWithSSO, whose JWT carries the SSO provider ID. That ID can drive Postgres row-level security policies via auth.jwt(), for example to restrict invites to users from the same identity provider.

Assumes: Single sign-on conceptsJWT basicsPostgres row-level security

Related posts

  • Supabase Auth: SSO, Mobile, and Server-side support

    Supabase mediumAdept

    Supabase Auth adds SAML 2.0 single sign-on, a PKCE authorization flow for server-side rendering and mobile apps, and native Sign in with Apple on iOS. SSO providers are managed with new `supabase sso` CLI commands, and the provider identifier in the JWT can drive Postgres Row Level Security policies for multi-tenant isolation. PKCE replaces the implicit grant flow, which exposed tokens in URL fragments that servers can't read and that malicious mobile apps could intercept. It does this with a hashed code verifier and challenge, so an intercepted authorization code is useless on its own. Enabling it means setting `flowType: 'pkce'` in supabase-js, and a Next.js callback route exchanges the code for a session.

  • Build "Sign in with Your App" using Supabase Auth

    Supabase mediumAdept

    Supabase Auth can now act as an OAuth 2.1 and OpenID Connect identity provider, letting a project offer "Sign in with [Your App]" to third-party apps, MCP-based AI agents, partner integrations and enterprise SSO. It uses the authorization code flow with PKCE, issues JWT access tokens carrying a client_id claim alongside the usual user_id and role, and also provides ID tokens, a UserInfo endpoint, refresh tokens, a JWKS endpoint and discovery documents at /.well-known/oauth-authorization-server and /.well-known/openid-configuration. MCP clients can register themselves through dynamic client registration. Existing login methods, Custom Access Token Hooks and Row Level Security all apply to OAuth tokens, so RLS policies can limit each client to specific data by checking the client_id claim. Granular scopes are planned but not yet available.

  • Custom OIDC Providers for Supabase Auth

    Supabase mediumAdept

    Supabase Auth now supports connecting any standards-compliant OpenID Connect identity provider, beyond its 20+ built-in social logins, for cases like regional compliance IdPs, self-hosted GitHub Enterprise or GitLab, and niche SSO systems. Providers are configured with an issuer URL, client credentials and scopes via the Admin API or Dashboard, with discovery and JWKS resolved from the .well-known endpoint and ID tokens verified automatically. Sign-in uses the same signInWithOAuth flow with a custom: identifier, and features include server-side PKCE by default, extra authorization params, multiple acceptable client IDs for multi-platform apps, and email-optional sign-in. Projects are limited to 3 custom providers unless support raises the cap.

  • Enterprise-managed auth for MCP: Claude can now issue the identity assertion

    Supabase mediumAdept

    Claude can now act as the issuer of the signed ID-JAG (Identity Assertion JWT Authorization Grant) for the Supabase MCP server, enabling enterprise-managed authorization for organizations whose identity provider doesn't support the MCP Enterprise-Managed Authorization extension (previously effectively only Okta). Claude verifies Claude-org membership and account email before signing, and Supabase checks the signature against the registered issuer, a matching SSO identity, and admin approval before minting a short-lived member-bound access token. The tradeoffs are significant: Claude does not check IdP sign-in or MFA, disabling a user in the IdP no longer revokes access (remove them from both Supabase and Claude orgs), and registering Claude's issuer URL replaces the IdP's, breaking managed auth for other AI tools relying on it.

  • Multi-factor Authentication via Row Level Security Enforcement

    Supabase mediumAdept

    Supabase Auth now offers TOTP-based multi-factor authentication to all users, built around separate enroll, challenge and verify endpoints. The challenge step is kept apart from verification so the flow can later support devices like Yubikeys. Issued JWTs carry an Authenticator Assurance Level claim (aal1 or aal2) and an Authenticator Method Reference claim listing the methods used, so Postgres Row Level Security policies can enforce MFA for all users or only for users with a verified factor. Those policies must be declared restrictive, because Postgres ORs permissive policies together.

The quest for software engineering knowledge.

Look:
Layout: