ObjectStackObjectStack

SSO — social and enterprise sign-in setup

Enable Google sign-in in open source, and extend auth providers through packages.

ObjectStack open source ships two built-in social sign-in implementations, both wired by os serve from deployment env vars:

  • Google OAuth: configure in Setup → Authentication, or from GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET deployment env vars
  • GitHub OAuth: configure from GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET deployment env vars

Additional providers should be contributed by product or enterprise packages through the auth:configure hook. Those packages can add better-auth socialProviders or OIDC/generic OAuth providers without forking @objectstack/plugin-auth.

The Console login and registration pages automatically render Continue with ... buttons for every enabled provider returned by /api/v1/auth/config.


Social Providers

Google

  1. Go to Google Cloud Console → APIs & Services → Credentials.
  2. Click Create Credentials → OAuth 2.0 Client ID → Web application.
  3. Add an Authorized redirect URI:
    https://<your-domain>/api/v1/auth/callback/google
    For local development: http://localhost:3000/api/v1/auth/callback/google
  4. Copy the Client ID and Client Secret.

Then either save the values in Setup → Authentication → Social sign-in or provide them as deployment environment variables:

GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret

# Optional settings env override. UI settings are lower precedence than env.
# OS_AUTH_GOOGLE_ENABLED=false

GitHub

  1. Go to GitHub Developer Settings → OAuth Apps → New OAuth App.
  2. Set Authorization callback URL:
    https://<your-domain>/api/v1/auth/callback/github
  3. Copy the Client ID and generate a Client Secret.

Provide them as deployment environment variables:

GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret

Extension Packages

The providers below are examples for enterprise or product packages, not built-in open-source settings. A package can register them by listening to auth:configure and mutating the draft auth config.

The env-var names shown below (e.g. MICROSOFT_CLIENT_ID, APPLE_CLIENT_ID) are illustrative for an extension package's own reader code — unlike GOOGLE_* and GITHUB_*, the framework does not read them out of the box, so an extension must wire them in its auth:configure handler.

Microsoft (Azure AD / Entra ID)

  1. Go to Azure Portal → Azure Active Directory → App registrations → New registration.
  2. Add a redirect URI (Web):
    https://<your-domain>/api/v1/auth/callback/microsoft
  3. Under Certificates & secrets, create a new client secret.
MICROSOFT_CLIENT_ID=your-azure-app-client-id
MICROSOFT_CLIENT_SECRET=your-azure-client-secret

# Optional: restrict to a single tenant (default: "common" — all Microsoft accounts)
# MICROSOFT_TENANT_ID=your-tenant-id

Apple

  1. Go to Apple Developer Console → Certificates, IDs & Profiles → Identifiers → register a Services ID.
  2. Enable Sign In with Apple and configure the redirect URL:
    https://<your-domain>/api/v1/auth/callback/apple
  3. Generate a private key under Keys.
APPLE_CLIENT_ID=your-apple-services-id
APPLE_CLIENT_SECRET=your-apple-private-key-jwt

Apple requires the client secret to be a signed JWT derived from the private key. See better-auth Apple docs for details.


Enterprise SSO (OIDC)

Admin-managed OIDC SSO ships in the open framework: @objectstack/plugin-auth registers external IdPs through @better-auth/sso, and admins add them without code from Setup → SSO Providers (see the ADR-0069 note below). The oidcProviders config shown here is the in-process path for framework or product packages that prefer wiring providers in code, or contributing them through auth:configure.

Admin-managed external IdP (ADR-0069). Recent releases add a per-environment external-IdP path built on @better-auth/sso and surface an sso flag in the public /auth/config (features.sso) so a client can show an enterprise-login button when SSO is configured. Admins register providers without code from Setup → SSO Providers — both OIDC (Okta, Entra, Auth0, Keycloak, …) and SAML 2.0 (see SAML 2.0 below). The oidcProviders extension shown here remains the in-process path for framework/enterprise packages that prefer wiring providers in code.

Setup → SSO Providers → Register Provider posts to the env-side bridge at POST /api/v1/auth/admin/sso/register, the OIDC counterpart of the SAML bridge below. It takes the flat form fields of the OIDC provider fields table, reshapes them for @better-auth/sso, and is gated on a platform admin (ADR-0068 D4) before it delegates — an organization owner or admin is not sufficient, because registering an identity provider decides how the whole environment authenticates.

This is an ObjectStack mount, distinct from @better-auth/sso's own POST /api/v1/auth/sso/register. The bridge exists so the no-code Setup form can post flat fields; both doors apply the platform-admin rule.

Register Microsoft Entra ID

Register an Entra ID application from Setup → SSO Providers → Register Provider, or through POST /api/v1/auth/sso/register, with the issuer https://login.microsoftonline.com/<tenant-id>/v2.0. No trusted-origins configuration is needed.

Discovery. Entra ID's discovery document names its userinfo_endpoint on https://graph.microsoft.com, a host other than the issuer's. The server keeps a built-in table of such companion origins for well-known identity providers, and trusts https://graph.microsoft.com only while it validates the discovery document of a registration whose issuer is an https://login.microsoftonline.com URL. It is not added to the trusted origins that the CSRF check reads, and no other request sees it. Sovereign-cloud Entra hosts are not in the table: name their userinfo endpoint explicitly, as below.

Any other identity provider whose discovery document names an endpoint on a foreign host is refused 400 discovery_untrusted_origin. The message names the endpoint and the registration member that names it explicitly, for example "userInfoEndpoint": "https://profile.example.com/userinfo". A host is never trusted only because a discovery document names it. Pass the endpoint as the oidcConfig member the message names (authorizationEndpoint, tokenEndpoint, jwksEndpoint or userInfoEndpoint), or as the field of the same name on the Register SSO Provider bridge, POST /api/v1/auth/admin/sso/register, and the registration trusts it. Setup → SSO Providers → Register SSO Provider offers each of them as a field: Authorization URL fills authorizationEndpoint, Token URL tokenEndpoint, JWKS URL jwksEndpoint and Userinfo URL userInfoEndpoint. An origin a registration or an update names, its issuer included, is trusted only for that provider's discovery and validation: a registration's discovery and endpoint checks read it, and so does the check of the provider's logout endpoint when a registration or an update turns Sign Out of the Company Sign-In Too (signOutOfIdp) on (the discovery document that check reads is fetched under the configured trusted origins only). It never becomes an accepted Origin for the request itself, whose origin check reads the deployment's configured trusted origins alone, as on any other POST. So turning Sign Out of the Company Sign-In Too on for an OpenID Connect identity provider on an internal or private network is refused 400 VALIDATION_FAILED on signOutOfIdp until the provider's origin is listed in OS_TRUSTED_ORIGINS.

