ערוך

שתף באמצעות


Configure your App Service or Azure Functions app to sign in using an OpenID Connect provider

This article shows you how to configure Azure App Service or Azure Functions to use a custom authentication provider that adheres to the OpenID Connect specification. OpenID Connect (OIDC) is an industry standard used by many identity providers (IDPs). You don't need to understand the details of the specification in order to configure your app to use an adherent IDP.

You can configure your app to use one or more OIDC providers. Each must be given a unique alphanumeric name in the configuration, and only one can serve as the default redirect target.

Register your application with the identity provider

Your provider will require you to register the details of your application with it. One of these steps involves specifying a redirect URI. This redirect URI will be of the form <app-url>/.auth/login/<provider-name>/callback. Each identity provider should provide more instructions on how to complete these steps. <provider-name> will refer to the friendly name you give to the OpenID provider name in Azure.

Note

Some providers may require additional steps for their configuration and how to use the values they provide. For example, Apple provides a private key which is not itself used as the OIDC client secret, and you instead must use it to craft a JWT which is treated as the secret you provide in your app config (see the "Creating the Client Secret" section of the Sign in with Apple documentation)

You'll need to collect a client ID and client secret for your application.

Important

The client secret is an important security credential. Don't share this secret with anyone or distribute it within a client application.

Additionally, you'll need the OpenID Connect metadata for the provider. This is often exposed via a configuration metadata document, which is the provider's Issuer URL suffixed with /.well-known/openid-configuration. Gather this configuration URL.

If you're unable to use a configuration metadata document, you'll need to gather the following values separately:

Add provider information to your application

  1. Sign in to the Azure portal and navigate to your app.
  2. Select Authentication in the menu on the left. Select Add identity provider.
  3. Select OpenID Connect in the identity provider dropdown.
  4. Provide the unique alphanumeric name selected earlier for OpenID provider name.
  5. If you have the URL for the metadata document from the identity provider, provide that value for Metadata URL. Otherwise, select the Provide endpoints separately option and put each URL gathered from the identity provider in the appropriate field.
  6. Provide the earlier collected Client ID and Client Secret in the appropriate fields.
  7. Specify an application setting name for your client secret. Your client secret will be stored as an app setting to ensure secrets are stored in a secure fashion. You can update that setting later to use Key Vault references if you wish to manage the secret in Azure Key Vault.
  8. Press the Add button to finish setting up the identity provider.

Note

The OpenID provider name can't contain symbols like "-" because an appsetting will be created based on this and it doesn't support it. Use "_" instead.

Note

Azure requires "openid," "profile," and "email" scopes. Make sure you've configured your App Registration in your ID Provider with at least these scopes.

Next steps