TOTPディスプレイ制御

Von Bedeutung

2025 年 5 月 1 日より、Azure AD B2C は新規のお客様向けに購入できなくなります。 詳細については、FAQ を参照してください。

時間ベースのワンタイムパスワード (TOTP) 表示コントロール を使用して、TOTP 方式を使用した多要素認証を有効にします。 エンド ユーザーは、 Microsoft Authenticator アプリ や TOTP 検証をサポートするその他の認証アプリなど、TOTP コードを生成する認証アプリを使用する必要があります。

カスタムポリシー内で TOTP を有効にするには、次の表示コントロールを使用します。

  • totpQrCodeControl - QRコードとディープリンクをレンダリングします。 ユーザーがQRコードをスキャンするか、ディープリンクを開くと、認証アプリが開き、ユーザーは登録プロセスを完了できます。
  • AuthenticatorAppIconControl - Microsoft Authenticator アプリのアイコンをレンダリングし、アプリをユーザーのモバイル デバイスにダウンロードするためのリンクを表示します。
  • AuthenticatorInfoControl - TOTP の紹介をレンダリングします。

次のスクリーンショットは、3 つのディスプレイ コントロールを示す TOTP 登録ページを示しています。

TOTP ディスプレイが登録フローを制御するスクリーンショット

次の XML スニペットは、3 つのディスプレイ コントロールを示しています。

  <DisplayControls>
    <!-- Render the QR code by taking the URI (qrCodeContent) input claim and rendering it as a QR code-->
    <DisplayControl Id="totpQrCodeControl" UserInterfaceControlType="QrCodeControl">
      <InputClaims>
        <InputClaim ClaimTypeReferenceId="qrCodeContent" />
      </InputClaims>
      <DisplayClaims>
        <DisplayClaim ClaimTypeReferenceId="qrCodeContent" ControlClaimType="QrCodeContent" />
      </DisplayClaims>
    </DisplayControl>

    <!-- Render the TOTP information by taking the totpIdentifier and the secretKey input claims and rendering them in plain text-->
    <DisplayControl Id="authenticatorInfoControl" UserInterfaceControlType="AuthenticatorInfoControl">
      <InputClaims>
        <InputClaim ClaimTypeReferenceId="totpIdentifier" />
        <InputClaim ClaimTypeReferenceId="secretKey" />
      </InputClaims>
      <DisplayClaims>
        <DisplayClaim ClaimTypeReferenceId="totpIdentifier" />
        <DisplayClaim ClaimTypeReferenceId="secretKey" />
      </DisplayClaims>
    </DisplayControl>

    <!-- Render the authenticator apps icon. -->
    <DisplayControl Id="authenticatorAppIconControl" UserInterfaceControlType="AuthenticatorAppIconControl" />
  </DisplayControls>

表示コントロールは、 セルフアサート技術プロファイルから参照されます。 セルフアサート技術プロファイルでは、入力要求変換を使用して、必要な qrCodeContent と secretKey 入力要求を準備します。

入力要求変換は、次の順序で呼び出す必要があります。

  1. CreateSecret 要求変換の種類は CreateOtpSecret。 要求変換により、TOTP シークレット キーが作成されます。 このキーは、後で Azure AD B2C のユーザーのプロファイルに格納され、認証アプリと共有されます。 認証アプリは、キーを使用して、ユーザーが MFA を通過するために必要な TOTP コードを生成します。 カスタムポリシーでは、キーを使用して、ユーザーから提供された TOTP コードを検証します。
  2. CreateIssuer の 要求変換の種類。 要求変換により、TOTP 発行者名が作成されます。 発行者名は、"Contoso demo" などのテナント名です。
  3. CreateUriLabel要求変換の種類は FormatStringMultipleClaims です。 クレーム変換により、TOTP URI ラベルが作成されます。 ラベルは、ユーザーの一意の識別子 (メールアドレスなど) と発行者名 ( Contoso demo:emily@fabrikam.com など) を組み合わせたものです。
  4. CreateUriString は、BuildUri の変換の種類を要求します。 claims 変換により、TOTP URI 文字列が作成されます。 文字列は、URI ラベルと秘密鍵 ( otpauth://totp/Contoso%20demo:emily@fabrikam.com?secret=fay2lj7ynpntjgqa&issuer=Contoso+demo など) の組み合わせです。 この URI ラベルは、表示コントロールによって QR コード形式とディープ リンクでレンダリングされます。

次の XML コードは、 EnableOTPAuthentication セルフアサート技術プロファイルと、その入力要求変換、入力要求、および表示コントロールを示しています。

<TechnicalProfile Id="EnableOTPAuthentication">
  <DisplayName>Sign up with Authenticator app</DisplayName>
  <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.SelfAssertedAttributeProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
  <Metadata>
    <Item Key="ContentDefinitionReferenceId">api.selfasserted.totp</Item>
    <Item Key="language.button_continue">Continue</Item>
  </Metadata>
  <CryptographicKeys>
    <Key Id="issuer_secret" StorageReferenceId="B2C_1A_TokenSigningKeyContainer" />
  </CryptographicKeys>
  <InputClaimsTransformations>
    <InputClaimsTransformation ReferenceId="CreateSecret" />
    <InputClaimsTransformation ReferenceId="CreateIssuer" />
    <InputClaimsTransformation ReferenceId="CreateUriLabel" />
    <InputClaimsTransformation ReferenceId="CreateUriString" />
  </InputClaimsTransformations>
  <InputClaims>
    <InputClaim ClaimTypeReferenceId="qrCodeContent" />
    <InputClaim ClaimTypeReferenceId="secretKey" />
  </InputClaims>
  <DisplayClaims>
    <DisplayClaim DisplayControlReferenceId="authenticatorAppIconControl" />
    <DisplayClaim ClaimTypeReferenceId="QrCodeScanInstruction" />
    <DisplayClaim DisplayControlReferenceId="totpQrCodeControl" />
    <DisplayClaim DisplayControlReferenceId="authenticatorInfoControl" />
  </DisplayClaims>
  <OutputClaims>
    <OutputClaim ClaimTypeReferenceId="objectId" />
    <OutputClaim ClaimTypeReferenceId="secretKey" />
  </OutputClaims>
  <UseTechnicalProfileForSessionManagement ReferenceId="SM-MFA-TOTP" />
</TechnicalProfile>

検証フロー

検証 TOTP コードは、表示要求と検証技術プロファイルを使用する別のセルフアサート技術プロファイルによって行われます。 詳細については、「 Azure AD B2C カスタム ポリシーで Microsoft Entra ID 多要素認証技術プロファイルを定義する」を参照してください。

次のスクリーンショットは、TOTP 検証ページを示しています。

TOTP ディスプレイ コントロールの検証フローを示すスクリーンショット

次のステップ