首页 > 解决方案 > ASP.Net Core: keep windows authentication

问题描述

I'm actually working on an website where users login via windows authentication.

My problem is, that actually all users have to login whenever they open our webpage. I wonder if it is possible to keep that windows authentification alive? Maybe with cookies?

I implemented the authentification by adding this to my Startup.cs:

services.Configure<IISOptions>(options =>
{
    options.AutomaticAuthentication = true;
});

services.AddAuthentication(IISDefaults.AuthenticationScheme);

And activating Windows-Authentication in my project-settings.

Afterwards im able to use the Authorize-atrribute:

[Authorize]
public IActionResult Index()
{
    return View();
}

If the user isn't logged in he is now asked to log in.

Is there any way to keep the windows-authentication alive, even if the user is closing his browser?

Thanks for your help and your ideas in advance!

标签: c#asp.net-mvcasp.net-core-mvcasp.net-core-2.0windows-authentication

解决方案


好吧,我找到了一种获得想要的方式,但这不是我想要的方式:

最后,我将我的网站声明为受信任的网站。这里的诀窍是,登录数据总是传递给网络服务器。

在 chrome 中,您可以通过以下方式实现它:菜单 -> 设置 -> 高级设置 -> 更改代理设置 -> 安全 -> 受信任的站点 -> 添加页面的 URL

可以在此处找到打开该设置的其他方式(Firefoy、IE):https ://effortz.com/add-website-browsers-trusted-sites-windows-os/

这样做仅适用于您实际使用的 PC。这些设置通常由系统管理员管理。在这种情况下,管理员可以将您的网站设置为网络中所有用户的信任。并且每个用户都会自动登录,并且登录数据始终可用。


推荐阅读