![](/img/trans.png)
[英]Azure Active Directory Login: Web App Permissions, User Consent not triggered
[英]Is there a way to add custom permissions for web app user in azure active directory
例如,我在應用程序注冊中有一個應用程序“ myApp”,在Azure Active Directory User1
有一個用戶,該用戶是AD中的管理員。 我想在該應用程序中通過Azure AD使用身份驗證,並希望User1
僅具有訪問“ api / todos”和“ api / vehicles”的權限。 因此,可以有一個角色“ Role1, with permissions
Todos ,
Vehicles的with permissions
。 有沒有一種配置方法? 謝謝。
是的,有一種配置方法。 Azure使用角色概念。 此示例顯示了如何在Web API中執行此操作。
簡而言之:您需要定義可能的角色,並通過管理門戶中的應用程序配置將用戶分配給他們。 然后,您需要在Web API控制器方法上使用[Authorize]
屬性來定義用戶應該扮演的角色,例如在示例控制器之一中 :
[Authorize(Roles = "Admin, Observer, Writer, Approver")]
public ActionResult Index()
{
ViewBag.Message = "Tasks";
ViewData["tasks"] = TasksDbHelper.GetAllTasks();
return View();
}
與[Authorize]
一樣,它是繼承的,因此可以將其放在整個控制器類中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.