Enable authentication and authorization in Azure Container Apps with a Custom OpenID Connect provider
This article shows you how to configure Azure Container Apps to use a custom authentication provider that adheres to the OpenID Connect specification. OpenID Connect (OIDC) is an industry standard widely adopted 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 requires you to register the details of your application with it. One of these steps involves specifying a redirect URI. This redirect URI is of the form <app-url>/.auth/login/<provider-name>/callback
. Each identity provider should provide more instructions on how to complete these steps.
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 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 need to collect a client ID and client secret for your application.
Important
The client secret is a critical security credential. Do not share this secret with anyone or distribute it within a client application.
Additionally, you need the OpenID Connect metadata for the provider. This information is often exposed via a configuration metadata document, which is the provider's Issuer URL suffixed with /.well-known/openid-configuration
. Make sure to gather this configuration URL.
If you're unable to use a configuration metadata document, you need to gather the following values separately:
- The issuer URL (sometimes shown as
issuer
) - The OAuth 2.0 Authorization endpoint (sometimes shown as
authorization_endpoint
) - The OAuth 2.0 Token endpoint (sometimes shown as
token_endpoint
) - The URL of the OAuth 2.0 JSON Web Key Set document (sometimes shown as
jwks_uri
)
Add provider information to your application
Sign in to the Azure portal and navigate to your app.
Select Authentication in the menu on the left. Select Add identity provider.
Select OpenID Connect in the identity provider dropdown.
Provide the unique alphanumeric name selected earlier for OpenID provider name.
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.
Provide the earlier collected Client ID and Client Secret in the appropriate fields.
Specify an application setting name for your client secret. Your client secret is stored as a secret in your container app.
Press the Add button to finish setting up the identity provider.
Working with authenticated users
Use the following guides for details on working with authenticated users.