c# - 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!
解决方案
好吧,我找到了一种获得想要的方式,但这不是我想要的方式:
最后,我将我的网站声明为受信任的网站。这里的诀窍是,登录数据总是传递给网络服务器。
在 chrome 中,您可以通过以下方式实现它:菜单 -> 设置 -> 高级设置 -> 更改代理设置 -> 安全 -> 受信任的站点 -> 添加页面的 URL
可以在此处找到打开该设置的其他方式(Firefoy、IE):https ://effortz.com/add-website-browsers-trusted-sites-windows-os/
这样做仅适用于您实际使用的 PC。这些设置通常由系统管理员管理。在这种情况下,管理员可以将您的网站设置为网络中所有用户的信任。并且每个用户都会自动登录,并且登录数据始终可用。
推荐阅读
- php - 登录后根据用户角色显示不同的页面
- node.js - Pagination in node js
- javascript - jQuery加载后如何专注于输入
- sql - 如何将 PredicateBuilder 与 Inner Join 一起使用
- google-chrome - Google Meet 虚拟背景如何运作?
- c# - 值不能为空。(参数“工厂”),ASP.NET Core MVC 中的 ILoggerFactory,.NET 5
- r - 如何更改棒棒糖上的行之间的距离
- python - Python,如果从另一个类调用方法,则无法断言
- flutter - 当我想启动我的应用程序时,为什么我会收到错误消息?
- python - 计算 discord.py 上的反应