1
尝试在测试环境中实现主题。ASP.NET Core中特定路由上的NTLM身份验证
.UseWebListener(options=>
{
options.ListenerSettings.Authentication.Schemes = AuthenticationSchemes.NTLM |
AuthenticationSchemes.Negotiate;
options.ListenerSettings.Authentication.AllowAnonymous = true;
})
而且
app.UseWhen(context => context.Request.Path.StartsWithSegments("/ntlm"),
builder => builder.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AutomaticAuthenticate = true,
AutomaticChallenge = true,
LoginPath = "/Main/Login",
LogoutPath = "/Main/Logout",
AuthenticationScheme = "NTLM", AccessDeniedPath = "/Main/Deny"
}
));
app.UseWhen(context => !context.Request.Path.StartsWithSegments("/ntlm"),
builder => builder.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AutomaticAuthenticate = false,
AutomaticChallenge = false,
LoginPath = "/Main/Login",
LogoutPath = "/Main/Logout",
AuthenticationScheme = "Cookies"
}
));
但似乎可以去看没有区别,请求路径是否符合 “/ NTLM” 或不启动。
我试着运行两个WebListeners,但我认为有更多的开销。
我想要达到的目标: 用户登录开始页面,登录表单上有一个“Windows验证”按钮。 他可以输入凭据或按下按钮并以他的操作系统身份进入。
魔法!这是正确的方法。 谢谢! – Danil
很酷。对于您想通过cookie保护的操作,您可以指定[授权(ActiveAuthenticationSchemes =“Cookie”)]以确保这是用于设置用户身份的中间件。 – Daboul