TOTP 表示コントロール

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

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

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

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

Screenshot showing TOTP display controls enrollment flow

次の 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>

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

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

  1. CreateSecret は、CreateOtpSecret の種類の変換を要求します。 要求変換では、TOTP 秘密鍵が作成されます。 このキーは、後で Azure AD B2C のユーザーのプロファイルに格納され、認証アプリと共有されます。 認証アプリでは、キーを使用して、ユーザーが MFA を通過するために必要な TOTP コードを生成します。 カスタム ポリシーでは、このキーを使用して、ユーザーが指定した TOTP コードを検証します。
  2. CreateIssuer は、CreateStringClaim の種類の変換を要求します。 要求変換では、TOTP 発行者名が作成されます。 発行者名はテナント名です (例: "Contoso demo")。
  3. CreateUriLabel は、FormatStringMultipleClaims の種類の変換を要求します。 要求変換では、TOTP URI ラベルが作成されます。 ラベルは、ユーザーの一意識別子 (電子メール アドレスなど) と発行者名 (Contoso demo:emily@fabrikam.com など) の組み合わせです。
  4. CreateUriString は、BuildUri の種類の変換を要求します。 要求変換では、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 検証ページを示しています。

Screenshot showing TOTP display controls verification flow

次のステップ