我在 Azure Active Directory 中有自定义扩展属性(通过 Azure AD Connect 映射)。 Azure AD 上的扩展属性采用以下形式extension_<uniqueid>_<attributename>
.
当用户通过 Open ID Connect 登录时,我想向应用程序公开多个扩展属性。这些属性应包含在 JWT 令牌中。
我尝试使用来自微软页面 https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-claims-mapping#example-create-and-assign-a-policy-to-include-the-employeeid-and-tenantcountry-as-claims-in-tokens-issued-to-a-service-principal创建策略并将其分配给想要在登录时接收令牌的应用程序的服务主体 ID。
这些是我使用的 powershell 命令。
Connect-AzureAD -Confirm
New-AzureADPolicy -Definition @('{"ClaimsMappingPolicy":{"Version":1,"IncludeBasicClaimSet":"true","ClaimsSchema":[{"Source":"user","ID":"extension_uniqueidretracted_extensionAttribute13","SamlClaimType":"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/extensionAttribute13","JwtClaimType":"MyCustomClaim1"},{"Source":"user","ID":"extension_uniqueidretracted_extensionAttribute14","SamlClaimType":"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/extensionAttribute14","JwtClaimType":"MyCustomClaim2"}]}}') -DisplayName "ExtensionAttributeMapping" -Type "ClaimsMappingPolicy"
Add-AzureADServicePrincipalPolicy -Id <ObjectId of the ServicePrincipal> -RefObjectId <ObjectId of the Policy>
创建和分配策略可以工作,但属性仍然不包含在令牌中。
我需要做什么才能使这项工作成功?
- 确保在 Azure AD 中的应用程序清单中将 AcceptMappedClaims 设置为 true。
- 尝试在 ClaimsMappingPolicy 中使用 "ExtensionID":"extension_uniqueidretracted_extensionAttribute13" 而不是 "ID":"extension_uniqueidretracted_extensionAttribute13"。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)