久久久久久久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)來確定調(diào)用用戶的組信息?此處的最終目標是將基于角色的安全性應(yīng)用于 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")]

另外,身份信息是如何以及在哪里應(yīng)用到執(zhí)行線程的?

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

推薦答案

最近,您可以使用角色聲明和/或組聲明來執(zhí)行此操作.如果您有一個受承載身份驗證保護的 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 中使用適當?shù)穆暶魈畛?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 以接收組聲明,您需要編輯應(yīng)用程序清單的 "groupMembershipClaims" 屬性,其值為 "All"本示例(分別包含或排除分發(fā)列表)a>,它使用組聲明將基于角色的安全性應(yīng)用到使用 [Authorize] 標記的 Web 應(yīng)用程序.

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" 屬性中定義應(yīng)用程序角色,如 此示例(鏈接尚未激活 - 它將在接下來的幾天內(nèi)),它使用角色聲明來執(zhí)行相同的操作.定義應(yīng)用程序角色后,您可以在 Azure 門戶中或通過 GraphAPI 將用戶和組分配給這些角色.請注意,由于 AAD 發(fā)出的聲明屬于 "roles" 類型,因此您需要將 RoleClaimType 設(shè)置為:

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",  
   },  
   ...  
}

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

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

相關(guān)文檔推薦

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 令牌授權(quán)不起作用)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護進程或服務(wù)器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發(fā)技
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調(diào)用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
Getting access token using email address and app password from oauth2/token(使用電子郵件地址和應(yīng)用程序密碼從 oauth2/token 獲取訪問令牌)
New Azure AD application doesn#39;t work until updated through management portal(新的 Azure AD 應(yīng)用程序在通過管理門戶更新之前無法運行)
主站蜘蛛池模板: 91精品一区二区三区久久久久 | 精品欧美黑人一区二区三区 | 国产精品视频一区二区三区不卡 | 欧美三区 | 国产精品毛片一区二区三区 | 日本精品视频一区二区 | 成人在线精品视频 | 成人精品免费视频 | 成人av电影在线 | 亚洲国产精品va在线看黑人 | 久久精品国产久精国产 | 一级毛片免费看 | 91九色网站| 午夜成人免费视频 | 97视频免费 | 午夜精品一区二区三区免费视频 | 亚洲精品欧美精品 | 日韩国产免费 | 久久久久久久综合色一本 | 亚洲精品国产a久久久久久 中文字幕一区二区三区四区五区 | 久久久精品久 | 亚洲一区 中文字幕 | 欧美日韩a| 国产精品国产三级国产aⅴ中文 | 超碰综合| 久久成人国产 | 毛片a| 国产999精品久久久久久 | 91精品一区 | 亚洲成av人片在线观看 | 中文字幕日韩三级 | 欧美福利视频一区 | 欧美日日| 一级黄色毛片免费 | 一区二区三区视频在线 | 韩国av电影网 | 性色视频在线观看 | 欧美电影网 | aaa精品| 欧美成人在线影院 | 亚洲视频在线免费观看 |