SSO discovery connects only to addresses that are public at connect time. Every read the server makes of an identity provider's OpenID Connect configuration (a registration's discovery document, the Sign Out of the Company Sign-In Too check's read of the same document on a registration or an update, a sign-in's discovery, and the token, key-set and userinfo reads of a sign-in's callback) goes through the platform's outbound-request guard: the connection itself resolves the host, judges every address it resolves to, and connects only to an address it judged. An address that is private, loopback, link-local, a cloud metadata or host-platform address (168.63.129.16 included) or in any other non-public range is refused and nothing is sent to it, whatever an earlier lookup of the same name answered; so is a host whose name does not resolve when the read connects. Only reads at the origins the provider's configuration names are judged: every other request the server makes while answering (a datastore or a rate-limit store reached over HTTP) is sent as before.

A registration also judges its discovery host before reading it, by the same rule: the host of the discoveryEndpoint the registration names, else the issuer's. A host that is not public is refused 400 VALIDATION_FAILED on issuer or oidcConfig.discoveryEndpoint, and nothing is read from it; the same answer comes back when the host answers a non-public address only once its read connects. The Register SSO Provider bridge answers that refusal as SSO_REGISTER_FAILED. The check comes before the Sign Out of the Company Sign-In Too check above, so a registration that also turns that switch on is refused on the same member. A refused callback read ends the sign-in on the error page with invalid_provider. Trust an origin gains because a registration names it never stands in for this rule, and neither does OS_EGRESS_ALLOWED_TARGETS. An identity provider on an internal network is reached once its origin is listed in OS_TRUSTED_ORIGINS: a read of an origin the deployment trusts is sent as before.

Google is one such provider: its discovery document names the token endpoint, the key set and the userinfo endpoint each on a host of its own, so a Google registration names all three, either in the Token URL, JWKS URL and Userinfo URL fields of the Setup form or through the bridge:

await fetch('http://localhost:3000/api/v1/auth/admin/sso/register', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  credentials: 'include',
  body: JSON.stringify({
    providerId: 'google',
    issuer: 'https://accounts.google.com',
    domain: 'acme.com',
    clientId: 'YOUR_CLIENT_ID',
    clientSecret: 'YOUR_CLIENT_SECRET',
    tokenEndpoint: 'https://oauth2.googleapis.com/token',
    jwksEndpoint: 'https://www.googleapis.com/oauth2/v3/certs',
    userInfoEndpoint: 'https://openidconnect.googleapis.com/v1/userinfo',
  }),
});

Claims. Microsoft Graph's userinfo answer carries sub, name, email and picture, but no groups, preferred_username or upn. Two things follow:

  • Groups come from the verified ID token. When the userinfo answer does not carry the provider's groups claim (mapping.extraFields.groups), the groups are read from the ID token the server has already verified. Where both carry the claim, the userinfo answer wins. See Grant permission sets from IdP groups.
  • A user without a mailbox needs an email mapping. Entra ID sends no email claim for a user with no mailbox, and such a sign-in is refused email_claim_missing (see Why an OIDC sign-in was refused). Set Map: Email claim on the register form, or the email member with Edit Attribute Mapping on an existing provider, to preferred_username (or upn), and turn on Read Claims From the ID Token Only (skipUserInfo, see Per-provider sign-in options), because while userinfo is called the mapping reads the userinfo answer, which has neither. The server never makes up an email address from another claim on its own.

Quick start — Okta

const oidcProviders = [
  {
    "providerId": "okta",
    "name": "Okta",
    "discoveryUrl": "https://your-org.okta.com/.well-known/openid-configuration",
    "clientId": "your-okta-client-id",
    "clientSecret": "your-okta-client-secret",
    "scopes": ["openid", "email", "profile"]
  }
];

Quick start — Azure AD (OIDC)

const oidcProviders = [
  {
    "providerId": "azure-ad",
    "name": "Azure AD",
    "discoveryUrl": "https://login.microsoftonline.com/<tenant-id>/v2.0/.well-known/openid-configuration",
    "clientId": "your-azure-client-id",
    "clientSecret": "your-azure-client-secret"
  }
];

Quick start — Keycloak

const oidcProviders = [
  {
    "providerId": "keycloak",
    "name": "Keycloak",
    "discoveryUrl": "https://keycloak.example.com/realms/your-realm/.well-known/openid-configuration",
    "clientId": "your-client-id",
    "clientSecret": "your-client-secret",
    "pkce": true
  }
];

Multiple enterprise providers

const oidcProviders = [
  {
    "providerId": "okta",
    "name": "Okta SSO",
    "discoveryUrl": "https://your-org.okta.com/.well-known/openid-configuration",
    "clientId": "...",
    "clientSecret": "..."
  },
  {
    "providerId": "azure-ad",
    "name": "Microsoft SSO",
    "discoveryUrl": "https://login.microsoftonline.com/<tenant>/v2.0/.well-known/openid-configuration",
    "clientId": "...",
    "clientSecret": "..."
  }
];

OIDC provider fields

FieldRequiredDescription
providerId✅Unique identifier used internally (e.g. okta, azure-ad)
name—Display name shown on the button (defaults to providerId)
discoveryUrl✅*OIDC discovery URL — auto-fetches all endpoints
authorizationUrl✅*OAuth2 authorization endpoint (if no discoveryUrl)
tokenUrl✅*OAuth2 token endpoint (if no discoveryUrl)
userInfoUrl—OAuth2 userinfo endpoint
issuer—Expected issuer for token validation
clientId✅OAuth2 client ID
clientSecret✅OAuth2 client secret
scopes—Requested scopes (default: openid email profile)
pkce—Enable PKCE — recommended for public clients

*Either discoveryUrl or authorizationUrl + tokenUrl must be provided.

Domain verification (opt-in)

A provider can claim an email domain, so that anyone signing in with an address at that domain is routed to it. Proving the claim is opt-in per environment (ADR-0135 D6) and off by default:

