共用方式為


在 Azure Active Directory B2C 自定義原則中定義 CAPTCHA 技術配置檔

注意

在 Azure Active Directory B2C 中, 自定義原則 的設計主要是為了解決複雜的案例。 在大部分情況下,我們建議您使用內 建的使用者流程。 如果您尚未這麼做,請了解開始使用 Active Directory B2C 中的自定義原則入門套件。

可讓 Azure Active Directory B2C (Azure AD B2C) 防止自動攻擊的完全自動化公用圖靈測試,以告訴計算機和人類分開 (CAPTCHA) 技術配置檔。 Azure AD B2C 的 CAPTCHA 技術配置檔同時支援音訊和視覺 CAPTCHA 挑戰類型。

通訊協定

Protocol 元素的 Name 屬性必須設定為 Proprietary處理程式屬性必須包含 Azure AD B2C 用於 CAPTCHA 之通訊協定處理程式元件的完整名稱:Web.TPEngine.Providers.CaptchaProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

注意

這項功能處於公開預覽狀態

下列範例顯示電子郵件註冊的自我判斷技術配置檔:

<TechnicalProfile Id="HIP-GetChallenge">
  <DisplayName>Email signup</DisplayName>
  <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.CaptchaProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />

CAPTCHA 技術配置文件作業

CAPTCHA 技術配置檔作業有兩個作業:

  • 取得挑戰作業會產生 CAPTCHA 程式代碼字串,然後使用 CAPTCHA 顯示控制件在使用者介面上顯示它。 顯示包含輸入文字框。 此作業會指示使用者輸入他們看到或聽到的字元到輸入文字框中。 用戶可以視需要在視覺和音訊挑戰類型之間切換。

  • 驗證程式代碼作業 會驗證使用者輸入的字元。

取得挑戰

第一個作業會產生 CAPTCHA 程式代碼字串,然後在使用者介面上顯示它。

輸入宣告

InputClaims 元素包含要傳送至 Azure AD B2C CAPTCHA 服務的宣告清單。

ClaimReferenceId 必要 描述
challengeType No CAPTCHA 挑戰類型、音訊或視覺效果 (預設值)。
azureregion Yes 服務提供 CAPTCHA 挑戰要求的服務區域。

顯示宣告

DisplayClaims 元素包含要在螢幕上呈現的宣告清單,供使用者查看。 例如,使用者會看到要讀取的 CAPTCHA 挑戰程式代碼。

ClaimReferenceId 必要 描述
challengeString Yes CAPTCHA 挑戰程序代碼。

輸出宣告

OutputClaims 元素包含 CAPTCHA 技術配置檔所傳回的宣告清單。

ClaimReferenceId 必要 描述
challengeId Yes CAPTCHA 挑戰程式代碼的唯一標識碼。
challengeString Yes CAPTCHA 挑戰程序代碼。
azureregion Yes 服務提供 CAPTCHA 挑戰要求的服務區域。

中繼資料

屬性 必要 描述
作業 Yes 值必須是 GetChallenge
品牌 Yes 值必須是 HIP

範例:產生 CAPTCHA 程式代碼

下列範例顯示用來產生程式代碼的 CAPTCHA 技術設定檔:

<TechnicalProfile Id="HIP-GetChallenge">
  <DisplayName>GetChallenge</DisplayName>
  <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.CaptchaProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />

  <Metadata>
    <Item Key="Operation">GetChallenge</Item>
    <Item Key="Brand">HIP</Item>
  </Metadata>

  <InputClaims>
    <InputClaim ClaimTypeReferenceId="challengeType" />
  </InputClaims>

  <DisplayClaims>
    <DisplayClaim ClaimTypeReferenceId="challengeString" />
  </DisplayClaims>

  <OutputClaims>
    <OutputClaim ClaimTypeReferenceId="challengeId" />
    <OutputClaim ClaimTypeReferenceId="challengeString" PartnerClaimType="ChallengeString" />
    <OutputClaim ClaimTypeReferenceId="azureregion" />
  </OutputClaims>

</TechnicalProfile>

驗證挑戰

第二個作業會驗證 CAPTCHA 挑戰。

輸入宣告

InputClaims 元素包含要傳送至 Azure AD B2C CAPTCHA 服務的宣告清單。

ClaimReferenceId 必要 描述
challengeType No CAPTCHA 挑戰類型、音訊或視覺效果 (預設值)。
challengeId Yes 用於會話驗證的 CAPTCHA 的唯一識別碼。 從 GetChallenge 呼叫填入
captchaEntered Yes 使用者輸入至使用者介面上挑戰文本框的挑戰程序代碼。
azureregion Yes 服務提供 CAPTCHA 挑戰要求的服務區域。 從 GetChallenge 呼叫填入

顯示宣告

DisplayClaims 元素包含要在螢幕上呈現的宣告清單,以便從使用者收集輸入。

ClaimReferenceId 必要 描述
captchaEntered Yes 使用者輸入的 CAPTCHA 挑戰代碼。

輸出宣告

OutputClaims 元素包含 captcha 技術配置檔所傳回的宣告清單。

ClaimReferenceId 必要 描述
challengeId Yes 用於會話驗證的 CAPTCHA 的唯一識別碼。
isCaptchaSolved Yes 旗標,指出 CAPTCHA 挑戰是否成功解決。
reason Yes 用來與使用者通訊,無論嘗試解決挑戰是否成功。

中繼資料

屬性 必要 描述
作業 Yes 值必須是 VerifyChallenge
品牌 Yes 值必須是 HIP

範例:驗證 CAPTCHA 程式代碼

下列範例顯示您用來驗證 CAPTCHA 程式代碼的 CAPTCHA 技術設定檔:

  <TechnicalProfile Id="HIP-VerifyChallenge">
    <DisplayName>Verify Code</DisplayName>
    <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.CaptchaProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
    <Metadata>
      <Item Key="Brand">HIP</Item>
      <Item Key="Operation">VerifyChallenge</Item>
    </Metadata>

    <InputClaims>
      <InputClaim ClaimTypeReferenceId="challengeType" DefaultValue="Visual" />
      <InputClaim ClaimTypeReferenceId="challengeId" />
      <InputClaim ClaimTypeReferenceId="captchaEntered" PartnerClaimType="inputSolution" Required="true" />
      <InputClaim ClaimTypeReferenceId="azureregion" />
    </InputClaims>

    <DisplayClaims>
      <DisplayClaim ClaimTypeReferenceId="captchaEntered" />
    </DisplayClaims>

    <OutputClaims>
      <OutputClaim ClaimTypeReferenceId="challengeId" />
      <OutputClaim ClaimTypeReferenceId="isCaptchaSolved" PartnerClaimType="solved" />
      <OutputClaim ClaimTypeReferenceId="reason" PartnerClaimType="reason" />
    </OutputClaims>

  </TechnicalProfile>

下一步