WorkOS Docs Homepage

Identity Provider-initiated SSO

The instructions in the Quick Start guide focus on setting up Service Provider (SP)-initiated SSO. In these scenarios, when a user attempts to login, they navigate to an application (a service provider) and are then redirected to the Identity Provider (IdP) for authentication, via the WorkOS API.

Alternatively, users are often able to start the process from the Identity Provider itself. Enterprise companies will often provide an IdP dashboard where employees can select any of the eligible applications that they can access via the IdP. In these cases, the IdP is initiating the SSO request, not the service provider.

IdP-initiated authentication is inherently more exposed to security vulnerabilities since the IdP delivers an SSO response to the Service Provider that the Service Provider had not initiated. There is no way for the application to definitively determine that these unsolicited responses have not been issued or compromised by an attacker, which exposes IdP-initiated SSO to potential CSRF Login and other "man-in-the-middle" attacks. As a result, WorkOS recommends using SP-initiated authentication whenever possible.

The instructions in this guide will allow the Identity Provider to issue IdP-initiated SSO calls to your application's callback endpoint. IdP administrators can configure the RelayState that the IdP will send with these requests. Currently, however, WorkOS does not support processing a RelayState for IdP-initiated authentication flows, so it should be left blank. If a RelayState is received, the request will result in an error. Upon a successful request, the user will be redirected to the default redirect URI in the WorkOS configuration.

We have recently added Beta support for reading the redirect_uri from the RelayState during an IdP-initiated SSO request. This allows an IdP administrator to configure the location where user will be redirected after a successful IdP-initiated authentication request. WorkOS will retrieve the redirect URI from the IdP's RelayState, where it must be configured in the format of a URL parameter: redirect_uri=[uri]. The URI must be one of the Redirect URIs specified in your WorkOS Dashboard, otherwise, the request will result in an error. Any other values in the IdP's RelayState will be ignored and discarded.

RelayState support for IdP-initiated authentication is currently behind a feature flag, please reach out to WorkOS support if you'd like to use it or learn more about it.

We have recently added Beta support for fully disabling IdP-initiated SSO logins for a connection. Once disabled, any attempted IdP-initiated requests will fail with an idp_initiated_sso_disabled error.

Disabling IdP-initiated SSO is currently behind a feature flag, please reach out to WorkOS support if you'd like to use it or learn more about it.

For applications that need to support IdP-initiated workflows, but would like to mitigate the security risks of unsolicited SAML responses, WorkOS recommends the following:

  • Disable IdP-initiated SSO for your connection.
  • Adjust your callback method to capture the idp_initiated_sso_disabled error.
  • Start a new SP-initiated request from the callback when the error is detected.

The error callback will include the connection and organization ID's, which can be used to request a new authorization URL for the SP-initiated request. The new request will generally be transparent to the user, as they are already logged in to the Identity Provider.

Callback Endpoint with IdP-Initiated error support