# Off by default. Turn on to require a DNS proof before a domain claim counts.
OS_SSO_DOMAIN_VERIFICATION=true

With it on, Setup → SSO Providers exposes a two-step flow, one route per step. Both are platform-admin gated (ADR-0068 D4) and both take the provider the domain is being claimed for:

  1. POST /api/v1/auth/admin/sso/request-domain-verification — returns a DNS TXT record to publish on the domain. Copy it into your DNS zone.
  2. POST /api/v1/auth/admin/sso/verify-domain — call once the record has propagated. It re-checks DNS and marks the domain verified, or reports why it could not.
// Step 1 — ask for the TXT record to publish. Body: { providerId }.
// The record goes under the provider's registered domain, which the answer
// carries as `domain`; dnsRecordName is the full record name under it.
const req = await fetch('http://localhost:3000/api/v1/auth/admin/sso/request-domain-verification', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  credentials: 'include',
  body: JSON.stringify({ providerId: 'okta' })
});
// → { success: true, data: { providerId, domain, token,
//                            dnsRecordType: 'TXT', dnsRecordName, dnsRecordValue,
//                            dnsRecords: [{ domain, type: 'TXT', name, value }] } }
// A provider listing several domains needs the record under each of them:
// dnsRecords has one entry per domain, and dnsRecordName names them all.

// …publish dnsRecordName / dnsRecordValue, wait for DNS to propagate, then:

// Step 2 — verify the claim. Body: { providerId }.
const done = await fetch('http://localhost:3000/api/v1/auth/admin/sso/verify-domain', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  credentials: 'include',
  body: JSON.stringify({ providerId: 'okta' })
});
// → { success: true, data: { providerId, verified: true, message } }

Both take providerId and refuse with 400 INVALID_REQUEST when it is missing. Step 2 reports NO_PENDING_VERIFICATION if you call it before step 1, and DOMAIN_VERIFICATION_FAILED when the TXT record is not visible yet — retry after DNS propagates.

The mounts are unconditional; the switch controls the endpoint behind them. Both routes exist whether or not OS_SSO_DOMAIN_VERIFICATION is set — and with it unset there is no endpoint behind them, so both steps answer 400 DOMAIN_VERIFICATION_DISABLED. With it on, either step answers an unknown providerId with 404 RESOURCE_NOT_FOUND; step 2's NO_PENDING_VERIFICATION is a 404 too, so match on the code rather than the status. Either way an anonymous caller gets 401 UNAUTHENTICATED and a signed-in non-platform-admin 403 PERMISSION_DENIED — identity is answered before capability, so a stranger cannot use these routes to probe which features an environment has enabled.

What verification decides, with it on:

  • A provider signs nobody in until its domain is verified. Step 2 proves every domain the provider lists, and one verified flag covers the whole list. Editing a provider's domain list clears the flag until every listed domain is proven again.

  • A provider creates an account only for an email address at a domain it has proven. The address's domain must equal one of the provider's listed, verified domains. A subdomain counts only when it is itself listed and verified, and a parent never counts for a listed subdomain. A listed entry counts only for the host the provider proved, so write each entry as a bare host name (acme.com, not https://acme.com and not acme.com:443): an entry written any other way proves nothing. Case, and the Unicode and punycode forms of an internationalised name, are one domain; an address written in any other spelling of a domain (a trailing dot, full-width letters) is refused. Any other new account is refused with error=EMAIL_DOMAIN_NOT_ALLOWED, and nothing is created. No audience posture, invitation, first-user carve-out or allowJit setting relaxes this.

  • An SSO sign-in links to an existing account only at a proven domain. When a sign-in links to an account that already exists (an implicit link), the asserted address must be at one of the provider's listed, verified domains, matched the same way. Two cases, kept apart:

    • an address at a domain the provider does not list at all was already not linked, and is still refused as before, with the same answer;
    • an address at a subdomain of a listed domain that is not itself listed and verified is no longer linked: it is refused with error=EMAIL_DOMAIN_NOT_ALLOWED.

    Either way no link is written and no session is issued.

  • A sign-in changes a linked account's address only to a proven domain. A provider set to update the account from what the identity provider asserts writes a new address at a later sign-in. That sign-in is refused with error=EMAIL_DOMAIN_NOT_ALLOWED, and the stored address stays, unless the new address is at one of the provider's listed, verified domains. A sign-in that would not change the stored address is not re-checked: one that asserts the account's own address, and one through a provider that does not update the account (every SAML provider, and an OIDC provider without that update setting, which the platform's own provider registration never turns on), signs in as before. An explicit link from account settings is unchanged.

So if your people first sign in with addresses at a subdomain or at another domain, list each such domain on the provider as a bare host name and verify it.

With verification on or off, a provider creates an account only for an email address. A SAML or OIDC sign-in that resolves to a value that is not an address (an IdP that sends no email attribute and an opaque persistent or transient NameID, or a mapping that names a claim holding a user name) is refused with error=INVALID_EMAIL, and nothing is created. Map the provider's email attribute or claim to the one that carries the address. With verification on, such a value is refused error=EMAIL_DOMAIN_NOT_ALLOWED by the rule above, as before. An account that already exists signs in as before.

A provider's domain list takes bare host names only. Registering a provider, or editing its domain, with an entry written any other way (a URL, a port, a path, a user part) is refused with 400 VALIDATION_FAILED on domain, naming the entry; nothing is saved. Every rule that reads the list (the account rule above, and SCIM adoption of an existing account) reads each entry the same way. A provider saved before this rule may still hold such an entry: it is not rewritten, and it names no domain. To correct one, send the bare host names as domain to POST /api/v1/auth/sso/update-provider (https://acme.com becomes acme.com; the console has no action that edits a provider's domain), then verify the domain again, since writing the list clears the verified flag. To find them, read the server log at boot: each such provider gets one warning naming its provider_id and the entry. The warning only reads; it changes no row.

Why an OIDC sign-in was refused

When the identity provider's ID token is not accepted, the callback redirects to your errorCallbackURL (or callbackURL) with error=invalid_provider, and error_description names the cause. The server also writes one warn log line with the providerId, protocol: 'oidc' and the same cause. Neither carries any token content, and the answer does not depend on whether the account exists.

