Add an OpenID Connect IdP

On this page

Add a login button that lets users authenticate through an external OpenID Connect Identity Provider. After you configure the Identity Provider, you can enable the button for one or more Applications.

Some OpenID Connect providers need specific configuration. The following guides cover those providers:

The following login page shows a button for the PiedPiper OpenID Connect Identity Provider:

A FusionAuth login page with a button to log in with the PiedPiper OpenID Connect Identity Provider.
A FusionAuth login page with a button to log in with the PiedPiper OpenID Connect Identity Provider.

Create an OpenID Connect Identity Provider#

The owner of the OpenID Connect provider supplies the client Id and the client secret. When you don't know the values, contact the owner.

When the provider has a well-known configuration endpoint, FusionAuth discovers the other endpoints from the Issuer field. For example, for an Issuer of https://login.piedpiper.com, FusionAuth requests https://login.piedpiper.com/.well-known/openid-configuration. When the provider has no well-known configuration endpoint, turn off Discover endpoints, and enter the URL of each endpoint in the three fields that appear.

To enable OpenID Connect for an Application or CIMD domain:

  1. In the Admin UI, navigate to Settings -> Identity Providers .

  2. Click the arrow next to the add button, and select OpenID Connect .

  3. Select the Tenant for the Identity Provider, or select Global identity provider. You can't change the scope later. For more information, see Identity Provider Scope.

  4. Fill out the form. Your identity provider supplies most of the values. For a description of each field, see Form Fields.

  5. On the Applications tab, turn on Enabled for each Application or CIMD domain that uses the Identity Provider.

  6. To register new users for the Application with the Application's default roles, turn on Create registration. When Create registration is off, a user needs a registration for the Application before the user can log in through the Identity Provider.

  7. Click .

The login page of each enabled Application then shows a login button for the Identity Provider. An Identity Provider with managed domains asks for the user's email address instead of showing a button.

The form to add an OpenID Connect Identity Provider in the Admin UI.
The form to add an OpenID Connect Identity Provider in the Admin UI.

Form Fields#

Id
  • Optional

An optional UUID. When you leave out the Id, FusionAuth generates a unique Id.

Tenant
  • Optional
  • Available since 1.62.0

The Tenant that this Identity Provider belongs to. The field appears only when you select a specific Tenant on the previous page. When you select Global identity provider on the previous page, the field doesn't appear.

Name
  • Required

A unique name for the Identity Provider. FusionAuth uses the name for display only, and you can change the name later.

Client Id
  • Required

The client Id that FusionAuth uses to authenticate with the provider. The owner of the Identity Provider supplies the value.

Client authentication
  • Optional
  • Available since 1.15.3

The client authentication method that FusionAuth uses with the OpenID Connect Identity Provider. For more information, see Client Authentication in the OpenID Connect specification.

Client secret
  • Optional

The client secret that FusionAuth uses to authenticate with the provider. The owner of the Identity Provider supplies the value. This field is required when Client authentication is HTTP basic authentication (client_secret_basic) or Request body (client_secret_post).

Discover endpoints

When turned on, FusionAuth discovers the endpoint configuration from the Issuer URL. For example, for an issuer of https://login.piedpiper.com, FusionAuth requests https://login.piedpiper.com/.well-known/openid-configuration.

When turned off, you enter the endpoints by hand. Turn off the field when the OpenID Connect provider doesn't implement the well-known discovery endpoint.

Issuer
  • Required

The public URL of the Identity Provider. This field is required when Discover endpoints is turned on.

Authorization endpoint
  • Required

The public URL of the OpenID Connect authorization endpointThe OAuth 2.0 endpoint where a user logs in and grants an application access. In FusionAuth, the authorization endpoint is /oauth2/authorize.. This field is required when Discover endpoints is turned off.

Token endpoint
  • Required

