你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

教程:将 BioCatch 和 Azure Active Directory B2C 一起配置

了解如何将 Azure Active Directory B2C (Azure AD B2C) 身份验证与 BioCatch 技术集成,以增强客户标识和访问管理 (CIAM) 安全状况。 BioCatch 产品分析用户的物理和认知数字行为,以获得有助于区分合法客户的见解。

转到 biocatch.com 以详细了解 BioCatch

先决条件

要开始,需要:

方案描述

BioCatch 集成包括以下组件:

  • Web 应用或 Web 服务 - 用户浏览到此 Web 服务,该服务会实例化转到 BioCatch 的唯一客户端会话 ID
    • 会话 ID 将用户行为特征传输到 BioCatch
  • 方法 - 将会话 ID 发送到 Azure AD B2C。 在示例中,JavaScript 将值输入到隐藏的 HTML 字段中。
  • Azure AD B2C 自定义 UI - 为 JavaScript 中的会话 ID 输入隐藏 HTML 字段
  • Azure AD B2C 自定义策略
    • 通过自断言技术配置文件将会话 ID 作为声明
    • 通过 REST API 声明提供程序与 BioCatch 集成,并将会话 ID 传递到 BioCatch
    • 对于自定义策略逻辑,从 BioCatch 返回多个自定义声明
    • 用户旅程评估返回的声明,并执行条件操作,例如多重身份验证

了解详细信息:

下图演示包含会话信息的用户流。

包含会话信息的用户流示意图。

  1. 用户浏览到返回 HTML、CSS 或 JavaScript 值的 Web 服务,然后加载 BioCatch JavaScript SDK。 客户端 JavaScript 配置 BioCatch SDK 的客户端会话 ID。 此外,Web 服务也可以预配置客户端会话 ID 并将其发送到客户端。 可以为 BioCatch 配置实例化的 BioCatch JavaScript SDK,该 SDK 使用客户端会话 ID 从客户端设备向 BioCatch 发送用户行为。
  2. 用户注册或登录并重定向到 Azure AD B2C。
  3. 用户旅程包括用于输入客户端会话 ID 的自断言声明提供程序。 此字段已隐藏。 使用 JavaScript 在字段中输入会话 ID。 选择“下一步”以继续注册或登录。 会话 ID 转到 BioCatch 以获得风险评分。 BioCatch 返回会话信息,并建议允许或阻止。 用户旅程有一个条件检查,后者根据返回的声明进行操作。
  4. 基于条件检查结果,调用了一项操作。
  5. Web 服务可使用会话 ID 来查询 BioCatch API,以确定风险和会话信息。

BioCatch 入门

转到 biocatch.com 联系我们页面以启动帐户。

配置自定义 UI

建议使用 CSS、JavaScript 或其他方法隐藏“客户端会话 ID”字段。 为了进行测试,取消隐藏该字段。 例如,JavaScript 隐藏输入字段,如下所示:

document.getElementById("clientSessionId").style.display = 'none';