error_descriptionWhat to check
id_token_expiredThe token's exp is in the past. Check the clocks of this server and the IdP.
id_token_not_yet_validThe token's nbf is in the future. Check the clocks of this server and the IdP.
id_token_audience_mismatchThe token's aud is not this provider's clientId. Check the client ID registered here against the IdP application.
id_token_issuer_mismatchThe token's iss is not this provider's issuer. Check the issuer URL, including any trailing path or slash.
id_token_signing_key_unknownNo key in the IdP's JWKS matches the token's key ID, usually after the IdP rotated or retired its signing key. Check the jwksEndpoint.
id_token_signature_invalidThe JWKS key does not verify the token's signature. Check that the jwksEndpoint belongs to the same IdP as the issuer.
token_not_verifiedAny other refusal of the ID token. The server log carries the detail.
email_claim_missingThe ID token was accepted, but the claim the provider maps to the email (mapping.email, email by default) is missing. The warn line names the claim and the mapping key. For a Microsoft Entra ID user without a mailbox, map preferred_username or upn and turn on skipUserInfo.

The ID-token causes are exported as SSO_OIDC_REFUSAL_CAUSES from @objectstack/plugin-auth, and email_claim_missing as SSO_OIDC_EMAIL_CLAIM_MISSING. SAML refusals name theirs too: see Why a SAML sign-in was refused.


Enterprise SSO (SAML 2.0)

SAML 2.0 is provided natively by @better-auth/sso (the same package behind the OIDC path) — no custom plugin or extension is needed. Admins register a SAML IdP from Setup → SSO Providers → Register SAML Provider, which posts to the env-side bridge at POST /api/v1/auth/admin/sso/register-saml.

Register a SAML provider

Fill in the IdP details collected by the Register SAML Provider action:

FieldRequiredDescription
providerId✅Stable identifier, e.g. acme-saml.
issuer✅The IdP's SAML EntityID (issuer), e.g. https://saml.acme.com/entityid.
domain✅Users with this email domain are routed to this IdP, e.g. acme.com.
entryPoint✅The IdP's SAML single sign-on (redirect) URL that receives the SAMLRequest.
cert✅The IdP's X.509 signing certificate (PEM body) — used to verify assertion signatures.
identifierFormat—Requested SAML NameID format (defaults to the IdP's configured format), e.g. urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress.
mapEmail—Assertion attribute the user's email is read from. Left blank: the standard …/claims/emailaddress claim when the assertion carries it, else email, else the NameID.
mapFirstName—Assertion attribute the user's first name is read from. Left blank: the standard …/claims/givenname claim when present, else givenName.
mapLastName—Assertion attribute the user's last name is read from. Left blank: the standard …/claims/surname claim when present, else surname.
mapName—Assertion attribute the user's full name is read from when the first and last name are absent. Left blank: the standard …/claims/name claim when present, else displayName, else the NameID.
mapGroups—Assertion attribute that carries the user's groups (see Grant permission sets from IdP groups).
mapAccountKey—Assertion attribute with one stable value per person that the IdP sets and the user cannot edit, used as the account key instead of the NameID (see Key accounts on a stable attribute). Left blank: Entra ID's object id claim for an Entra ID provider, else the NameID.

On success the response returns the two Service Provider (SP) URLs you configure on the IdP side:

{
  "success": true,
  "data": { "providerId": "acme-saml" },
  "acsUrl": "https://<your-domain>/api/v1/auth/sso/saml2/sp/acs/acme-saml",
  "spMetadataUrl": "https://<your-domain>/api/v1/auth/sso/saml2/sp/metadata?providerId=acme-saml"
}
  • ACS (Assertion Consumer Service) URL — register this as the SP ACS / reply URL on the IdP.
  • SP metadata URL — serves the SP EntityDescriptor/SPSSODescriptor XML (many IdPs can import it directly to auto-configure the SP).

SAML sign-in flow

  1. User enters their work email (or clicks the enterprise-login button).
  2. Client calls POST /api/v1/auth/sign-in/sso with { email, callbackURL } (and optionally errorCallbackURL).
  3. The email domain is matched to the registered provider; the response is a redirect to the IdP's entryPoint carrying a signed SAMLRequest.
  4. The IdP authenticates the user and POSTs a SAML assertion back to the SP ACS URL; @better-auth/sso (samlify) validates the signature/timestamp, then creates a session and redirects to callbackURL.
  5. A refused sign-in redirects to errorCallbackURL, or to the platform's sign-in page when none was given, with error= naming the refusal: for example account_not_linked when the email belongs to an existing account this provider is not linked to. It never lands on callbackURL, as with OIDC.

Signature, timestamp, and replay validation are handled by @better-auth/sso (samlify). You only supply the IdP's signing certificate at registration time.

Map the user's email and name

A SAML sign-in reads the user's email and name from assertion attributes. For each member left unmapped, the sign-in first reads the standard claim Microsoft Entra ID and AD FS send by default, when the assertion carries it:

MemberStandard claim, read first when unmapped
Emailhttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress
First namehttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname
Last namehttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname
Full namehttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/name

Without that claim, the email is the email attribute (else the NameID) and the name is givenName + surname, else displayName, else the NameID. So an Entra ID provider with nothing mapped reads the address in the emailaddress claim, whether the person enters from your sign-in page (an email-format NameID) or from the IdP's app portal (Entra's default persistent NameID, an opaque id), so the two entries resolve to one address and never make a second account. Which account each entry signs in to is decided by the account key, below. When the assertion carries both an email attribute and the emailaddress claim, the claim is read. A member you map is always read as mapped. Two limits:

  • The claims are recognised by the attribute names in the assertion as posted. An encrypted assertion's names cannot be read before it is decrypted, so a provider that encrypts assertions reads only what it maps: map its members.
  • The stored mapping does not change: Show Attribute Mapping still shows an unmapped member as empty.

Key accounts on a stable attribute

A SAML account is keyed on the provider and one value of the person. By default that value is the NameID, which is not the same on every entry: Entra ID sends the user principal name when the sign-in starts from your sign-in page and an opaque id when it starts from its app portal. So a provider can key its accounts on a stable attribute instead:

  1. the attribute named in Map: Account key attribute (mapAccountKey) when the provider is registered, for any IdP. It must be one the IdP sets and the user cannot edit, such as Entra ID's object id or Okta's user id: never an attribute a user can change (an email, a display name, a profile field), since whoever holds its value holds the account;
  2. with none named, for an Entra ID provider (its IdP Entity ID is on sts.windows.net or login.microsoftonline.com), Entra's object id claim http://schemas.microsoft.com/identity/claims/objectidentifier, which Entra ID sends by default;
  3. otherwise, the NameID.

