Identity Federation
Identity Federation is an enterprise feature, available only in the Ory Polis Enterprise License images. See Enterprise Features.
This feature allows you to federate multiple Identity Providers (IdPs) without needing any additional plugins or code changes. Your app signs in through an Identity Federation App, which can be a SAML app or an OIDC app, and Ory Polis acts as its identity provider. Extremely useful in cases where the SAML support is restricted to a single provider and you need to support multiple IdPs. Contact us to find out more.
SAML flow
Here is how the flow works for a SAML app if you are using Ory Polis as a SAML IdP and want to federate with another identity provider (IdP) (Eg: Okta):
- The user accesses the Service Provider's (SP) login page
- The user clicks on the "Login with SAML" button
- The SP sends SAML Request to Ory Polis's SSO endpoint
- Ory Polis displays the list of IdP available for the user to choose from (if there is more than one IdP) based on the requested tenant and product combination
- Ory Polis redirects the user to the chosen IdP for authentication
- After successful authentication, IdP sends (POST) SAML Response to Ory Polis's ACS endpoint
- Ory Polis process SAML Response from the IdP and create a new SAML Response to send (POST) back to the SP's ACS endpoint
- SP process SAML Response from Ory Polis and create a new session for the user (Depending on the SP's implementation)
Redirect URLs for OIDC apps
This section applies to OIDC apps only. A SAML app delivers its SAML Response to the ACS URL configured on the app and has no redirect URL.
An OIDC app accepts a redirect_uri only when it matches one of the app's Allowed redirect URLs. The redirect URLs registered
on the SSO connections the app signs users in through do not count: those belong to clients that use the connection directly,
through its own client ID or its tenant and product, and a different client's registration must not decide where your app's
authorization code is sent. The authorization request and the callback from the Identity Provider are both checked against the
app's list, so a redirect_uri that is missing from it fails with Redirect URL is not allowed. before any code is issued.
Earlier releases also accepted a redirect_uri that was registered only on one of the app's SSO connections. If your app relied
on that, sign-in through the app fails after upgrading until you add the redirect URL to the app itself:
- From the Admin Portal go to Identity Federation > Apps, open the app and add the redirect URL under Allowed
redirect URLs, or update the app through the API with the same
redirectUrllist. - Repeat for every OIDC app that clients on that redirect URL sign in through. One client can only use one app at a time, so the
app is the one named by the
client_idthe client sends,fed_followed by the app ID. - Leave the SSO connections as they are. Their redirect URLs still apply to clients that use the connection directly.
Whether a redirect_uri matches an entry is decided the same way as for an SSO connection: by scheme, host and port, or by the
full URL when OPENID_REDIRECT_EXACT_MATCH is true.
Token exchange for OIDC apps
This section applies to OIDC apps only.
To exchange an authorization code issued for an OIDC app, send the app's own client ID and client secret to the token endpoint, in
the request body or in an Authorization: Basic header. This applies whether or not the login used PKCE; a PKCE login also sends
its code_verifier. The exchange is rejected with HTTP 401 invalid_client when the app's credentials are missing or other
credentials are sent in their place, such as an SSO connection's client ID and secret, or a tenant and product with the
CLIENT_SECRET_VERIFIER.
Earlier releases also accepted those other credentials, or a code_verifier alone. If your app relied on that, sign-in through
the app fails after upgrading until the client sends the app's credentials:
- From the Admin Portal go to Identity Federation > Apps and open the app to find its client ID and client secret.
- Configure the client to send them in every token request for the app.
User identifiers
This section applies to OIDC apps only. A SAML app is unaffected: the SAML Response it sends to the Service Provider carries the NameID the upstream Identity Provider asserted, exactly as it did before.
An OIDC app fronts several Identity Providers behind one issuer, so the identifier it returns for a user is derived from the upstream connection that authenticated them as well as from the identifier that connection asserted. Two connections behind one app therefore never return the same identifier for two different people, which they could otherwise do whenever both Identity Providers happen to use the same local identifier for someone.
That identifier is the sub claim in the ID token and the id field from the userinfo endpoint. Store your accounts under that
value.
Further claims are returned alongside it, in both the ID token and the userinfo response:
upstream_subholds the identifier the upstream connection resolved for the user, before it was scoped to the app. Do not store an account under it — the connections behind one app can assert the same value.logoutNameIdholds the NameID exactly as the upstream SAML Identity Provider asserted it. Pass this asnameIdwhen you send a single logout request, because the upstream provider knows the user by this value.legacy_subholds the identifier the app returned before identifiers became connection-scoped, whileOPENID_IDFED_LEGACY_SUBJECTistrue. If you have accounts stored under the old identifier, look them up bylegacy_subon the next sign-in and savesubin its place, then set that variable tofalse. Do not storelegacy_subitself; the claim will be removed in a later release.
If two people were previously sharing one identifier, they now receive different ones. The account you already hold follows whichever of them signs in first and the other is provisioned as a new account, so review those by hand.
Logins started by the Identity Provider
This section applies to SAML apps that sign users in through OIDC connections. OIDC apps do not support it.
An OIDC Identity Provider behind a SAML app can start a sign-in by sending the user to
/api/identity-federation/oidc/idp-login/<app ID> with its issuer in iss, and optionally target_link_uri, as in OpenID
Connect third-party initiated login. Ory Polis signs the user in through the connection, among the app's tenants, whose provider
has that issuer, then sends the SAML Response to the app's ACS URL with target_link_uri as the RelayState. A target_link_uri
must match one of that connection's redirect URLs.
- A connection configured with inline metadata matches on the
issuerin that metadata. These connections are checked first and need no request to the provider. - A connection configured with a discovery URL matches on the issuer its discovery document advertises. Each Ory Polis instance keeps a fetched document in memory for 15 minutes, and connections whose document is in memory are checked next, again with no request. Only then are the remaining documents fetched during the login.
- Ory Polis fetches at most four discovery documents at a time for one login, the rest waiting their turn, and the first connection to match is used. A login waits at most 10 seconds for discovery; if no connection has matched by then, it fails, but discovery carries on in the background, so retrying the login can match.
- When a provider's discovery document can't be fetched, its connection is skipped and Ory Polis tries the provider again after a short backoff, up to 30 seconds. If the document was fetched before, the last good copy keeps being used for up to 24 hours.
Selecting a tenant
This section applies to OIDC apps only. An OIDC app signs users in through the connections of each of its tenants. To send a user
straight to the connections of one tenant, add tenant and product to the authorization request alongside the app's
client_id. The product must be the app's product and the tenant must be one of the app's tenants; Ory Polis rejects any other
tenant or product. The ID token is still issued for the app, with the same user identifiers as a login without a tenant. See
How the connection is chosen.
Visit Create an Identity Federation App to learn how to create and configure an Identity Federation App.