配置 Azure AD B2C Identity Experience Framework 策略

  1. 若要开始,请参阅 教程:在 Azure AD B2C 中创建用户流和自定义策略

  2. 创建一个从扩展文件继承的新文件。

    <BasePolicy> 
    
        <TenantId>tenant.onmicrosoft.com</TenantId> 
    
        <PolicyId>B2C_1A_TrustFrameworkExtensions</PolicyId> 
    
      </BasePolicy> 
    
  3. 在 BuildingBlocks 资源下创建对自定义 UI 的引用以隐藏输入框。

    <ContentDefinitions> 
    
        <ContentDefinition Id="api.selfasserted"> 
    
            <LoadUri>https://domain.com/path/to/selfAsserted.cshtml</LoadUri> 
    
            <DataUri>urn:com:microsoft:aad:b2c:elements:contract:selfasserted:2.1.0</DataUri> 
    
          </ContentDefinition> 
    
        </ContentDefinitions>
    
  4. 在 BuildingBlocks 资源下,添加以下声明。

    <ClaimsSchema> 
    
          <ClaimType Id="riskLevel"> 
    
            <DisplayName>Session risk level</DisplayName> 
    
            <DataType>string</DataType>       
    
          </ClaimType> 
    
          <ClaimType Id="score"> 
    
            <DisplayName>Session risk score</DisplayName> 
    
            <DataType>int</DataType>       
    
          </ClaimType> 
    
          <ClaimType Id="clientSessionId"> 
    
            <DisplayName>The ID of the client session</DisplayName> 
    
            <DataType>string</DataType> 
    
            <UserInputType>TextBox</UserInputType> 
    
          </ClaimType> 
    
    </ClaimsSchema> 
    
  5. 为客户端会话 ID 字段配置自断言声明提供程序。

    <ClaimsProvider> 
    
          <DisplayName>Client Session ID Claims Provider</DisplayName> 
    
          <TechnicalProfiles> 
    
            <TechnicalProfile Id="login-NonInteractive-clientSessionId"> 
    
              <DisplayName>Client Session ID TP</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</Item> 
    
              </Metadata> 
    
              <CryptographicKeys> 
    
                <Key Id="issuer_secret" StorageReferenceId="B2C_1A_TokenSigningKeyContainer" /> 
    
              </CryptographicKeys> 
    
            <!—Claim we created earlier --> 
    
              <OutputClaims> 
    
                <OutputClaim ClaimTypeReferenceId="clientSessionId" Required="false" DefaultValue="100"/> 
    
              </OutputClaims> 
    
            <UseTechnicalProfileForSessionManagement ReferenceId="SM-AAD" /> 
    
            </TechnicalProfile> 
    
          </TechnicalProfiles> 
    
        </ClaimsProvider> 
    
  6. 为 BioCatch 配置 REST API 声明提供程序。

    <TechnicalProfile Id="BioCatch-API-GETSCORE"> 
    
          <DisplayName>Technical profile for BioCatch API to return session information</DisplayName> 
    
          <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.RestfulProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
    
          <Metadata> 
    
            <Item Key="ServiceUrl">https://biocatch-url.com/api/v6/score?customerID=<customerid>&amp;action=getScore&amp;uuid=<uuid>&amp;customerSessionID={clientSessionId}&amp;solution=ATO&amp;activtyType=<activity_type>&amp;brand=<brand></Item>
    
            <Item Key="SendClaimsIn">Url</Item> 
    
            <Item Key="IncludeClaimResolvingInClaimsHandling">true</Item> 
    
            <!-- Set AuthenticationType to Basic or ClientCertificate in production environments --> 
    
            <Item Key="AuthenticationType">None</Item> 
    
            <!-- REMOVE the following line in production environments --> 
    
            <Item Key="AllowInsecureAuthInProduction">true</Item> 
    
          </Metadata> 
    
          <InputClaims> 
    
            <InputClaim ClaimTypeReferenceId="clientsessionId" /> 
    
          </InputClaims> 
    
          <OutputClaims> 
    
            <OutputClaim ClaimTypeReferenceId="riskLevel" /> 
    
            <OutputClaim ClaimTypeReferenceId="score" /> 
    
          </OutputClaims> 
    
          <UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" /> 
    
        </TechnicalProfile> 
    
      </TechnicalProfiles>
    

    注意

    BioCatch 提供 URL、客户 ID 和唯一用户 ID (UUID)。 客户 SessionID 声明作为查询字符串参数传递到 BioCatch。 可以选择活动类型,例如 MAKE_PAYMENT。

  7. 使用以下示例配置用户旅程:

    • 获取 clientSessionID 作为声明。
    • 调用 BioCatch API 以获取会话信息。
    • 如果返回的声明风险较低,则跳过 MFA 的步骤,否则强制执行用户 MFA。
    <OrchestrationStep Order="8" Type="ClaimsExchange"> 
    
          <ClaimsExchanges> 
    
            <ClaimsExchange Id="clientSessionIdInput" TechnicalProfileReferenceId="login-NonInteractive-clientSessionId" /> 
    
          </ClaimsExchanges> 
    
        </OrchestrationStep> 
    
        <OrchestrationStep Order="9" Type="ClaimsExchange"> 
    
          <ClaimsExchanges> 
    
            <ClaimsExchange Id="BcGetScore" TechnicalProfileReferenceId=" BioCatch-API-GETSCORE" /> 
    
          </ClaimsExchanges> 
    
        </OrchestrationStep> 
    
        <OrchestrationStep Order="10" Type="ClaimsExchange"> 
    
          <Preconditions> 
    
            <Precondition Type="ClaimEquals" ExecuteActionsIf="true"> 
    
              <Value>riskLevel</Value> 
    
              <Value>LOW</Value> 
    
              <Action>SkipThisOrchestrationStep</Action> 
    
            </Precondition> 
    
          </Preconditions> 
    
          <ClaimsExchanges> 
    
            <ClaimsExchange Id="PhoneFactor-Verify" TechnicalProfileReferenceId="PhoneFactor-InputOrVerify" /> 
    
          </ClaimsExchanges>
    
  8. 配置信赖方(可选)。 可以将 BioCatch 返回的信息作为令牌中的声明传递给应用程序:risklevel 和评分。

    <RelyingParty> 
    
    <DefaultUserJourney ReferenceId="SignUpOrSignInMfa" /> 
    
    <UserJourneyBehaviors> 
    
      <SingleSignOn Scope="Tenant" KeepAliveInDays="30" /> 
    
      <SessionExpiryType>Absolute</SessionExpiryType> 
    
      <SessionExpiryInSeconds>1200</SessionExpiryInSeconds> 
    
      <ScriptExecution>Allow</ScriptExecution> 
    
    </UserJourneyBehaviors> 
    
    <TechnicalProfile Id="PolicyProfile"> 
    
      <DisplayName>PolicyProfile</DisplayName> 
    
      <Protocol Name="OpenIdConnect" /> 
    
      <OutputClaims> 
    
        <OutputClaim ClaimTypeReferenceId="displayName" /> 
    
        <OutputClaim ClaimTypeReferenceId="givenName" /> 
    
        <OutputClaim ClaimTypeReferenceId="surname" /> 
    
        <OutputClaim ClaimTypeReferenceId="email" /> 
    
        <OutputClaim ClaimTypeReferenceId="objectId" PartnerClaimType="sub" /> 
    
        <OutputClaim ClaimTypeReferenceId="identityProvider" />                 
    
        <OutputClaim ClaimTypeReferenceId="riskLevel" /> 
    
        <OutputClaim ClaimTypeReferenceId="score" /> 
    
        <OutputClaim ClaimTypeReferenceId="tenantId" AlwaysUseDefaultValue="true" DefaultValue="{Policy:TenantObjectId}" /> 
    
      </OutputClaims> 
    
      <SubjectNamingInfo ClaimType="sub" /> 
    
    </TechnicalProfile> 
    
    </RelyingParty>
    