For a provider keyed on a stable attribute, both entries reach one account and both sign in: from your sign-in page and then from the IdP's portal, or portal first, the same person ends on the same account. An email change at the IdP keeps the account too. When an assertion does not carry the attribute, that sign-in is keyed on its NameID, as before.

  • The key is the provider's own. A sign-in through another provider never reaches the account by it, and an existing account at the same address (a password account, or another provider's) is still judged by the linking rule (Linking to an existing account).
  • The value is read from the assertion as posted and confirmed against the verified assertion before anything is written; a sign-in whose verified assertion does not carry it is refused with error=INVALID_REQUEST. A value written with a comment, CDATA, an entity reference or markup is not read, and the NameID keys that sign-in. An encrypted assertion's value cannot be read before it is decrypted, so a provider that encrypts assertions keys on the NameID.
  • Accounts made before an account key applied keep the NameID they were made with; they are not rewritten, and a sign-in reaches one only through the account's email. The same entry with the same email still signs in to it; the other entry (another NameID) is refused error=account_not_linked as before, so the two entries do not reach one such account; and after the email changes at the IdP the old account is not reached (a new user is made where the provider allows JIT, otherwise the sign-in is refused error=SELF_REGISTRATION_CLOSED). Name the attribute when the provider is registered.

Okta uses other attribute names, so its users are named after their NameID until the provider maps them:

MemberDefaultOkta (common)Entra ID
Emailemailemailhttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress
First namegivenName—http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname
Last namesurname—http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname
Display namedisplayNamenamehttp://schemas.microsoft.com/identity/claims/displayname

Okta sends the attributes its application's attribute statements name, so check those statements for the exact names. Map them on the Register SAML Provider form, or on an existing provider:

  • Show Attribute Mapping shows the attributes (SAML) or claims (OIDC) the provider reads now; an empty member uses the default.
  • Edit Attribute Mapping changes the members you fill in. A member you leave untouched keeps its value, and a member you clear goes back to the default. The groups claim and every other member of the mapping are kept as stored. An OIDC provider maps email and name only (its default claims are email and name).

Both run on platform-admin standing, through POST /api/v1/auth/admin/sso/get-attribute-mapping and POST /api/v1/auth/admin/sso/set-attribute-mapping ({ providerId, email?, firstName?, lastName?, name? }). The email member decides which account a sign-in is linked to, so change it with care on a provider that already has users.

Why a SAML sign-in was refused

When the identity provider's SAML response is not accepted, the sign-in lands on your errorCallbackURL (or the platform's sign-in page) with error=saml_error. For the four common configuration mistakes, error_description names the cause instead of Invalid SAML response, and the server writes one warn log line with the providerId, protocol: 'saml' and the same cause. The cause is read from the response the IdP posted, compared with the provider's configured signing certificate and IdP entity ID; neither the redirect nor the log line carries any assertion content, and the answer does not depend on whether the account exists.

error_descriptionWhat to check
saml_idp_status_not_successThe IdP answered with a failure status instead of an assertion: for example Entra ID's "user is not assigned to the application". Check the user's assignment and the IdP's sign-in log.
saml_response_unsignedNeither the response nor its assertion is signed. Turn on response or assertion signing in the IdP application.
saml_signing_certificate_mismatchThe response is signed with a certificate the provider does not have, usually after the IdP rotated its signing certificate. Update the provider's certificate (several can be configured while both are in use).
saml_issuer_mismatchThe response is signed with the configured certificate but comes from another IdP entity ID. Check the provider's IdP Entity ID against the IdP's issuer.
Invalid SAML responseAny other refusal of the response (for example an expired assertion or a broken signature). The server log carries the vendor's line.

The list is exported as SSO_SAML_REFUSAL_CAUSES from @objectstack/plugin-auth.


Per-provider sign-in options

Each registered SSO provider carries these switches. All of them are off by default. The first two apply to OIDC and SAML, the third to OIDC only.

OptionColumn on sys_sso_providerWhen on
allowIdpInitiatedallow_idp_initiatedThe provider may start a sign-in from the IdP's own portal, with no request from this platform.
allowJitallow_jitUnder the invite_only audience posture, the provider may create an account for a person who has none and holds no invitation.
skipUserInfoskip_user_infoThe provider's email, name and groups are read from its verified ID token, and its userinfo endpoint is not called. The stored endpoint is kept, and turning the option off uses it again.

Changing them. Use Setup → SSO Providers → Edit Sign-In Options on a provider row. It posts to POST /api/v1/auth/sso/update-provider with { providerId, allowIdpInitiated, allowJit, skipUserInfo }, and POST /api/v1/auth/sso/register takes the same members, as does the Register SSO Provider bridge (POST /api/v1/auth/admin/sso/register) for skipUserInfo, which the register form offers as Read Claims From the ID Token Only. The people who can change a provider today are the only ones who can change these options. A value that is not a boolean is refused 400 VALIDATION_ERROR, and nothing is written. Every option keeps a history, so every change writes a row to the audit ledger (sys_audit_log) and a field-level line to the record's activity feed, naming the old and the new value.

IdP-initiated sign-in

With the option off, a sign-in the IdP starts on its own is refused, and nobody is signed in:

  • SAML. A Response with no InResponseTo redirects to the error page with error=unsolicited_response.
  • OIDC. A callback that carries a code and no state redirects with error=state_not_found, and so does a request from an IdP app tile that carries an iss and no code (below).

