我只是想知道是否有方法通過Azure門戶向Azure Ad OAuth2 JWT令牌添加或指定自定義聲明? 或者這是唯一可能的代碼方?添加Azure廣告Oauth2 JWT令牌聲明
回答
我相信您可以通過閱讀Authorization in a web app using Azure AD application roles & role claims Azure-AD示例的How to run the sample as a single-tenant app部分來了解如何設置其他聲明(例如角色聲明)的示例。這需要編輯Azure-AD應用程序清單以添加應用程序角色。然後分配不同的角色給目錄中的不同用戶
據我所知,Azure AD目前不支持發佈自定義聲明。
作爲解決方法,我們可以使用Azure AD Graph添加directory schema extensions。在此之後,我們可以使用Azure的AD圖來獲取數據擴展並添加自定義的要求時,安全令牌驗證像下面的代碼:
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
PostLogoutRedirectUri = postLogoutRedirectUri,
Notifications = new OpenIdConnectAuthenticationNotifications
{
AuthenticationFailed = context =>
{
context.HandleResponse();
context.Response.Redirect("/Error?message=" + context.Exception.Message);
return Task.FromResult(0);
}
,
SecurityTokenValidated = context =>
{
//you can use the Azure AD Graph to read the custom data extension here and add it to the claims
context.AuthenticationTicket.Identity.AddClaim(new System.Security.Claims.Claim("AddByMe", "test"));
return Task.FromResult(0);
}
});
此外,如果你有關於Azure的任何想法或意見,你可以從here提交。
好吧,我明白,這可能是我的選擇。但我正在尋找的是在azure AD發佈的jwt令牌中包含deviceID聲明。我在這裏找到了一些有關它的信息: https://msdn.microsoft.com/en-us/windows/hardware/commercialize/customize/mdm/azure-active-directory-integration-with-mdm 根據主題:「使用協議語義」和「使用Azure AD的管理協議」 這僅適用於BYOD訂閱還是我誤解了這一點? @FeiXue感謝您的答案btw :) – John
@John感謝您與我們分享答案。我建議你撰寫一篇文章並將其標記爲答案,以便其他具有相同問題的人可以很容易地重新整理它,並可以從中受益:) –
對不起,也許我在上面的問題中有點不清楚。我沒有找到解決方案,我只是簡單地要求引用上面的鏈接:我是否能夠將設備ID包含在不記名令牌的聲明中,還是隻能在BYOD訂閱中使用?最好的祝願。 :) – John
- 1. 將聲明添加到OpenAM中的JWT令牌?
- 2. Azure廣告和Azure廣告b2c令牌驗證失敗
- 3. mvc azure廣告令牌到期
- 4. Azure的廣告訪問令牌澄清
- 5. Azure廣告組成員身份聲明
- 6. 瞭解JWT令牌谷歌的OAuth2
- 7. 的oauth2 JWT令牌驗證過程
- 8. 撤銷JWT的OAuth2刷新令牌
- 9. Spring Security OAuth2 JWT令牌中繼問題
- 10. 令牌聲明
- 11. 從JWT令牌
- 12. 在Volley請求中添加JWT令牌
- 13. 向數組添加聲明給JWT?
- 14. azure-ad-jwt它如何驗證令牌
- 15. 從WebAPI控制器獲取聲明 - JWT令牌,
- 16. JWT令牌中「kid」聲明的含義是什麼?
- 17. 無法從JWT令牌獲得與ASP.NET Core的聲明
- 18. 如何在jwt中使用jose-jwt添加聲明
- 19. 預期的聲明「}」令牌
- 20. 驗證Azure廣告訪問令牌時簽名無效,但id令牌有效
- 21. 如何向WCF中的安全令牌添加附加聲明
- 22. OAuth2令牌PHP
- 23. WSO2IS JWT訪問令牌
- 24. Json Web令牌JWT
- 25. JWT令牌共享
- 26. JWT令牌SSO流
- 27. Spring Oauth JWT - 刷新令牌
- 28. JWT令牌和Owin認證
- 29. Azure廣告在聲明中返回角色,但User.IsInRole返回false
- 30. 使用JWT令牌的安全令牌驗證錯誤 - HDInsight
嗯,我不認爲在角色聲明中說「自定義」是有效的。至於字面上的**自定義**聲明 - 這是不可能實現的。 – user7567234