ASP.Net Core:保持Windows身份验证 [英] ASP.Net Core: keep windows authentication

查看:103
本文介绍了ASP.Net Core:保持Windows身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上正在一个用户通过Windows身份验证登录的网站上.

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

我的问题是,实际上所有用户在打开我们的网页时都必须登录.我想知道是否有可能保持Windows身份验证的生命力?也许还有饼干?

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?

我通过将身份验证添加到我的 Startup.cs 中来实现身份验证:

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

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

services.AddAuthentication(IISDefaults.AuthenticationScheme);

并在我的项目设置中激活Windows身份验证.

And activating Windows-Authentication in my project-settings.

此后,我无法使用Authorize-atrribute:

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.

即使用户正在关闭浏览器,有什么方法可以使Windows身份验证保持活动状态?

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

感谢您的帮助和想法!

推荐答案

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

Well I found a way to get want I wanted, but its not the way I wanted:

最后,我宣布自己的网站为受捆绑的网站.诀窍在于,登录数据始终会传递到Web服务器.

I ended up by declaring my site as a trused one. The trick hereby is, that the login data is always passed to the webserver.

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

In chrome you can achive it htis way : Menu -> Settings -> Advanced Settings -> Change proxy settings -> Security -> Trusted Sites -> Add the URL of your page

可以在此处找到其他打开设置的方法(Firefoy,IE):

Other ways(Firefoy, IE) to open that settings can be found here : https://effortz.com/add-website-browsers-trusted-sites-windows-os/

执行此操作仅对您实际使用的PC有效.这些设置通常由系统管理员管理.在这种情况下,管理员可以将您的网站设置为网络中所有用户信任的网站.而且繁荣的每个用户都将自动登录,并且登录数据始终可用.

Doing this will onl work for the PC you are actually on. Often those settings are managed by systemadministrators. In this case, the admins can set your site trusted for all users in your network. And boom every user is automatically logged in and the login data is always available.

这篇关于ASP.Net Core:保持Windows身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