# Connect an application to enterprise SSO

Connect your customer's identity provider through SAML or OpenID Connect.
Use organization-scoped identities with your own application sessions or
Identiblok's hosted sign-in. The examples provide server integration modules
for your framework's login, callback, and session handlers.

## Choose a handoff

| Application need | Entry point | Verified result |
| --- | --- | --- |
| Your own session, with a mapped customer profile | Standalone `/sso/authorize` and `/sso/exchange` | Scoped subject, profile and assurance |
| Identiblok-hosted organization sign-in with OIDC | `/oauth/authorize`, with exact organization and connection | Signed ID token and scoped token family |
| Existing SAML relying party | Organization/connection-specific SAML SSO URL | Signed assertion with scoped NameID and organization |

A managed subject is `ibk_ent_` followed by 32 hexadecimal characters. It belongs
to one application, organization and connection. Keep those IDs together in your
application session. Never select a personal account by email, treat this as a
global AuthID credential, or let callback parameters choose the expected scope.
Use trusted server configuration or a server-maintained allowlist to select each
customer's connection. Domain discovery supplies routing hints only.

## Configure a connection

In your project, select the intended environment and open **Enterprise SSO**.
Select the customer organization, create a connection, and copy its callback and
metadata values into the provider. Save the provider's exact issuer and reviewed
configuration. OIDC secrets are server-only, masked on entry and omitted on read;
a blank secret during editing preserves the saved value. Stable issuer/subject
choices cannot change after they are supplied. Create a replacement connection
for a new identity source.

Choose **Verify connection** and return in the same tab. Verification covers
only the current configuration and expires after 24 hours. It creates no
customer membership and does not enable login. Then review enrollment and assurance,
enable the connection, and separately preview and confirm **Require SSO** if
needed. JIT starts off; enable it only for intended customer enrollment. Existing
invitation-only application policy still applies. Trust in email or MFA requires
explicit provider-specific policy; an attribute mapping alone grants neither.

## Node and Python

Install the versioned server packages:

```sh
npm install https://identiblok.com/downloads/management/identiblok-authid-0.4.0-alpha.1.tgz
python -m pip install https://identiblok.com/downloads/management/identiblok_authid-0.4.0a1-py3-none-any.whl
```

Use `EnterpriseSSO` from `@identiblok/authid/sso` or `identiblok_authid` for
standalone handoff. Node `begin` and `complete` are asynchronous; Python `begin`
is synchronous and `complete` is asynchronous. Both clients pin the complete
scope, preserve S256 PKCE and state in durable storage, bind the browser, consume
transactions atomically, bound exchange responses and check the returned scope.
Failed or uncertain exchanges require a new sign-in, never a code retry. Hosted
Python OIDC uses one ten-second deadline across token and JWKS requests; run its
synchronous completion outside an async event loop (or in a worker thread). The
service permits 30 standalone exchanges per client per minute.

Executable source examples:

- `examples/authid/node-enterprise-sso.mjs`
- `examples/authid/python-enterprise-sso.py`
- `examples/authid/node-enterprise-oidc.mjs`
- `examples/authid/python-enterprise-oidc.py`

The Node examples also need `sqlite-transactions.mjs` and Node 24+; the hosted
OIDC example additionally uses `openid-client` 6 with signed-token verification.
Python's hosted example uses `AuthIDOIDC` with both `organization_id` and
`connection_id`. Omitting both keeps the personal-ID contract; never infer the
mode from an unverified token. Upgrading this SDK changes its transaction key
namespace, so pending logins from older versions must restart.

Set `AUTHID_APPLICATION_ID`, `AUTHID_ORGANIZATION_ID`, `AUTHID_CONNECTION_ID`,
`AUTHID_OIDC_CLIENT_ID`, `AUTHID_OIDC_CLIENT_SECRET`, `AUTHID_OIDC_REDIRECT_URI`,
and `AUTHID_STATE_DB`. The client belongs to the selected application's environment.
`AUTHID_ORIGIN` defaults to `https://auth.identiblok.com`. The standalone helpers
and Node hosted example require an exact HTTPS callback without query parameters.
Keep all credentials out of browser bundles, URLs, logs and public variables.

Your web framework must generate 32 random bytes as a 43-character unpadded
base64url browser binding and set it in a five-minute Secure, HttpOnly,
SameSite=Lax, Path=/ `__Host-authid-tx` cookie with no Domain attribute. Pass that
cookie into begin/complete; never read the binding from the callback query.
After successful completion, rotate your application's session ID, delete the
transaction cookie and store only the verified identity and required profile.
Reject absent/expired cookies and keep CSRF protection on application actions.
Map errors to a neutral restart message; do not log whole provider responses,
tokens, exception objects or callback URLs.

SQLite is for one persistent host. Vercel and other multi-host/ephemeral runtimes
need shared durable storage implementing atomic insert-if-absent `put`, unexpired
`get`, and single-winner `take`; see the example README. Never replace this store
with a process-local map in production.

The standalone convenience clients do not send invitation secrets. For an
invitation-only flow, implement the documented authenticated backend
`POST /sso/authorize` contract and preserve the same browser/state/PKCE checks.
Never place the invitation in a browser URL. See the protocol contract for the
exact request and lifetime.