The public URL of the OpenID Connect token endpointThe OAuth 2.0 endpoint where an application exchanges a grant, such as an authorization code, for tokens. In FusionAuth, the token endpoint is /oauth2/token.. This field is required when Discover endpoints is turned off.

Userinfo endpoint
  • Required

The public URL of the OpenID Connect userinfo endpoint. This field is required when Discover endpoints is turned off.

Button text
  • Optional
  • Defaults to Login with OpenID Connect

The text of the button on the login form.

Button image
  • Optional

The image on the button on the login form. When you leave out the image, the button shows a default OpenID Connect icon.

Scope
  • Optional

The scope that FusionAuth requests from the user during login. Some OpenID Connect providers require a scope.

Linking strategy
  • Optional
  • Available since 1.28.0

How FusionAuth links the external user to a FusionAuth user. For more information, see Linking Strategies.

Available since 1.65.0 You can only change this value when the identity provider is disabled. To change the linking strategy for an identity provider that is already enabled, disable the provider, change the value, and then re-enable the provider.

When Linking strategy links on email and the OpenID Connect response contains an email_verified claim of false, FusionAuth doesn't create the link. FusionAuth returns an error that says a link can't use an unverified email address.

Reconcile lambda
  • Optional

A lambda that maps custom claims from the OpenID Connect provider to the FusionAuth user or registration.

To create or configure a lambda, navigate to Customizations -> Lambdas . For more information, see the lambda documentation.

Enable debug logging
  • Optional
  • Defaults to false

Creates Event Log entries during login that help you debug integration issues. To view the Event Log, navigate to System -> Event Log .

Applications#

The Applications tab lists each Application and CIMD domain. The FusionAuth Application represents the Admin UI. To let administrators log in to the Admin UI through the Identity Provider, enable the FusionAuth Application.

The Applications tab of the form to add an OpenID Connect Identity Provider.
The Applications tab of the form to add an OpenID Connect Identity Provider.
Enabled
  • Optional
  • Defaults to false

Turns on the Identity Provider for the Application.

Create registration
  • Optional

When a new user logs in through the Identity Provider, FusionAuth registers the user for the Application with the Application's default roles. When the toggle is off, register each user for the Application before the user logs in through the Identity Provider. For more information, see Applications and Overrides.

Tenants#

The Tenants tab limits the number of links that each user in a Tenant can have to this Identity Provider. Links to other Identity Providers don't count toward the limit. On a global Identity Provider, the tab starts empty. To set a limit for a Tenant, click Add tenant configuration . On a tenant-scoped Identity Provider, the tab lists only the Identity Provider's Tenant.

Limit links per user
  • Optional
  • Defaults to false
  • Available since 1.32.0

When turned on, FusionAuth enforces Maximum link count for users in the Tenant.

Maximum link count
  • Optional
  • Available since 1.32.0

The maximum number of links that a user can have to this Identity Provider. When a user reaches the limit, FusionAuth rejects a new link. The Link API returns a 400, and the hosted login pages show an error.

For more information, see Identity Providers and Tenants.

Managed Domains#

The Managed domains tab of the form to add an OpenID Connect Identity Provider.
The Managed domains tab of the form to add an OpenID Connect Identity Provider.
Managed domains
  • Optional

The email domains that this Identity Provider manages, one domain on each line. For example, to use the OpenID Connect Identity Provider only for employees, add the company domain, such as piedpiper.com.

With managed domains, the login page doesn't show a button for this Identity Provider. Instead, the login page first asks the user for an email address. When the email address matches a managed domain, FusionAuth redirects the user to this Identity Provider to authenticate. Otherwise, the login page asks for a password, and FusionAuth authenticates the user.

The Lookup API also uses managed domains. For more information, see Managed Domains.

Options#

The Options tab of the form to add an OpenID Connect Identity Provider.
The Options tab of the form to add an OpenID Connect Identity Provider.
Use POST method
  • Optional
  • Defaults to false

When turned on, the authentication request uses the HTTP POST binding instead of the default Redirect binding, which uses the HTTP GET method.

