2017-10-11 85 views
1

我希望將policyId包含在執行我的Customized SignUpSignIn策略時返回的聲明中。執行我的Custom SignUpSignIn策略後,如何返回PolicyId聲明?

我認爲這應該在索賠Id tfp

還有is an article關於如何做到這一點。

在「設置索賠代表政策ID」一節中說,在「令牌頒發者」ClaimsProvider覆蓋中包含密鑰AuthenticationContextReferenceClaimPattern

<ClaimsProviders> 
    <ClaimsProvider> 
    <DisplayName>Token Issuer</DisplayName> 
    <TechnicalProfiles> 
     <TechnicalProfile Id="JwtIssuer"> 
     <Metadata> 
      ..... 
      <Item Key="AuthenticationContextReferenceClaimPattern">None</Item> 
     </Metadata> 
     </TechnicalProfile> 
    </TechnicalProfiles> 
    </ClaimsProvider> 
</ClaimsProviders> 

然後,你必須添加trustFrameworkPolicyoutputClaims。我覺得是這樣的:

<RelyingParty> 
    <DefaultUserJourney ReferenceId="SignUpOrSignIn" /> 
    <TechnicalProfile Id="PolicyProfile"> 
    <DisplayName>PolicyProfile</DisplayName> 
    <Protocol Name="OpenIdConnect" /> 
    <OutputClaims> 
     <OutputClaim ClaimTypeReferenceId="displayName" /> 
     <OutputClaim ClaimTypeReferenceId="givenName" /> 
     <OutputClaim ClaimTypeReferenceId="surname" /> 
     ...... 
     <OutputClaim ClaimTypeReferenceId="trustFrameworkPolicy" Required="true" DefaultValue="{policy}" /> 
    </OutputClaims> 
    <SubjectNamingInfo ClaimType="sub" /> 
</TechnicalProfile> 

但是當我上傳這個自定義策略文件則顯示錯誤:

「政策 「」 承租人 「B2C_1A_xxxx yyyyy.onmicrosoft.com」 品牌對id爲「trustframeworkPolicy」的ClaimType的引用,但策略或其任何基本策略都不包含此類元素。「

這意味着它找不到ClaimTypeReferenceId:「trustFrameworkPolicy」。

我是否必須添加ClaimType「trustframeworkPolicy」的聲明定義?在ClaimSchema中?

如果是這樣:它是什麼樣的?

回答

2

添加以下ClaimTypeTrustFrameworkExtensions.xml時:

<ClaimType Id="trustFrameworkPolicy"> 
    <DisplayName>Trust Framework Policy</DisplayName> 
    <DataType>string</DataType> 
    <DefaultPartnerClaimTypes> 
     <Protocol Name="OAuth2" PartnerClaimType="tfp" /> 
     <Protocol Name="OpenIdConnect" PartnerClaimType="tfp" /> 
    </DefaultPartnerClaimTypes> 
</ClaimType> 

注:ClaimType應該是<ClaimsSchema><BuildingBlocks>

子節點
+1

這是正確的答案!爲了在「tfp」聲明中包含PolicyName,我必須在我的問題中執行操作,並添加像@spottedmahn這樣的claimType。 – Rikkert

+0

[GitHub問題](https://github.com/Azure-Samples/active-directory-b2c-custom-policy-starterpack/issues/11)將'ClaimType'添加到入門包中。 – spottedmahn

0

PolicyId是ACR要求在使用Starter Pack

jwt token with acr tag

+0

@Rikkert檢查出這個其他的答案進一步的細節:https://stackoverflow.com/questions/46688455/in-azure-ad-b2c-should-the-acr-or-tfp-claim-have-the-policy-name/46697200# 46697200 – Pytry

+0

@Pytry這僅在使用常規B2C_1_SiUpIn策略時纔可配置。使用自定義策略時,您沒有「令牌,會話和SSO配置」屏幕。你必須用xml文件來配置它。 – Rikkert

+0

@Rikkert啊,謝謝你的信息:) – Pytry