With it on, @better-auth/sso accepts that sign-in, and the platform adds no sign-in mechanism of its own (the app-tile entry below only starts the vendor's own sign-in). A SAML Response with no InResponseTo is validated like any other and signs the user in. An OIDC callback with no state restarts the flow at the IdP's authorization endpoint with a fresh state, and the sign-in completes from there. A sign-in this platform starts is unchanged either way.

The option belongs to one provider: turning it on for one SAML provider does not accept unsolicited Responses for another. For OIDC, the column is the only place it is set. An allowIdpInitiated member written into the stored OIDC configuration is not read, and it is removed on the next write.

From an IdP app tile (OIDC third-party-initiated login)

An Okta or Entra ID app tile starts an OIDC sign-in by sending the browser to the app's initiate login URI with an iss parameter and no code (OIDC Core 1.0 §4, "Initiating Login from a Third Party"). Point that URI at the provider's callback:

https://<your-host>/api/v1/auth/sso/callback/<providerId>

In Okta that is the OIDC app's Initiate login URI, with Login initiated by set to Either Okta or App and the login flow Redirect to app to initiate login (OIDC Compliant). A portal that opens a fixed URL (Entra ID's My Apps opens the app's home page URL) can carry the parameter in that URL: …/sso/callback/<providerId>?iss=<the registered issuer, URL-encoded>.

A request there that carries iss and no code, state or error starts the platform's own sign-in at the IdP, with a fresh state (and PKCE when the provider uses it), as Sign in with SSO does, only when all four hold:

  1. the provider is a registered OIDC provider;
  2. its allowIdpInitiated option is on;
  3. iss is the provider's registered issuer, byte for byte (no case or trailing-slash folding);
  4. target_link_uri, when present, is on this deployment's origin or a trusted origin, sent once and not empty. The sign-in then lands there; without it, it lands on the deployment's base URL.

A request of this shape that misses any of the four redirects with error=state_not_found, as before, and writes one warn line naming the first condition that failed (provider_not_registered, provider_not_oidc, idp_initiated_off, issuer_mismatch, target_link_uri_untrusted, or start_refused when the start itself is refused, for example by domain verification). The request signs nobody in and sets no session cookie: the session is created only when the IdP comes back with a code for that state, the code exchange succeeds and the ID token verifies, all by @better-auth/sso. login_hint is passed on to the IdP.

Accounts for people who were not invited

Under the invite_only audience posture (the default, see Who may sign up), an SSO sign-in by a person who has no account and no pending invitation is refused. It redirects to the error page with error=SELF_REGISTRATION_CLOSED, and no user is created. These sign-ins are unchanged:

  • a person who already has an account;
  • a person with a pending invitation;
  • the first human of a deployment that has none yet;
  • every sign-in under the email_domain or open posture.

Admission is not acceptance: accepting an organization invitation needs a verified email address, and an account an SSO sign-in creates counts as verified only when the provider verified the address (Self-hosting).

To let a provider create accounts for everyone its IdP authenticates, as it did before this rule, turn on allowJit for that provider. With domain verification on, a provider still creates an account only for an email address at a domain it has proven, under every posture, with or without an invitation and with or without allowJit.

Skip the sign-in page (direct sign-in)

When a deployment signs people in through one identity provider, a signed-out visit can go straight to that provider and come back to the page it asked for, without showing the sign-in page first. It is off by default. Turn it on with the auth plugin's directSignIn option or with the environment, which wins field by field:

OS_AUTH_DIRECT_SIGN_IN_ENABLED=true
# Optional: which provider to use. Unset, the one configured provider is used.
# OS_AUTH_DIRECT_SIGN_IN_PROVIDER=okta
# Optional: hidden (default) or off.
# OS_AUTH_DIRECT_SIGN_IN_LOCAL_PATH=hidden
# Optional: hold (default) or identity-provider.
# OS_AUTH_DIRECT_SIGN_IN_AFTER_SIGN_OUT=hold
new AuthPlugin({
  directSignIn: { provider: 'okta', localSignIn: 'hidden', afterSignOut: 'hold' },
});
SettingValuesEffect
OS_AUTH_DIRECT_SIGN_IN_ENABLEDtrue / falseTurns it on or off, whatever the option says.
OS_AUTH_DIRECT_SIGN_IN_PROVIDERa providerIdAn oidcProviders entry or a registered SSO provider. Unset, the only one configured is used; with none or several configured, the sign-in page is shown as before.
OS_AUTH_DIRECT_SIGN_IN_LOCAL_PATHhidden (default) / offhidden keeps the password form at /login?local=1. off means the sign-in form offers no local way in. Any other value refuses to boot.
OS_AUTH_DIRECT_SIGN_IN_AFTER_SIGN_OUThold (default) / identity-providerWhere an explicit sign-out returns when the identity provider ends its own session. hold returns to the sign-in page, which holds (see No loops below). identity-provider returns through the direct sign-in door, so the person lands on the identity provider's own sign-in page. Any other value refuses to boot.

With off, the sign-in form offers no local way in, in any of its states: no email or phone form, no sign-up link and no "use password" link, also on an OAuth client's hand-off and when no provider can be started. It changes the form only: POST /api/v1/auth/sign-in/email still accepts a password, and the /register and /forgot-password pages are not changed by it.

Because the form then offers no email and password and no phone sign-in, the three checks that keep a way to sign in do not count them under off, even while they are switched on. Saving the auth settings refuses a Google change that removes the last way in (Google switched off, or a client credential cleared that no environment variable backs) with 400 SETTINGS_VALIDATION, and turning email and password on in that save does not help. The email and password switch itself is never refused under off, because the form draws it neither way. Setup's Delete SSO Provider on the last identity provider is refused 409 DELETE_RESTRICTED with nothing deleted. A boot with no identity provider reports at error under the grep token no_sign_in_method_at_boot. Another identity provider, a social or OIDC provider with a client ID and secret, or a host sign-in handoff still counts. Recover by setting OS_AUTH_DIRECT_SIGN_IN_LOCAL_PATH=hidden, and OS_AUTH_EMAIL_PASSWORD_ENABLED=true too when email and password sign-in is off, then restarting.

On a cloud-managed runtime whose deployment declares email and password off, the email and password switch is judged before these checks, under off or not: a save that turns it on is refused 400 SETTINGS_VALIDATION, a value stored on earlier is not applied, and email and password does not count as a way in for a Google change in the same save (Self-hosting).

What a visit does. The Console sign-in page reads features.directSignIn from GET /api/v1/auth/config. That is true only while a provider can be started, and only when this server mounted the door: a setting turned on after start-up takes a restart. A signed-out visitor is then sent to GET /api/v1/auth/sign-in/direct?callbackURL=<this page>, which starts the provider's own sign-in and redirects to it. After the sign-in, the visitor comes back to the same sign-in URL, which then continues as after any sign-in: organization pick, OAuth and mobile hand-offs, and ?redirect=. The door sets no session itself.

Return address. Only a same-origin path is kept. An absolute URL, //host, a backslash, a control character (a tab or a newline included), or any of these behind percent-encoding is dropped, and the sign-in returns to the Console home page. The query takes callbackURL only, once. Anything else is refused 400 VALIDATION_ERROR. When the sign-in lands back on the sign-in page instead (the provider's error, or a start the door could not make), the page's own ?redirect= comes with it, under the same same-origin rule.

No loops. The page shows itself, with a Continue with single sign-on button (and the reason, where there is one), instead of starting again when:

  • the provider sends back an error;
  • the visitor comes back without a session (for example, a browser that blocks this site's cookies);
  • the door could not start a sign-in. It redirects to /login?error=direct_sign_in_unavailable and writes one warn line naming why (no_provider, several_providers, provider_not_found or start_refused);
  • the identity provider's sign-in rate limit refused the start (too many starts from one address in a few seconds). It redirects to /login?error=direct_sign_in_rate_limited, the page asks the visitor to wait a few seconds and try again, and the warn line names rate_limited;
  • the IP allow-list refuses the visitor's network. The door is not exempt from the allow-list: a browser GET of the door from a refused address starts nothing and is redirected to /login?error=IP_NOT_ALLOWED (keeping a same-origin ?redirect=) instead of the 403 body, the page says sign-in is not allowed from this network, and every other auth request from that address is still refused 403 IP_NOT_ALLOWED;
  • the person just signed out in that tab. Often the identity provider's session outlives the platform's, so starting again would sign them straight back in. When the provider ends its own session too (an OIDC provider whose discovery document names an end_session_endpoint, or an SSO provider with sign-out turned on), the sign-out goes through the provider's logout and comes back to the sign-in page; the page still holds there. The tab keeps a short note of the sign-out for that round trip (at most ten minutes) and reads it once, so a reload of the held page, or another tab, starts the sign-in as for a fresh visit.

Sign-out through the identity provider. With afterSignOut: 'identity-provider' (or OS_AUTH_DIRECT_SIGN_IN_AFTER_SIGN_OUT=identity-provider), a sign-out that goes through the provider's logout comes back to GET /api/v1/auth/sign-in/direct instead of the sign-in page, so the person sees the identity provider's own sign-in page and no sign-in page of this deployment. Register that door's absolute address as a post-logout redirect URI at the provider. It cannot loop: the provider has just ended its own session, and the door starts a fresh sign-in without the browser's cookies, so the provider asks for credentials. A state the provider passes back from the sign-out is accepted once and ignored, since the door starts a new sign-in with its own. The Console uses the door only while features.directSignIn reads true; otherwise, and when the provider has no logout to go through, the sign-out ends on the held sign-in page as above.

An OAuth client's authorization hand-off (client_id or redirect_uri on the sign-in URL) keeps today's sign-in page. API keys, bearer tokens, /api/* and /mcp are never redirected.


Grant permission sets from IdP groups

An SSO provider, OIDC or SAML, can decide what its users may do from the groups the identity provider sends at sign-in. It uses the same group mappings (sys_idp_group_mapping) as a SCIM connection: one mapping model, two sources.

Where the groups come from. Set the provider's own claim mapping to fill groups: mapping.extraFields.groups names the OIDC claim or the SAML attribute that carries the user's groups, for example extraFields: { groups: 'groups' } in oidcConfig.mapping (or samlConfig.mapping) when the provider is registered through POST /api/v1/auth/sso/register. The claim's value may be one string or a list of strings. A provider whose mapping fills no groups signs users in as before.

For OIDC, the claim is read from the userinfo answer when it carries it, and otherwise from the ID token the server has already verified. Microsoft Entra ID puts groups only in the ID token, so it needs nothing more.

Groups overage (Entra ID). When a user belongs to more groups than fit in a token, Entra ID sends a reference to Microsoft Graph (_claim_names) instead of the groups. The server does not call Graph. That sign-in grants nothing from groups, removes the grants the provider made earlier, and logs one warn line per provider naming the fix: in the Entra ID application, emit only the groups assigned to the application, or point the groups claim at the claim that carries the application's own assignments instead of groups.

In Setup → SSO Providers, a platform administrator sets the same member without the API:

  • Register SSO Provider and Register SAML Provider take it as Map: Groups claim (OIDC) or Map: Groups attribute (SAML). Leave it blank to map no groups.
  • Show Groups Claim on a provider shows the claim it reads now, whichever way it was set.
  • Edit Groups Claim changes it, and a blank value removes it. Every other member of the provider's mapping is kept as stored. A provider without a groups claim signs users in as one registered without it.

Saving a mapping in Setup. In Setup → IdP Group Mappings, a platform administrator manages the mappings without the API:

  • Map SSO Group saves a mapping for an SSO provider: its Provider ID, the group as the groups claim sends it (a Group External ID or a Group Display Name), and a permission set picked from the security catalog.
  • Map SCIM Group does the same for a SCIM connection, named by its connection ID.
  • Delete Mapping, on a mapping's row, asks for confirmation and then deletes the mapping, as the delete route below does.

A save or a delete the server refuses shows the server's own message in the dialog, and nothing is stored. There is no generic New or Edit form on the list: a mapping changes only through these actions or the routes below.

Saving a mapping through the API. Operators and scripts save one mapping per group and permission set through POST /api/v1/auth/admin/scim/set-group-mapping, naming the provider with providerId:

curl -X POST http://localhost:3000/api/v1/auth/admin/scim/set-group-mapping \
  -H 'Content-Type: application/json' -H "Authorization: Bearer $ADMIN_SESSION" \
  -d '{ "providerId": "okta", "groupDisplayName": "Sales", "permissionSet": "sales_rep" }'
# → { success, data: { mappingId, created, providerId, permissionSet, organizationId, reprojected: false, … } }
  • Name the source with exactly one of connectionId (a SCIM connection) or providerId (an SSO provider). Name the group with exactly one of groupExternalId (matched against the group's id, such as an Entra ID group object id) or groupDisplayName (matched against its exact name).
  • The grant's organization is the provider's own organization. An unknown provider, or one that belongs to no organization, is refused 400 VALIDATION_FAILED on providerId. With SSO off the save is refused 503.
  • Only an ordinary permission set inside that organization can be granted. An administrator set, or any set outside the organization boundary, is refused 400 VALIDATION_FAILED on permissionSet, and nothing is stored. With no security service to judge the boundary, the save is refused 503.
  • POST /api/v1/auth/admin/scim/delete-group-mapping with { "mappingId": "…" } removes a mapping, and at once the grants of that set its provider made in that organization, unless another of the provider's mappings still names the set.

At every sign-in. The user's grants follow the IdP's groups. A mapped group grants its set in the provider's organization, and a group the user has left loses its set at their next sign-in. A sign-in with no groups claim removes the grants that provider made earlier. The boundary is judged again before every grant. Only grants the provider itself made are ever removed: a grant made by hand or through SCIM is never touched. A saved mapping applies at each member's next sign-in, because a provider sends groups only when someone signs in; use SCIM when a group change must take effect between sign-ins.

When applying the mappings fails, the sign-in still succeeds and the failure is logged at error. The user keeps the grants of their previous sign-in until the next one applies the mappings again.


Deleting an SSO provider

Deleting a provider ends the sessions a sign-in through it opened and removes the permission-set grants its group mappings projected. Setup's Delete SSO Provider (or POST /api/v1/auth/sso/delete-provider with { "providerId": "…" }) first shows what the delete removes, then:

  • unlinks every user who signed in through the provider;
  • ends the live sessions signed in through it. Each session an SSO sign-in opens records its provider (sys_session.sso_provider_id); the delete revokes the live sessions that record this provider, with revoke_reason sso_provider_deleted, so their next request is signed out. A session signed in any other way (a password, another provider) is left as it is;
  • removes its group mappings and the permission-set grants they projected (the grants whose reason is the provider's projection marker), never a grant made by hand or by SCIM.

The answer names each count: unlinkedUsers, usersWithoutOtherSignIn, revokedSessions, removedGroupMappings and removedGrants. When the cleanup after the delete fails, the answer says so (dependentsRemoved: false) and the failure is logged once at error.

At every boot, the projected grants and live sessions of a provider that no longer exists are removed too: a projected grant whose reason names a provider with no sys_sso_provider row is deleted, and a live session that records such a provider is revoked. So the grants and sessions a failed cleanup left are settled at the next start; the boot logs at info what it removed, and at error when it could not. The boot does not remove the provider's group mappings: delete each one with Setup's Delete Mapping on its row, or POST /api/v1/auth/admin/scim/delete-group-mapping with { "mappingId": "…" }. Several servers booting at once may run the sweep together; each removes what is left and none reports the others' removals as a failure.


Verify configuration

Restart the server (pnpm dev), then:

curl http://localhost:3000/api/v1/auth/config

Expected response (the endpoint wraps getPublicConfig() in a { success, data } envelope; abbreviated — getPublicConfig() also returns disableSignUp/requireEmailVerification on emailPassword and additional features keys such as multiOrgEnabled, oidcProvider, deviceAuthorization, and admin):

{
  "success": true,
  "data": {
    "emailPassword": { "enabled": true },
    "socialProviders": [
      { "id": "google", "name": "Google", "enabled": true, "type": "social" },
      { "id": "github", "name": "GitHub", "enabled": true, "type": "social" },
      { "id": "okta",   "name": "Okta SSO", "enabled": true, "type": "oidc" }
    ],
    "features": { "twoFactor": false, "organization": true }
  }
}

The Console /login and /register pages will now show a button for each enabled provider.


OAuth flow

Social providers (Google, GitHub, Microsoft, Apple):

  1. User clicks Continue with Google (or similar).
  2. Client calls POST /api/v1/auth/sign-in/social with { provider: "google", callbackURL }.
  3. Browser redirects to the provider's consent screen.
  4. Provider redirects to /api/v1/auth/callback/google.
  5. better-auth creates a session and redirects to callbackURL.

OIDC/enterprise providers (oidcProviders): better-auth's generic-OAuth plugin registers each one as a social provider and adds no endpoints of its own, so the flow uses the same two routes as above.

  1. User clicks Continue with Okta SSO.
  2. Client calls POST /api/v1/auth/sign-in/social with { provider: "okta", callbackURL }, where provider is the entry's providerId.
  3. Browser redirects to the provider's authorization endpoint.
  4. Provider redirects to /api/v1/auth/callback/okta. better-auth exchanges the code, reads the user's profile from the ID token or userInfoUrl, creates a session and redirects to callbackURL.

Linking to an existing account

A social, OIDC or enterprise SSO sign-in may arrive with an email that already belongs to a local account, one that is not linked to this provider yet. The platform then links the identity to that account automatically (an implicit link) only under these rules:

  • The local account's email must be verified. If it is not, no link is written and the callback redirects with error=account_not_linked. The user signs in with their existing method and links the provider from account settings, or verifies their email first.
  • The platform identity provider is the exception. objectstack-cloud links to an unverified local account, because it creates the environment owner's account itself, without a mailbox round-trip.
  • An unlink is honoured. After a user unlinks a provider, signing in with that provider no longer re-links it, for any provider, objectstack-cloud included. The user links it again explicitly from account settings (POST /api/v1/auth/link-social while signed in), which also ends the refusal. If the unlink cannot be recorded, the unlink itself fails and the provider stays linked.

An explicit link from account settings does not depend on whether the signed-in user's email is verified. It still requires the provider to vouch for the email (a trusted provider or an email_verified claim) and the email to match the account's.

account.accountLinking.requireLocalEmailVerified in the auth plugin config changes the first rule. Unset (the default) gives the rules above. true applies the verified-email requirement to every provider, objectstack-cloud included. false turns the requirement off, which the library warns is an account-takeover risk; the unlink rule still applies. account.accountLinking.trustedProviders relaxes only the provider-side email_verified claim and never the local requirement.


Notes

  • OS_AUTH_SECRET must be set to a random string in production (a long random value of 32+ characters is recommended). AUTH_SECRET and BETTER_AUTH_SECRET are accepted as legacy aliases (read silently, without a deprecation warning). If no secret is set, the auth plugin is skipped in production.
  • OS_AUTH_URL (or OS_BASE_URL as a fallback) must match the domain registered with each provider; it determines the base URL used to build OAuth callback URLs.
  • Never commit client secrets to source control — use a secrets manager in production.
  • The redirect URI registered with each provider must match exactly: https://<your-domain>/api/v1/auth/callback/<provider-id>.

On this page