Unique Id claim
  • Optional
  • Defaults to sub

The name of the claim that contains the immutable unique Id of the user.

Email claim
  • Optional
  • Defaults to email

The name of the claim that contains the user's email address.

Email verified claim
  • Optional
  • Defaults to email_verified
  • Available since 1.48.0

The name of the claim that says whether the provider verified the user's email address. When Linking strategy links on email and the claim is false, FusionAuth rejects the link. When the response has no claim with this name, FusionAuth links on the email address without a check.

Set Email verified claim to the claim name of the provider. Otherwise, an attacker can add the email address of a FusionAuth user to an account at the provider, and then log in as that user.

Username claim
  • Optional
  • Defaults to preferred_username

The name of the claim that contains the user's username.

Redirect URLs#

An OpenID Connect login uses two redirect URLsThe URL where the authorization server sends the browser after login, with an authorization code or an error.:

  • The FusionAuth redirect URL handles the response from the OpenID Connect Identity Provider. The path is always /oauth2/callback. For FusionAuth at login.piedpiper.com, the FusionAuth redirect URL is https://login.piedpiper.com/oauth2/callback. Register this URL with the Identity Provider. FusionAuth processes the response, runs the configured lambda, if any, and logs the user in to FusionAuth.
  • The application redirect URL receives the authorization code from FusionAuth and exchanges the code for a token. You write this route, so you control the URL. Every application that integrates with FusionAuth has this redirect, with or without an OpenID Connect Identity Provider. For more information, see Authorization Code Grant.

The following diagram shows the requests in an OpenID Connect login. Pied Piper is the application, FusionAuth is the authorization serverThe server that authenticates users and issues tokens to applications in OAuth 2.0. FusionAuth is an authorization server., and Azure Active Directory/Microsoft Entra ID is the remote Identity Provider:

Azure AD/Microsoft Entra IDFusionAuthPied PiperBrowserAzure AD/Microsoft Entra IDFusionAuthPied PiperBrowserClick Login LinkRedirect to FusionAuthRequest Login PageSend Login PageClicks on 'Login With Azure AD'Redirects to Azure ADRequests Login PageSends Login PageSends CredentialsRedirects to FusionAuth Redirect URLRequests FusionAuth Redirect URLProcesses request, runs lambda, logs user into FusionAuthRedirects to Pied Piper Redirect URLRequests Pied Piper Redirect URLRequests TokenReturns TokenStores token (could send it to Browser as cookie as well)Redirects to Application pagesMakes authenticated request(s)
Azure AD/Microsoft Entra IDFusionAuthPied PiperBrowserAzure AD/Microsoft Entra IDFusionAuthPied PiperBrowserClick Login LinkRedirect to FusionAuthRequest Login PageSend Login PageClicks on 'Login With Azure AD'Redirects to Azure ADRequests Login PageSends Login PageSends CredentialsRedirects to FusionAuth Redirect URLRequests FusionAuth Redirect URLProcesses request, runs lambda, logs user into FusionAuthRedirects to Pied Piper Redirect URLRequests Pied Piper Redirect URLRequests TokenReturns TokenStores token (could send it to Browser as cookie as well)Redirects to Application pagesMakes authenticated request(s)

Requests and redirects in an OpenID Connect login through FusionAuth.

Proof Key for Code Exchange#

Available since 1.21.0

PKCEAn extension to OAuth 2.0 that mitigates authorization code interception attacks using dynamic code verifiers and challenges. (pronounced "pixy") is an extension to the Authorization Code grantAn OAuth 2.0 grant type in which a client exchanges an authorization code for tokens.. PKCE protects the exchange of an authorization code for tokens. For the specification, see RFC 7636.

FusionAuth uses PKCE with every OpenID Connect Identity Provider. You can't turn PKCE off. During a hosted login, FusionAuth generates a code verifier and sends an S256 code challenge to the authorization endpoint. FusionAuth then sends the code verifier to the token endpoint. A provider without PKCE support ignores the PKCE parameters.