## Permissions, revocation and logout

A completed sign-in is identity proof, not a permission decision. Check protected
actions online with the signed permissions client and the verified organization
subject and exact organization. Do not cache positive permission decisions.
Permission checks validate current membership and grants; they do not revalidate
your application's saved SSO proof, connection status or authentication-policy
version. A permission can remain allowed after a provider is disabled.

New sign-in/exchange and hosted OIDC refresh/userinfo recheck their current SSO
authority. A standalone application's own session does not: set a short fixed
session expiry (for example, five minutes), require a fresh SSO handoff after
expiry, and reauthenticate before sensitive actions. Choose this maximum stale
authentication window deliberately. Do not extend it merely because a permission
check succeeds. Your sessions and already-issued offline SAML assertions do not
disappear remotely. Clear your own session on logout, and manage upstream
provider sessions and directory membership separately.

## Provider configuration recipes

Use a public HTTPS provider with a valid certificate. Verify your tenant's
connection after configuring the provider; private addresses and self-signed
endpoints are rejected.

### Okta SAML

Create a SAML 2.0 application integration. Use the Identiblok ACS value for Single
sign-on URL, Recipient and Destination; use its entity ID for Audience URI.
Leave default RelayState empty. Select Persistent Name ID with an immutable
administrator-controlled user identifier, not an editable email/username.
Enable assertion signing, RSA-SHA256 and SHA256; keep assertion encryption off.
If signing the response too, use the same certificate for both signatures.
Enable honoring Force Authentication. For signed request validation, upload the
Identiblok public signing certificate and enable Signed Requests. Copy Okta's
exact issuer, SSO URL and current public signing certificate into Identiblok.
Assign a designated setup account or group before verifying the connection.

Field names and their meanings: [Okta SAML field reference](https://help.okta.com/en-us/Content/topics/apps/aiw-saml-reference.htm).
Identiblok requires the stricter signing/stable-subject settings above. An Okta
app tile that sends an unsolicited assertion is unsupported; start at Identiblok.

### Keycloak OIDC

Create a dedicated OpenID Connect client in the intended realm. Enable Client
authentication and Standard Flow; disable implicit/direct-access/service-account
flows. Register only Identiblok's exact callback as a valid redirect URI and
require S256 PKCE. Use Client ID and Secret credentials with
`client_secret_basic`, and RS256 ID tokens. Enter the realm's exact issuer in
Identiblok, review discovery's proposed endpoints, then save. Ensure client
scopes include `basic` (which supplies `auth_time`), `profile` and `email`. Keep
only the mapped profile fields; do not add extra ID-token audiences. Verify the resulting token's `auth_time`, issuer, sole client
audience, nonce and stable `sub` against Identiblok's validation. Configure MFA
trust only after verifying the realm's enforced method and exact ACR/AMR signal.

Provider controls: [Keycloak client administration](https://www.keycloak.org/docs/latest/server_admin/index.html#_oidc_clients).
Identiblok's supported subset also requires `auth_time` and accepts only RS256
with the configured client as sole audience; provider defaults are not evidence
that those conditions have been met.

### Keycloak SAML

Create a dedicated SAML client whose Client ID is Identiblok's exact entity ID.
Set the exact ACS as the POST assertion consumer URL and the sole valid redirect.
Enable client signature validation and import Identiblok's public signing
certificate. Enable both document and assertion signatures using RSA-SHA256,
exclusive canonicalization and SAML Signature Key Name `NONE`. Use persistent
NameID, force POST binding and include AuthnStatement. Leave assertion encryption
off. Map only the required user properties (for example, email to `mail`).
Pin the realm issuer, SSO endpoint and active RSA signing certificate in Identiblok.

Keycloak documents the [signature key name and client controls](https://www.keycloak.org/docs/26.6.4/server_admin/index.html#_saml_clients).
Its [upgrade guide](https://www.keycloak.org/docs/latest/upgrading/index.html) describes
the `basic` client scope. Verify the connection in Identiblok after changing provider settings.

## Rotation and recovery

Adding a second SAML certificate begins a fixed 30-day overlap. During overlap,
either currently valid key works; afterward only the second key works. Remove
the old key and promote the replacement deliberately. Every credential/config
edit clears connection verification and returns the connection to draft, even if it was
enabled. Verify the updated connection and enable it. A required-SSO policy stays required
and fails closed during this interval; plan an appropriate maintenance window.

Review enforcement's session impact before confirming. Expired or changed impact
requires a fresh preview. Disabling a provider does not relax a requirement;
relaxing one is a separate administrator action and never revives old sessions.
If verification fails, use **Return to SSO setup**, correct the saved
configuration, and verify the connection again. Do not paste assertions or secrets into
support messages. Use redacted event/request IDs and connection versions.

Management SDKs expose scoped connection, discovery, policy and requirement
operations from the generated contract. General CLI/MCP tools exclude secrets,
credential handoffs, verification links, discovery email and enforcement confirmations.
Use the console or a purpose-built backend for those operations.
