OIDC enterprise login
Enterprise customers need to authenticate through an OIDC identity provider such as Okta.
Better Auth · Const
The Better Auth SSO plugin adds OIDC and SAML single sign-on support. Enable it with sso(), then register identity providers with their required configuration.
The SSO plugin adds enterprise sign-on support to Better Auth. Configure it in the auth instance, then register OIDC or SAML providers; OIDC registration validates the provider's discovery document and generates a redirect URL from the provider ID.
sso()A Better Auth configuration with the SSO plugin enabled.
import { betterAuth } from "better-auth";
import { sso } from "@better-auth/sso";
export const auth = betterAuth({
plugins: [sso()],
});Install @better-auth/sso, then add the plugin to the Better Auth configuration.
Enterprise customers need to authenticate through an OIDC identity provider such as Okta.
An organization requires SAML-based federation with an identity provider.
Users should launch the application from their identity provider dashboard.
Add sso() from @better-auth/sso to the plugins array in betterAuth. The plugin then exposes SSO functionality for provider registration and authentication.
Follow-up: How are OIDC providers registered? Use the registerSSOProvider endpoint with the provider configuration, including a unique provider ID.
Register an OIDC provider through the registerSSOProvider endpoint with its required configuration. Better Auth validates the provider's OIDC discovery document and creates a redirect URL using the provider ID.
Follow-up: What must be checked before choosing a provider ID? Ensure it does not conflict with social providers, trusted account-linking providers, or reserved built-in IDs.
SAML registration requires Service Provider metadata configuration. The SSO plugin creates SAML metadata and callback endpoints for the registered provider.
Follow-up: What kind of SSO flow can SAML support besides application-initiated login? IdP-initiated login is supported, with the identity provider posting the SAML response to the callback endpoint.
registerSSOProviderOIDC providerSAML providerSAML callbackSP metadata