与 Azure AD B2C 集成

将策略文件添加到 Azure AD B2C。 有关以下说明,请将目录与 Azure AD B2C 租户配合使用。

  1. 以 Azure AD B2C 租户的全局管理员身份登录到 Azure 门户
  2. 在门户工具栏中,选择“目录 + 订阅”。
  3. 在“门户设置”>“目录 + 订阅”页上的“目录名称”列表中,找到 Azure AD B2C 目录。
  4. 选择“切换”。
  5. 在 Azure 门户左上角,选择“所有服务”。
  6. 搜索并选择“Azure AD B2C”。
  7. 导航到“Azure AD B2C”>“Identity Experience Framework”。
  8. 将策略文件上传到租户。

测试解决方案

有关以下说明,请参阅教程:在 Azure Active Directory B2C 中注册 Web 应用程序

  1. 注册一个将重定向到 JWT.MS 的虚拟应用程序。

  2. 在“Identity Experience Framework”下,选择所创建的策略。

  3. 在策略窗口中,选择虚拟 JWT.MS 应用程序

  4. 选择“立即运行”。

  5. 执行注册流并创建帐户。

  6. 返回到 JWT.MS 的令牌具有 2 倍数量的 riskLevel 和评分声明。

  7. 使用以下示例。

    { 
    
      "typ": "JWT", 
    
      "alg": "RS256", 
    
      "kid": "_keyid" 
    
    }.{ 
    
      "exp": 1615872580, 
    
      "nbf": 1615868980, 
    
      "ver": "1.0", 
    
      "iss": "https://tenant.b2clogin.com/12345678-1234-1234-1234-123456789012/v2.0/", 
    
      "sub": "12345678-1234-1234-1234-123456789012", 
    
      "aud": "12345678-1234-1234-1234-123456789012", 
    
      "acr": "b2c_1a_signup_signin_biocatch_policy", 
    
      "nonce": "defaultNonce", 
    
      "iat": 1615868980, 
    
      "auth_time": 1615868980, 
    
      "name": "John Smith", 
    
      "email": "john.smith@contoso.com", 
    
      "given_name": "John", 
    
      "family_name": "Smith", 
    
      "riskLevel": "LOW", 
    
      "score": 275, 
    
      "tid": "12345678-1234-1234-1234-123456789012" 
    
    }.[Signature]  
    
    

其他资源