oidc method. However, B2C has two behaviors that require extra configuration compared to most providers:
- Its OIDC discovery document is served from a policy-specific URL (using your tenant domain), while the
issuerit reports is the tenant GUID. This requires thediscovery_urloption. - It returns the email address in an
emailsarray rather than a stringemailclaim. This requires theclaims_mappingoption.
Prerequisites
- Docker
- An Azure AD B2C tenant
- A B2C user flow or custom policy (for example, a sign-up/sign-in flow such as
B2C_1_signupsignin)
Register an application in Azure AD B2C
- In the Azure portal, switch to your Azure AD B2C tenant and open App registrations.
- Select New registration and give the application a meaningful name, such as âFliptâ.
-
Under Redirect URI, select Web and enter your Flipt callback URL:
https://your.flipt.instance.url.com/auth/v1/method/oidc/azure/callbackTheazuresegment must match the provider name you use in your Flipt configuration. This guide usesazure. -
After creating the registration, open Certificates & secrets, select New client secret, and copy the generated value. Youâll use this as the
client_secret. -
Copy the Application (client) ID from the appâs Overview page. Youâll use this as the
client_id.
Find your issuer and discovery URLs
Flipt needs two related URLs that B2C keeps separate. Fetch your policyâs discovery document. The metadata path uses your tenant domain and policy name, and does not include theoauth2 segment:
- The value of the
issuerfield is yourissuer_url. It uses the tenant GUID, for examplehttps://yourtenant.b2clogin.com/00000000-0000-0000-0000-000000000000/v2.0/. Copy it exactly, including the trailing slash. - The URL you fetched, without the
.well-known/openid-configurationsuffix, is yourdiscovery_url, for examplehttps://yourtenant.b2clogin.com/yourtenant.onmicrosoft.com/B2C_1_signupsignin/v2.0.
Running Flipt
1. Define a Flipt config.yml
Configure the oidc method with a provider named azure. Set issuer_url and discovery_url from the previous step, and map the email claim from the B2C emails array.
config.yml
claims_mappingmaps Fliptâsemailattribute to the first entry of the B2Cemailsarray. This is required foremail_matchesto work, since B2C doesnât emit a stringemailclaim.- Donât request
emailorprofileinscopes. B2C only advertises theopenidscope (which Flipt requests automatically); requesting others can cause the authorize request to fail. Email and name claims are delivered through your user flowâs application-claims configuration. - Donât enable
fetch_extra_user_info. B2C doesnât expose a UserInfo endpoint, so enabling it causes the login callback to fail. All claims are already present in the ID token.
2. Run Flipt as a Docker container
3. Navigate to the Flipt UI
Open your Flipt instance in a browser. A âLogin with Azureâ option is presented. Selecting it redirects you to your B2C sign-up/sign-in experience, and after authenticating youâre returned to the Flipt dashboard.Troubleshooting
NewProvider: unable to create provider: 404 Not Found
Flipt couldnât fetch the discovery document. This usually means the URL includes the oauth2 segment, or the policy name is wrong. The discovery document is at .../<policy>/v2.0/.well-known/openid-configuration (no oauth2). Verify the URL with curl as shown above.
oidc: issuer did not match the issuer returned by provider
The issuer_url doesnât match the issuer reported by the discovery document. Set discovery_url to the policy URL you fetch discovery from, and set issuer_url to the exact issuer value from that document (the tenant-GUID form, including the trailing slash).
Login succeeds but every request is rejected
If you use email_matches but havenât mapped the email claim, Flipt has no email to match and rejects requests. Add claims_mapping with email: "/emails/0" as shown above.
Conclusion
This guide showed how to configure Flipt v2 to authenticate with Azure AD B2C, including thediscovery_url and claims_mapping options that B2C requires.
If you have any questions or feedback, please reach out to the Flipt team on Discord or GitHub Discussions.
References: