How it works
Enforcement is keyed off the connection’semail_domain_allowlist. When enforce_login is true, any login attempt whose email domain resolves to that connection is redirected into SAML, and the other methods step aside:
- OTP create — submitting an email identifier whose domain is enforced is refused with the
saml_login_requirederror (HTTP403). The SDK is expected to restart the flow via the SAML initiate endpoint. - OAuth callback — when the IdP-supplied email’s domain is enforced, the OAuth flow is abandoned (no account is created or linked) and the user is redirected into a fresh SAML
AuthnRequest. The PKCE challenge and dispatch from the OAuth state are carried over.
Enable enforcement
Setenforce_login to true on the connection’s behavior block. You can do this at creation or with a PUT:
@acme.com email can no longer obtain a session via OTP or OAuth — only through this Okta connection.
The saml_login_required error
When a client tries to start an OTP login for an enforced email, POST /v1/session/otp returns 403 with:
SAMLLoginRequiredError so you can transparently fall back to loginWithSAMLByEmail — see Enforce SSO login (Web SDK).
Notes and edge cases
- Ambiguous or unmatched domains are not enforced. Connection creation rejects overlapping allowlists, so a domain resolves to at most one connection; an unresolvable domain falls through to the normal login flows.
- IdP-initiated logins are unaffected. Enforcement only intercepts the OTP and OAuth entry points — a user clicking the IdP tile always lands on the ACS endpoint.
- Existing sessions are not revoked. Enforcement governs new logins; it does not invalidate sessions a user already holds.
What’s next?
Enforce login (Web SDK)
Handle
saml_login_required and fall back to SAML in the browser.SAML login (Web SDK)
Start a standard SAML login from the JavaScript SDK.