简体   繁体   English

Chrome绕过MVC 4 Web应用程序的Windows身份验证

[英]Chrome bypass Windows Authentication for MVC 4 web application

I have an MVC 4 web application that uses Windows Authentication. 我有一个使用Windows身份验证的MVC 4 Web应用程序。 I deploy that app to real web server with IIS 7. The Windows Authentication function works well with Internet Explorer (IE), FireFox (FF), and Safari, but it does not work with Chrome; 我将该应用程序部署到带有IIS 7的真实Web服务器上。Windows身份验证功能可以很好地与Internet Explorer(IE),FireFox(FF)和Safari一起使用,但不适用于Chrome; I am using Chrome version 27. 我正在使用Chrome版本27。

Here, " Works " means when user opens a browser (IE, FF, or Safari) and browses to the web application site, he/she is firstly prompted to provide valid credentials in a dialog box. 在这里,“ Works ”表示当用户打开浏览器(IE,FF或Safari)并浏览到Web应用程序站点时,首先会提示他/她在对话框中提供有效的凭据。 Then if his/her credentials are valid, then the user is allowed to view the web site pages. 然后,如果他/她的凭据有效,则允许用户查看网站页面。 " Does not work with Chrome " means Chrome always let users browse the web pages right away without seeing the credential dialog box and without prompting them to enter credentials in the dialog box as IE, FF or Safari does! 不适用于Chrome ”表示Chrome始终允许用户立即浏览网页,而不会看到凭据对话框,也不会像IE,FF或Safari一样提示用户在对话框中输入凭据! That is the issue I do not know how to solve although I tried to clear cookies, caches for my Chrome browser and shut down and open Chrome again. 尽管我尝试清除Cookie,Chrome浏览器的缓存,然后关闭并再次打开Chrome,但我不知道该如何解决。 I know the "cookie clear" action for Chrome is not supposed to do because Windows Authentication mode in IIS has nothing to do with cookie like Forms Authentication mode does. 我知道不应执行Chrome的“清除Cookie”操作,因为IIS中的Windows身份验证模式与“表单身份验证”模式无关,与Cookie无关。

At very first time when I tested my web application with Chrome right after deploy the web application to server, Chrome did prompted me to input credentials in the dialog box, but from the second time on, Chrome does not prompt me any more. 第一次将Web应用程序部署到服务器后,当我使用Chrome测试我的Web应用程序时,Chrome浏览器确实提示我在对话框中输入凭据,但是从第二次开始,Chrome浏览器不再提示我。

Please let me know what I should do to stop Chrome browser from letting users bypass the credential prompt dialog box. 请让我知道我应该怎么做才能阻止Chrome浏览器让用户绕过凭据提示对话框。 Thank you in advance. 先感谢您。

I followed 2 steps below to make my MVC web application work with IE, FF and Safari: 我按照以下两个步骤使MVC Web应用程序可与IE,FF和Safari一起使用:

1 1个

In the web configuration (web.config) file of my MVC 4 web application (Intranet Template), I specify the Windows Authentication function as: 在我的MVC 4 Web应用程序(Intranet模板)的Web配置(web.config)文件中,我将Windows身份验证功能指定为:

<authentication mode="Windows" />
    <authorization>
      <deny users="?" />
    </authorization>

2 2

On the real web server, in IIS version 7, I open my MVC web site application node and head to its Authentication node to enable Windows Authentication, and disable Anonymous Authentication. 在真实的Web服务器上,在IIS版本7中,我打开MVC网站应用程序节点并转到其“身份验证”节点以启用Windows身份验证,并禁用“匿名身份验证”。

Take a look at Securing your ASP.NET MVC 4 App and the new AllowAnonymous Attribute . 看一下保护ASP.NET MVC 4 App和新的AllowAnonymous Attribute的安全

You cannot use routing or web.config files to secure your MVC application (Any Version). 您不能使用路由或web.config文件保护MVC应用程序(任何版本)的安全。 The only supported way to secure your MVC application is to apply the Authorize attribute ... 保护MVC应用程序安全的唯一受支持方法是应用Authorize属性

Quote 引用

MVC uses routes and does not map URLs to physical file locations like WebForms, PHP and traditional web servers. MVC使用路由,并且不会将URL映射到物理文件位置,例如WebForms,PHP和传统的Web服务器。 Therefore using web.config will definitely open a security hole in your site. 因此,使用web.config肯定会在您的站点中打开一个安全漏洞。

The product team will have a communication if this changes in the future, but for now it is without exception the rule. 如果将来这种情况发生变化,产品团队将与您进行沟通,但现在毫无例外,这是规则。

Examples: 例子:

Start with the default ASP.Net MVC project (internet/intranet). 从默认的ASP.Net MVC项目(互联网/内联网)开始。

Edit the web.config adding: 编辑web.config并添加:

<location path="Home">
  <system.web>
    <authoirzation>
      <deny users="*">
    </authoirzation>
  </system.web>
</location>

Run the project, by default you will use the Default route /Home/Index and you see content, simply bypassing the web.config with no changes to the default template. 运行项目,默认情况下,您将使用默认路由/Home/Index并看到内容,只需绕过web.config而不更改默认模板即可。 Why? 为什么? Because the ASP.Net pipeline is comparing the URL requested to the location specified in the web.config. 因为ASP.Net管道正在将请求的URL与web.config中指定的位置进行比较。 However, after the Authorization Event has been executed in the pipeline the routing taking place (Default routing or custom routing) and allows access to the supposedly restricted area. 但是, 管道中执行了“授权事件” ,将进行路由(默认路由或自定义路由),并允许访问所谓的受限区域。

Additionally, any MVC Redirect() will also by-pass the same security measures as again the routing takes place after the Authorization Pipeline Event. 此外,任何MVC Redirect()也将绕过相同的安全措施,就像在授权管道事件之后再次进行路由一样。

You need to add the site to your local intranet zone. 您需要将站点添加到本地Intranet区域。 We do this via group policy. 我们通过组策略来做到这一点。

See How to enable Auto Logon User Authentication for Google Chrome 请参阅如何为Google Chrome启用自动登录用户身份验证

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM