久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 JWT 檢索 Azure AD 組信息

Retrieving Azure AD Group information with JWT(使用 JWT 檢索 Azure AD 組信息)
本文介紹了使用 JWT 檢索 Azure AD 組信息的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我有需要 Azure AD 不記名身份驗證的 API.

I have APIs that require Azure AD bearer authentication.

public void ConfigureAuth(IAppBuilder app)
{
   app.UseWindowsAzureActiveDirectoryBearerAuthentication(
      new WindowsAzureActiveDirectoryBearerAuthenticationOptions
      {
         // ...
      });
}

是否可以查詢 Azure AD(可能使用 Graph API)來確定調用用戶的組信息?此處的最終目標是將基于角色的安全性應用于 API 方法/控制器,如下所示(或類似).

Is it then possible to query Azure AD - perhaps using the Graph API - to determine the group information of the calling user? The end goal here is to apply role-based security to the API methods/controllers, as below (or similar).

[PrincipalPermission(SecurityAction.Demand, Role = "Admin")]

另外,身份信息是如何以及在哪里應用到執行線程的?

Additionally, how and where is the identity information applied to the executing thread?

推薦答案

最近,您可以使用角色聲明和/或組聲明來執行此操作.如果您有一個受承載身份驗證保護的 Web API(如 此處的示例),您可以配置 API,以便訪問令牌包含組和/或角色聲明.

As of recently, you can use Role Claims and/or Group Claims to do so. If you have a web API protected with bearer authentication (like in the sample here), you can configure the API so that access tokens contain Group and/or Role claims.

OWIN 中間件將讀取 JWT 不記名令牌中的聲明,并在 System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler 中使用適當的聲明填充 ClaimsIdentity (來源).

The OWIN middleware will read the claims in the JWT bearer token and populate the ClaimsIdentity with appropriate claims, in the System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler (source).

要配置您的 API 以接收組聲明,您需要編輯應用程序清單的 "groupMembershipClaims" 屬性,其值為 "All"本示例(分別包含或排除分發列表)a>,它使用組聲明將基于角色的安全性應用到使用 [Authorize] 標記的 Web 應用程序.

To configure your API to receive Group Claims, you need to edit the "groupMembershipClaims" property of the application manifest with a value of "All" or "SecurityGroups" (distribution lists included or excluded, respectively) as shown in this sample, which uses Group Claims to apply role-based security to a web app using the [Authorize] tag.

要配置您的 API 以接收角色聲明,您還需要編輯清單,在 "appRoles" 屬性中定義應用程序角色,如 此示例(鏈接尚未激活 - 它將在接下來的幾天內),它使用角色聲明來執行相同的操作.定義應用程序角色后,您可以在 Azure 門戶中或通過 GraphAPI 將用戶和組分配給這些角色.請注意,由于 AAD 發出的聲明屬于 "roles" 類型,因此您需要將 RoleClaimType 設置為:

To configure your API to receive Role Claims, you also need to edit the manifest, defining Application Roles in the "appRoles" property as shown in this sample (link not yet active - it will be in the next few days), which uses Role Claims to do the same. Once you have defined Application Roles, you can assign users and groups to those roles in the Azure Portal or via the GraphAPI. Note because the claims emitted by AAD are of type "roles", you will need to set the RoleClaimType as:

new WindowsAzureActiveDirectoryBearerAuthenticationOptions  
{  
   ...
   TokenValidationParameters = new TokenValidationParameters {  
       RoleClaimType = "roles",  
   },  
   ...  
}

這篇關于使用 JWT 檢索 Azure AD 組信息的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進行身份驗證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權不起作用)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護進程或服務器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發技
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
Getting access token using email address and app password from oauth2/token(使用電子郵件地址和應用程序密碼從 oauth2/token 獲取訪問令牌)
New Azure AD application doesn#39;t work until updated through management portal(新的 Azure AD 應用程序在通過管理門戶更新之前無法運行)
主站蜘蛛池模板: 麻豆视频国产 | 黄色一级片免费 | 亚洲免费视频一区 | 一区二区国产精品 | 美女福利网站 | 亚洲香蕉在线 | 国产欧美日韩在线观看 | 日韩欧美在线观看视频 | 香蕉视频色版 | 国产精品久久久久久久久久久久久 | 免费成年人视频 | 精品视频免费在线观看 | 成人黄色一级片 | av不卡在线播放 | 日日日操 | 日韩在线专区 | 成人看片免费 | 亚洲视频在线播放 | 99精品视频在线观看 | a在线免费观看 | 国产精品综合 | 久久久久久国产精品 | 成人小视频在线 | 操操操操操操 | 天堂网在线资源 | 三级av网站| 天堂成人网| 国产一区二区影院 | 久久精品欧美一区二区 | 国产欧美综合一区二区三区 | 精品一区视频 | 国产免费一级 | 国产精品乱码一区二区视频 | av久久久| 美女综合网 | 一区二区三区在线播放 | 欧美一区二区三区在线视频 | 九九热在线精品 | 久久精品三级 | 日韩一区三区 | 五月天堂网 |