Skip to content

Instantly share code, notes, and snippets.

@shammelburg
Created February 19, 2018 11:08
Show Gist options
  • Save shammelburg/eb3a7481f3a2309f4ecb8f9edff60385 to your computer and use it in GitHub Desktop.
Save shammelburg/eb3a7481f3a2309f4ecb8f9edff60385 to your computer and use it in GitHub Desktop.
Azure AD | ASP.NET Core | Check if user is in Policy Group
private IAuthorizationService _AuthorizationService;
public HomeController(IAuthorizationService AuthorizationService)
{
this._AuthorizationService = AuthorizationService;
}
[Authorize(Policy = "SecurityGroup")]
public async Task<IActionResult> About()
{
if((await _AuthorizationService.AuthorizeAsync(User, "SecurityGroup")).Succeeded)
{
//
}
return View();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment