Build a custom flow for authenticating with SAML connections
Before you start
You must configure your application instance through the Clerk Dashboard for the SAML connection(s) that you want to use. Visit the appropriate SAML guide for your platform to learn how to configure your instance.
Create the sign-up and sign-in flow
When using SAML, the sign-in and sign-up flows are equivalent. A successful SAML flow consists of the following steps:
- Start the SAML flow by calling
SignIn.authenticateWithRedirect(params)
orSignUp.authenticateWithRedirect(params)
. Both of these methods require aredirectUrl
param, which is the URL that the browser will be redirected to once the user authenticates with the identity provider. - Create a route at the URL that the
redirectUrl
param points to. The following example names this route/sso-callback
. This route should either call theClerk.handleRedirectCallback()
method or render the prebuilt<AuthenticateWithRedirectCallback/>
component.
The following example shows two files:
- The sign-in page where the user can start the SAML flow.
- The SSO callback page where the SAML flow is completed.
SAML account transfer flows
It is common for users who are authenticating with SAML to use a sign-in button when they mean to sign-up, and vice versa. For those cases, the SignIn
and SignUp
objects have a transferable
status that indicates whether the user can be transferred to the other flow.
If you would like to keep your sign-in and sign-up flows completely separate, then you can skip this section.
The following example demonstrates how to handle these cases in your sign-in flow. To apply the same logic to the sign-up flow, simply replace signIn.authenticateWithRedirect()
with signUp.authenticateWithRedirect()
in your code.
Feedback
Last updated on