Skip to content

Commit

Permalink
Section 10 - Policy based authorization with Claims
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhrugen Patel committed Sep 7, 2020
1 parent 941ae54 commit 84d9ebd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions IdentityManager/Controllers/AccessCheckerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public IActionResult AdminAccess()
return View();
}

[Authorize(Policy = "Admin_CreateAccess")]
//Accessible by Admin users with a claim of create to be True
public IActionResult Admin_CreateAccess()
{
Expand Down
1 change: 1 addition & 0 deletions IdentityManager/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public void ConfigureServices(IServiceCollection services)
{
options.AddPolicy("Admin", policy => policy.RequireRole("Admin"));
options.AddPolicy("UserAndAdmin", policy => policy.RequireRole("Admin").RequireRole("User"));
options.AddPolicy("Admin_CreateAccess", policy => policy.RequireRole("Admin").RequireClaim("create", "True"));
});

services.AddControllersWithViews();
Expand Down

0 comments on commit 84d9ebd

Please sign in to comment.