|
| 1 | +--- |
| 2 | +title: Azure MFA technical profiles in custom policies |
| 3 | +titleSuffix: Azure AD B2C |
| 4 | +description: Custom policy reference for Azure Multi-Factor Authentication (MFA) technical profiles in Azure AD B2C. |
| 5 | +services: active-directory-b2c |
| 6 | +author: mmacy |
| 7 | +manager: celestedg |
| 8 | + |
| 9 | +ms.service: active-directory |
| 10 | +ms.workload: identity |
| 11 | +ms.topic: conceptual |
| 12 | +ms.date: 12/17/2019 |
| 13 | +ms.author: marsma |
| 14 | +ms.subservice: B2C |
| 15 | +--- |
| 16 | + |
| 17 | +# Define an Azure MFA technical profile in an Azure AD B2C custom policy |
| 18 | + |
| 19 | +[!INCLUDE [active-directory-b2c-advanced-audience-warning](../../includes/active-directory-b2c-advanced-audience-warning.md)] |
| 20 | + |
| 21 | +Azure Active Directory B2C (Azure AD B2C) provides support for verifying a phone number by using Azure Multi-Factor Authentication (MFA). Use this technical profile to generate and send a code to a phone number, and then verify the code. |
| 22 | + |
| 23 | +The Azure MFA technical profile may also return an error message. You can design the integration with Azure MFA by using a **Validation technical profile**. A validation technical profile calls the Azure MFA service. The validation technical profile validates the user-provided data before the user journey continues. With the validation technical profile, an error message is display on a self-asserted page. |
| 24 | + |
| 25 | +[!INCLUDE [b2c-public-preview-feature](../../includes/active-directory-b2c-public-preview.md)] |
| 26 | + |
| 27 | +## Protocol |
| 28 | + |
| 29 | +The **Name** attribute of the **Protocol** element needs to be set to `Proprietary`. The **handler** attribute must contain the fully qualified name of the protocol handler assembly that is used by Azure AD B2C: |
| 30 | + |
| 31 | +``` |
| 32 | +Web.TPEngine.Providers.AzureMfaProtocolProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null |
| 33 | +``` |
| 34 | + |
| 35 | +The following example shows an Azure MFA technical profile: |
| 36 | + |
| 37 | +```XML |
| 38 | +<TechnicalProfile Id="AzureMfa-SendSms"> |
| 39 | + <DisplayName>Send Sms</DisplayName> |
| 40 | + <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.AzureMfaProtocolProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> |
| 41 | + ... |
| 42 | +``` |
| 43 | + |
| 44 | +## Send SMS |
| 45 | + |
| 46 | +The first mode of this technical profile is to generate a code and send it. The following options can be configured for this mode. |
| 47 | + |
| 48 | +### Input claims |
| 49 | + |
| 50 | +The **InputClaims** element contains a list of claims to send to Azure MFA. You can also map the name of your claim to the name defined in the MFA technical profile. |
| 51 | + |
| 52 | +| ClaimReferenceId | Required | Description | |
| 53 | +| --------- | -------- | ----------- | |
| 54 | +| userPrincipalName | Yes | The identifier for the user who owns the phone number. | |
| 55 | +| phoneNumber | Yes | The phone number to send an SMS code to. | |
| 56 | +| companyName | No |The company name in the SMS. If not provided, the name of your application is used. | |
| 57 | +| locale | No | The locale of the SMS. If not provided, the browser locale of the user is used. | |
| 58 | + |
| 59 | +The **InputClaimsTransformations** element may contain a collection of **InputClaimsTransformation** elements that are used to modify the input claims or generate new ones before sending to the Azure MFA service. |
| 60 | + |
| 61 | +### Output claims |
| 62 | + |
| 63 | +The Azure MFA protocol provider does not return any **OutputClaims**, thus there is no need to specify output claims. You can, however, include claims that aren't returned by the Azure MFA identity provider as long as you set the `DefaultValue` attribute. |
| 64 | + |
| 65 | +The **OutputClaimsTransformations** element may contain a collection of **OutputClaimsTransformation** elements that are used to modify the output claims or generate new ones. |
| 66 | + |
| 67 | +### Metadata |
| 68 | + |
| 69 | +| Attribute | Required | Description | |
| 70 | +| --------- | -------- | ----------- | |
| 71 | +| Operation | Yes | Must be **OneWaySMS**. | |
| 72 | +| UserMessageIfInvalidFormat | No | Custom error message if the phone number provided is not a valid phone number | |
| 73 | +| UserMessageIfCouldntSendSms | No | Custom error message if the phone number provided does not accept SMS | |
| 74 | +| UserMessageIfServerError | No | Custom error message if the server has encountered an internal error | |
| 75 | + |
| 76 | +### Return an error message |
| 77 | + |
| 78 | +As described in [Metadata](#metadata), you can customize the error message shown to the user for different error cases. You can further localize those messages by prefixing the locale. For example: |
| 79 | + |
| 80 | +```XML |
| 81 | +<Item Key="en.UserMessageIfInvalidFormat">Invalid phone number.</Item> |
| 82 | +``` |
| 83 | + |
| 84 | +### Example: send an SMS |
| 85 | + |
| 86 | +The following example shows an Azure MFA technical profile that is used to send a code via SMS. |
| 87 | + |
| 88 | +```XML |
| 89 | +<TechnicalProfile Id="AzureMfa-SendSms"> |
| 90 | + <DisplayName>Send Sms</DisplayName> |
| 91 | + <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.AzureMfaProtocolProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> |
| 92 | + <Metadata> |
| 93 | + <Item Key="Operation">OneWaySMS</Item> |
| 94 | + </Metadata> |
| 95 | + <InputClaimsTransformations> |
| 96 | + <InputClaimsTransformation ReferenceId="CombinePhoneAndCountryCode" /> |
| 97 | + <InputClaimsTransformation ReferenceId="ConvertStringToPhoneNumber" /> |
| 98 | + </InputClaimsTransformations> |
| 99 | + <InputClaims> |
| 100 | + <InputClaim ClaimTypeReferenceId="userPrincipalName" /> |
| 101 | + <InputClaim ClaimTypeReferenceId="fullPhoneNumber" PartnerClaimType="phoneNumber" /> |
| 102 | + </InputClaims> |
| 103 | +</TechnicalProfile> |
| 104 | +``` |
| 105 | + |
| 106 | +## Verify code |
| 107 | + |
| 108 | +The second mode of this technical profile is to verify a code. The following options can be configured for this mode. |
| 109 | + |
| 110 | +### Input claims |
| 111 | + |
| 112 | +The **InputClaims** element contains a list of claims to send to Azure MFA. You can also map the name of your claim to the name defined in the MFA technical profile. |
| 113 | + |
| 114 | +| ClaimReferenceId | Required | Description | |
| 115 | +| --------- | -------- | ----------- | ----------- | |
| 116 | +| phoneNumber| Yes | Same phone number as previously used to send a code. It is also used to locate a phone verification session. | |
| 117 | +| verificationCode | Yes | The verification code provided by the user to be verified | |
| 118 | + |
| 119 | +The **InputClaimsTransformations** element may contain a collection of **InputClaimsTransformation** elements that are used to modify the input claims or generate new ones before calling the Azure MFA service. |
| 120 | + |
| 121 | +### Output claims |
| 122 | + |
| 123 | +The Azure MFA protocol provider does not return any **OutputClaims**, thus there is no need to specify output claims. You can, however, include claims that aren't returned by the Azure MFA identity provider as long as you set the `DefaultValue` attribute. |
| 124 | + |
| 125 | +The **OutputClaimsTransformations** element may contain a collection of **OutputClaimsTransformation** elements that are used to modify the output claims or generate new ones. |
| 126 | + |
| 127 | +## Metadata |
| 128 | + |
| 129 | +| Attribute | Required | Description | |
| 130 | +| --------- | -------- | ----------- | |
| 131 | +| Operation | Yes | Must be **Verify** | |
| 132 | +| UserMessageIfInvalidFormat | No | Custom error message if the phone number provided is not a valid phone number | |
| 133 | +| UserMessageIfWrongCodeEntered | No | Custom error message if the code entered for verification is wrong | |
| 134 | +| UserMessageIfMaxAllowedCodeRetryReached | No | Custom error message if the user has attempted a verification code too many times | |
| 135 | +| UserMessageIfThrottled | No | Custom error message if the user is throttled | |
| 136 | +| UserMessageIfServerError | No | Custom error message if the server has encountered an internal error | |
| 137 | + |
| 138 | +### Return an error message |
| 139 | + |
| 140 | +As described in [Metadata](#metadata), you can customize the error message shown to the user for different error cases. You can further localize those messages by prefixing the locale. For example: |
| 141 | + |
| 142 | +```XML |
| 143 | +<Item Key="en.UserMessageIfWrongCodeEntered">Wrong code has been entered.</Item> |
| 144 | +``` |
| 145 | + |
| 146 | +### Example: verify a code |
| 147 | + |
| 148 | +The following example shows an Azure MFA technical profile used to verify the code. |
| 149 | + |
| 150 | +```XML |
| 151 | +<TechnicalProfile Id="AzureMfa-VerifySms"> |
| 152 | + <DisplayName>Verify Sms</DisplayName> |
| 153 | + <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.AzureMfaProtocolProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> |
| 154 | + <Metadata> |
| 155 | + <Item Key="Operation">Verify</Item> |
| 156 | + </Metadata> |
| 157 | + <InputClaims> |
| 158 | + <InputClaim ClaimTypeReferenceId="phoneNumber" PartnerClaimType="phoneNumber" /> |
| 159 | + <InputClaim ClaimTypeReferenceId="verificationCode" /> |
| 160 | + </InputClaims> |
| 161 | +</TechnicalProfile> |
| 162 | +``` |
0 commit comments