我在 Azure Active Directory 中有自定义扩展属性(通过 Azure AD Connect 映射)。 Azure AD 上的扩展属性采用形式 extension_<uniqueid>_<attributename>
.
当用户通过 Open ID Connect 登录时,我想向应用程序公开几个扩展属性。这些属性应包含在 JWT token 中。
我尝试使用 Microsoft Page 中的方法创建策略并将其分配给希望在登录时接收 token 的应用程序的服务主体 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>
创建和分配策略有效,但属性仍未包含在 token 中。
我需要做什么才能完成这项工作?
最佳答案
关于jwt - 如何在登录时在 JWT token 中从 Azure Active Directory 传递自定义扩展属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56106717/