How SAML v2 IdP-Initiated Login Works
On this page
In a service provider initiated loginA SAML workflow where login starts at the Service Provider., your application starts the login. Your application sends the user to the Authorize endpoint, FusionAuth sends the user to the SAML v2 Identity Provider (IdP), and the IdP returns a SAML response to FusionAuth.
In an IdP-initiated login, the user starts at the IdP, such as a tile in an Okta or Azure AD dashboard. The IdP posts a SAML response to FusionAuth without a request from FusionAuth. FusionAuth then completes an OAuth Authorization Code grant for the Application, and sends the user to your application with an authorization code.
FusionAuth doesn't recommend IdP-initiated login. FusionAuth didn't start the login, so FusionAuth can verify less about the SAML response. FusionAuth must also accept a cross-site POST request from the IdP. Enable IdP-initiated login only to support a legacy integration, or when the user experience matters more than the risk.
Identity Provider Types#
The following Identity Provider types accept IdP-initiated logins:
- A SAML v2 Identity Provider with Enable IdP initiated login turned on. This type supports SP-initiated and IdP-initiated logins with the same configuration. Available in FusionAuth
1.43.0and later. - A SAML v2 IdP Initiated Identity Provider. This type supports only IdP-initiated logins. Use this type for an IdP that can't start an SP-initiated login. Available in FusionAuth
1.26.0and later.
Both types require a paid plan, and handle the login in the same way.
The Login Flow#
An IdP-initiated login skips the Authorize request. During an SP-initiated login, the Authorize request carries the redirect_uri and scope parameters from your application. During an IdP-initiated login, FusionAuth reads those values from the IdP's request instead.
During an IdP-initiated login, FusionAuth reads the redirect URI and scope from the request that the SAML v2 IdP sends to the ACS URL.
The IdP sends the SAML response to an ACSThe service provider endpoint that receives SAML responses from an identity provider. When FusionAuth acts as a service provider, the endpoint is /samlv2/acs. URL for one Application:
<base_url>/samlv2/acs/<identityProviderId>/<clientId>
<clientId> is the Client Id of the Application. FusionAuth lists the URL for each enabled Application in IdP Initiated Callback URLs (ACS) in the Integration Details of the Identity Provider. For more information, see Integration Details.
After FusionAuth validates the SAML response, FusionAuth logs the user in and creates an SSO session. The code exchange doesn't use PKCE, even when the Application requires PKCE, because the IdP can't send a code challenge.
Redirect URI#
FusionAuth chooses the redirect URI in the following order:
- The
RelayStateparameter that the IdP sends with the SAML response. Available in FusionAuth1.41.0and later. - The
redirect_uriquery parameter on the ACS URL. - The first URL in Authorized redirect URLs on the OAuth tab of the Application. FusionAuth skips URLs that contain a wildcard.
The redirect URI must match a URL in Authorized redirect URLs. When the redirect URI doesn't match, FusionAuth shows an error page with the invalid_redirect_uri reason, and doesn't log the user in.
Most IdPs have a setting for a fixed RelayState value, such as Default RelayState in Okta. When an IdP can't send RelayState, URL encode the redirect URI and add the encoded value to the ACS URL:
<base_url>/samlv2/acs/<identityProviderId>/<clientId>?redirect_uri=https%3A%2F%2Fexample.com%2Fwelcome
Don't add RelayState to the ACS URL as a query parameter. FusionAuth combines a RelayState query parameter with the RelayState form value from the IdP, and the combined value doesn't match any redirect URL.
When the Application is the FusionAuth Admin UI, FusionAuth ignores the redirect URI and sends the user to the Admin UI.
Scope and Refresh Tokens#
The Application settings don't add a scope to an IdP-initiated login. To request scopes, add the scope query parameter to the ACS URL. Separate scopes with an encoded space (%20), and join query parameters with &:
<base_url>/samlv2/acs/<identityProviderId>/<clientId>?scope=openid%20offline_access
The token response depends on the scopes:
- FusionAuth returns a refresh token when the scopes include
offline_accessand Generate refresh tokens is enabled on the Application. To use the refresh token later, enable theRefresh Tokengrant in Enabled grants. - FusionAuth returns an Id token when the scopes include
openid.
When the Application is the FusionAuth Admin UI, FusionAuth adds the offline_access scope. For more information, see Reserved Scopes.
Limitations#
IdP-initiated login doesn't support CIMD clients. The Applications list of an Identity Provider with IdP-initiated login doesn't show CIMDAn OAuth 2.0 extension in which the client identifier is an HTTPS URL that hosts a JSON document describing the client's metadata. The authorization server retrieves the metadata from the URL instead of requiring a Dynamic Client Registration request. domains. Available since 1.70.0
Related
Reference for the form fields and Integration Details of the SAML v2 and SAML v2 IdP Initiated Identity Providers.
Learn about the APIs for creating, retrieving, updating and deleting SAML v2 IdP Initiated identity providers.
Learn how to let users log in to a third-party application, such as a SaaS product, with their FusionAuth accounts over OpenID Connect or SAML v2.
Learn how to let users log in to FusionAuth from the Okta dashboard with SAML v2 IdP-initiated login.