如何从广告b2c中检索用户同意的版本?

时间:2019-09-05 05:56:12

标签: azure azure-ad-b2c

我正在使用AZure Ad B2C租户,并且在注册时具有自定义同意字段。这很好,并且只要我们更新同意,便会提示用户。

我必须保留用户同意的历史记录。可以说在注册时user1接受了同意(v1),一段时间后user1接受了同意(v2),等等。

我需要用户接受/拒绝的所有同意的历史记录。有可能找回吗?

我尝试了以下方法。

  1. 添加了两个扩展声明以及具有字符串类型的同意字段(因为扩展声明不支持stringcollection)

    <ClaimType Id="extension_TermsOfUseConsented">
        <DisplayName>Terms of Use Consented</DisplayName>
        <DataType>string</DataType>
        <UserInputType>CheckboxMultiSelect</UserInputType>
        <Restriction>
          <Enumeration Text="I am agreeing to the terms of use" Value="2018-10-29" SelectByDefault="false" />
        </Restriction>
      </ClaimType>      
    <ClaimType Id="extension_TempConsent">
      <DisplayName>temp Consent</DisplayName>
      <DataType>string</DataType>      
    </ClaimType>
    
    <ClaimType Id="extension_ConsentHistory">
      <DisplayName>consent history</DisplayName>
      <DataType>string</DataType>      
    </ClaimType>
    
  2. 在“注册依赖方”部分中添加了以上字段。

    <RelyingParty>
    <DefaultUserJourney ReferenceId="SignUpOrSignIn-withConsent" />
    <TechnicalProfile Id="PolicyProfile">
      <DisplayName>PolicyProfile</DisplayName>
      <Protocol Name="OpenIdConnect" />
      <InputClaims>          
      </InputClaims>
      <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="displayName" />
        <OutputClaim ClaimTypeReferenceId="givenName" />
        <OutputClaim ClaimTypeReferenceId="surname" />
        <OutputClaim ClaimTypeReferenceId="signInNames.emailAddress" PartnerClaimType="email" />
        <OutputClaim ClaimTypeReferenceId="objectId" PartnerClaimType="sub"/>
        <OutputClaim ClaimTypeReferenceId="extension_TermsOfUseConsented" />
        <OutputClaim ClaimTypeReferenceId="extension_ConsentHistory" />
        <OutputClaim ClaimTypeReferenceId="extension_TempConsent" />
    
      </OutputClaims>
      <SubjectNamingInfo ClaimType="sub" />
    </TechnicalProfile>
    

  3. 在用户旅程第3步中,请阅读“ AAD-UserReadUsingObjectId”技术资料中的上述声明。

           <TechnicalProfile Id="AAD-UserReadUsingObjectId">
           <Metadata>
           <Item Key="Operation">Read</Item>
            <Item Key="RaiseErrorIfClaimsPrincipalDoesNotExist">true</Item>
            </Metadata>
            <IncludeInSso>false</IncludeInSso>
            <InputClaims>
            <InputClaim ClaimTypeReferenceId="objectId" Required="true" />
            </InputClaims>
            <OutputClaims>
    
            <!-- Optional claims -->
            <OutputClaim ClaimTypeReferenceId="signInNames.emailAddress" />
            <OutputClaim ClaimTypeReferenceId="displayName" />
            <OutputClaim ClaimTypeReferenceId="otherMails" />
            <OutputClaim ClaimTypeReferenceId="givenName" />
            <OutputClaim ClaimTypeReferenceId="surname" />
            <OutputClaim ClaimTypeReferenceId="extension_TermsOfUseConsented" /> 
            <OutputClaim ClaimTypeReferenceId="extension_TempConsent" />
            <OutputClaim ClaimTypeReferenceId="extension_ConsentHistory" />
            <OutputClaim ClaimTypeReferenceId="extension_ReadStringFromVP" />
          </OutputClaims>
          <IncludeTechnicalProfile ReferenceId="AAD-Common" />
        </TechnicalProfile>
    
  4. 在步骤4中,读取同意值,如果条款是新条款,则提示用户接受。在索赔交换中,请参考以下技术资料。

       <TechnicalProfile Id="SelfAsserted-Consent">
          <DisplayName>User Consent</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.consent</Item>
          </Metadata>
          <CryptographicKeys>
            <Key Id="issuer_secret" StorageReferenceId="B2C_1A_TokenSigningKeyContainer" />
          </CryptographicKeys>
          <InputClaims />
          <OutputClaims>
            <OutputClaim ClaimTypeReferenceId="extension_TermsOfUseConsented" Required="true" />
            <OutputClaim ClaimTypeReferenceId="extension_TempConsent" DefaultValue="," />
            <OutputClaim ClaimTypeReferenceId="extension_ConsentHistory" DefaultValue="," />
          </OutputClaims>
           <OutputClaimsTransformations>                
                 <OutputClaimsTransformation ReferenceId="AppendConsent" />        
                 <OutputClaimsTransformation ReferenceId="TakeConsentBackup" />             
           </OutputClaimsTransformations>
          <ValidationTechnicalProfiles>
            <ValidationTechnicalProfile ReferenceId="AAD-WriteUserConsentByObjectId-ThrowIfNotExists" />
          </ValidationTechnicalProfiles>
        </TechnicalProfile>
    
  5. 在ClaimsTransformation中进行一些字符串处理

      <ClaimsTransformation Id="TakeConsentBackup" TransformationMethod="FormatStringMultipleClaims">
        <InputClaims>
        <InputClaim ClaimTypeReferenceId="extension_ConsentHistory" TransformationClaimType="inputClaim1" />
        <InputClaim ClaimTypeReferenceId="extension_TempConsent" TransformationClaimType="inputClaim2" />
      </InputClaims>
      <InputParameters>
        <InputParameter Id="stringFormat" DataType="string" Value="{1},{0}" />
      </InputParameters>
      <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="extension_ConsentHistory" TransformationClaimType="outputClaim" />
      </OutputClaims>
    </ClaimsTransformation>
    
     <ClaimsTransformation Id="AppendConsent" TransformationMethod="FormatStringMultipleClaims">
        <InputClaims>
        <InputClaim ClaimTypeReferenceId="extension_TermsOfUseConsented" TransformationClaimType="inputClaim1" />
        <InputClaim ClaimTypeReferenceId="extension_TempConsent" TransformationClaimType="inputClaim2" />
      </InputClaims>
      <InputParameters>
        <InputParameter Id="stringFormat" DataType="string" Value="{1}{0}" />
      </InputParameters>
      <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="extension_TempConsent" TransformationClaimType="outputClaim" />
      </OutputClaims>
    </ClaimsTransformation>
    
  6. 在AAD-WriteUserConsentByObjectId-ThrowIfNotExists中编写如下的扩展声明。

    <TechnicalProfile Id="AAD-WriteUserConsentByObjectId-ThrowIfNotExists">
    <Metadata>
    <Item Key="Operation">Write</Item>
    <Item Key="RaiseErrorIfClaimsPrincipalDoesNotExist">true</Item>
    </Metadata>
    <IncludeInSso>false</IncludeInSso>
    <InputClaims>
    <InputClaim ClaimTypeReferenceId="objectId" Required="true" />
    </InputClaims>
    <PersistedClaims>
    <PersistedClaim ClaimTypeReferenceId="objectId" />
    <PersistedClaim ClaimTypeReferenceId="extension_TermsOfUseConsented" />         
    <PersistedClaim ClaimTypeReferenceId="extension_ConsentHistory" />
    

      

  7. 在索赔返回时,其显示字符串操作值(在同意的时间) 但在下次登录(未经同意)时,它不会返回扩展名字段。仅获取extension_TermsOfUseConsented字段值。 enter image description here

  8. 仅在策略中处理预期的索赔扩展,而并非来自用户输入。那是问题吗?

我在这里想念什么?

先谢谢。

0 个答案:

没有答案