Skip to main content
This guide adds a manage security policy to your Azure AD B2C tenant. A signed-in user starts it from a Manage security button in your app. The user verifies in Authsignal’s pre-built UI, then adds, changes or removes authenticators. Your app gets the result in the ID token. The examples use the policy ID B2C_1A_MANAGE_SECURITY. You can use any policy ID.

Prerequisites

Complete the MFA integration guide first. This policy uses the same base policies and the same B2C_1A_AuthsignalSecret policy key.

Try a live demo!

Sequence

Code example

The full policy is in each example repository: The steps below show each part of the policy.

Step by step guide

Step 1: Create a manage security action in Authsignal

In the Authsignal Portal, create an action for managing authenticators, for example manageSecurity. In the action’s configuration, add these steps to the flow:
  1. A Verification step. Allow every method that your users can enroll, for example Email OTP, Passkey and SMS OTP.
  2. A Manage methods step. Select the methods that users can manage.
A user can only verify with a method that the verification step allows. Otherwise the user sees “Verification unsuccessful”.

Step 2: Create the policy file

Create a policy file, for example ManageSecurity.xml. Set its base policy to the extensions policy from the MFA guide.

Step 3: Declare the claims

Add these claims to <BuildingBlocks><ClaimsSchema>.

Step 4: Add the claims transformations

Add these claims transformations to <BuildingBlocks><ClaimsTransformations>. Replace the INSERT_AUTHSIGNAL_ACTION placeholder with the action code from step 1. The first transformation builds the init auth request body. Its custom.correlationId field stores the B2C correlation ID on the Authsignal action. The other two check the user ID and the action state in the token from Authsignal.

Step 5: Add the technical profiles

Add these technical profiles to a <ClaimsProvider> in <ClaimsProviders>. Replace the AUTHSIGNAL_CONNECT_HOSTNAME and INSERT_AUTHSIGNAL_TENANT_ID placeholders with the values from the MFA guide. The OIDC documentation lists the hostnames. With SM-Noop session management, Azure AD B2C runs the Authsignal steps every time.

Step 6: Add the user journey

Add this user journey to <UserJourneys>. In step 1, use the sign-in technical profile from your sign-in journey. The passwordless example uses SelfAsserted-LocalAccountSignin-Email_Passwordless. Azure AD B2C skips this step when the user has a B2C session.

Step 7: Add the relying party

Add the relying party after <UserJourneys>. It puts the action state and the correlation ID in the ID token.
If your sign-in page uses JavaScript, for example for passkey autofill, add <UserJourneyBehaviors><ScriptExecution>Allow</ScriptExecution></UserJourneyBehaviors> after <DefaultUserJourney>. Step 1 shows that page when the user has no B2C session.

Step 8: Upload the policy and add the redirect URI

  1. Upload the policy to your Azure AD B2C tenant.
  2. In your app registration, add the redirect URI for the manage security response.

Step 9: Add a manage security button to your app

When a signed-in user clicks the button, send an OpenID Connect authorization request for your manage security policy. Pass the user’s email address in login_hint.
The MFA example app does this with a second NextAuth.js provider in pages/api/auth/[...nextauth].ts.

Step 10: Read the result

The ID token from the manage security policy contains these claims: If the flow fails or the user IDs don’t match, the policy shows the error page and returns no token. This ID token has no name or email address. Add the result to the session from sign-in. Don’t replace that session.

Next steps