我正在寻找ASP.NET MVC应用程序的帮助。它可以对单个租户进行身份验证以使活动目录用户蔚蓝,并可以使用活动目录安全组授权用户。即,如果用户是该安全组的一部分,则仅允许访问网站,否则拒绝访问。
Active Directory身份验证可以由Visual Studio本身使用向导完成,但不确定如何通过AAD安全组执行授权。
PS我是ASP.NET安全的新手
设置规格
Startup.cs配置
// COOKIES: Tells it to use cookies for authentication.
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
CookieManager = new SystemWebCookieManager()
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions()
{
ClientId = ClientID,
Authority = Authority,
PostLogoutRedirectUri = PostLogoutRedirectUri,
Notifications = new OpenIdConnectAuthenticationNotifications()
{
AuthenticationFailed = PrincipalService.OnAzureAuthenticationFailure,
AuthorizationCodeReceived = (AuthorizationCodeReceivedNotification notification) =>
{
var username = notification.AuthenticationTicket.Identity.Name.Split('#').LastOrDefault();
var emailAddress = notification.AuthenticationTicket.Identity.Claims.FirstOrDefault(x => x.Type.Contains("emailaddress"))?.Value;
Logger.Log(Level.Auth, $"Azure login success! Username: '{username}' Email: '{emailAddress}'.");
return Task.FromResult(0);
}
}
});
Run Code Online (Sandbox Code Playgroud)
题
在进行此设置后,如何检查当前登录的用户是否在特定的AD组中? …