我正在为AAD B2C编写自定义政策,并且需要包含一些内置声明(国家/地区,邮政编码,城市,地址)。
我使用了入门包,并注意到,甚至像电子邮件这样的声明也在TrustFrameworkBase ClaimSchema元素的架构中声明,如以下示例所示,其中一些声明通过协议引用了DefaultPartnerClaimTypes元素:
<ClaimsSchema>
...
<ClaimType Id="displayName">
<DisplayName>Display Name</DisplayName>
<DataType>string</DataType>
<DefaultPartnerClaimTypes>
<Protocol Name="OAuth2" PartnerClaimType="unique_name" />
<Protocol Name="OpenIdConnect" PartnerClaimType="name" />
<Protocol Name="SAML2" PartnerClaimType="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name" />
</DefaultPartnerClaimTypes>
<UserHelpText>Your display name.</UserHelpText>
<UserInputType>TextBox</UserInputType>
</ClaimType>
...
<ClaimType Id="email">
<DisplayName>Email Address</DisplayName>
<DataType>string</DataType>
<DefaultPartnerClaimTypes>
<Protocol Name="OpenIdConnect" PartnerClaimType="email" />
</DefaultPartnerClaimTypes>
<Restriction>
<Pattern RegularExpression="^[a-zA-Z0-9.!#$%&'^_`{}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$" HelpText="Please enter a valid email address." />
</Restriction>
</ClaimType>
...
</ClaimsSchema>
这些是文本类型的声明,例如,电子邮件声明具有用于验证电子邮件地址的正则表达式限制,我的问题是例如关于国家/地区声明,在内置声明中,其枚举受到限制并显示为下拉列表。是否可以从我的自定义策略中引用它而不定义所有元素和规则?只需引用内置的ClaimType?
谢谢
答案 0 :(得分:1)
国家/地区声明被映射到the user object的国家/地区属性。 用户对象的 country 属性可以包含任何字符串值。
因此,由策略开发人员确定是否应将国家/地区声明限制为众所周知的值列表。
如果是,则必须在声明类型中添加the <Restriction />
element。