When your app calls the authorization endpoint without the FusionAuth hosted login pages, generate the code verifier in your app. Send the code verifier in data.code_verifier to the Complete OpenID Connect Login API. For more information, see Complete an OpenID Connect Login.

Troubleshooting#

To troubleshoot an OpenID Connect connection:

  • Check the whole configuration, including stray spaces.
  • Turn on Enable debug logging, and read the Event Log entries during a login.

User Info as JWT#

The OpenID Connect specification lets a client request the userinfo response in the following formats:

  • JSON
  • Signed JWT
  • Encrypted or nested JWT

FusionAuth supports only the JSON format. When the OpenID Connect endpoint returns the userinfo data as a JWT, the Event Log shows an error such as the following:

Request to the [https://example.com/userinfo] endpoint failed. Status code [200].
Exception encountered.com.inversoft.rest.JSONException : Message: Failed to parse the HTTP response as JSON. Actual HTTP response body:
eyJoa...

To fix the error, ask the administrators of the OpenID Connect endpoint to return the userinfo data as JSON for your client registration.

Unable to Log In#

A common pattern is to set up OIDC as the login method for the FusionAuth application. This lets you keep all your users in the OIDC system, and have FusionAuth delegate auth decisions to it. However, if your Identity Provider isn't configured correctly, you can end up in a dead end, unable to log in. This might happen if the following occurs:

  • You set up OIDC as the authentication method for your FusionAuth admin application.
  • You set the Managed domains to your domain. For example, example.com.
  • All added users have the same example.com domain.
  • You accidentally misconfigure OIDC and break authentication.
  • Then you log out of the FusionAuth Admin UI.

You won't be able to log in to the FusionAuth admin application to correct the misconfiguration. You've locked down the FusionAuth admin application so that only users with example.com email domains can access it, but because of the misconfiguration, there is no account with a valid OIDC login.

Unable to login with a managed domain and misconfigured Identity Provider.
Unable to login with a managed domain and misconfigured Identity Provider.

This is a problem, but not an insurmountable one. Your options depend on when you discover the issue. If you are beginning your OIDC configuration, you can avoid this scenario. Follow these steps:

  • Don't set any value of Managed domains before you have tested the OIDC configuration.
  • Test authentication in a different or incognito browser window, ensuring that an admin user account is always accessible to modify configuration.
  • Add an admin user account with a domain not in the Managed domains setting. Ensure this user is registered with the FusionAuth admin application and has the admin role.
  • Set up an API key. Navigate to Settings -> API Keys to do so and make sure it has privileges to create users and registrations. This will open up options in the future to reset settings without using the Admin UI.

If you are currently locked out of your FusionAuth application, you have fewer options:

  • If you have a known username and password that are not delegated to OIDC (perhaps the initial account created when you set up FusionAuth) proceed to the FusionAuth admin login page. Append &showPasswordField=true to the end of the login URL. This will force the UI to show the password field.
  • If you have an API key with appropriate privileges, you can modify the configuration without using the Admin UI. Add an admin user with a different email domain and sign into the Admin UI to correct your OIDC configuration. Here's how you might do so (3c219e58-ed0e-4b18-ad48-f4f92793ae32 is the FusionAuth application Id):
Adding a New Admin User With a Different Domain
$ curl -XPOST -H "Authorization: $API_KEY" -H "Content-Type: application/json" \
-d '{
	"user": {
		"email": "user@differentdomain.com",
		"password": "password"
	},
	"registration": {
		"applicationId": "3c219e58-ed0e-4b18-ad48-f4f92793ae32",
		"roles": ["admin"]
	}
}' \
https://login.piedpiper.com/api/user/registration

If you have neither an API key nor a known user, you can restore from a database backup, modify the database directly if you have access, or re-install FusionAuth.