简体   繁体   English

表单身份验证是否完全必要

[英]Is Forms Authentication totally necessary?

I'm writing an internal web application right now (with ASP.Net Web Forms), and it presents an odd problem. 我现在正在编写一个内部Web应用程序(使用ASP.Net Web Forms),这是一个奇怪的问题。 I have to be able to impersonate the currently logged in windows user, and execute a command based on their Windows Authentication to log in.. AND ... if they don't have Windows Authentication set up in the application I have to use to log them in, I have to be able to accept a user name and password. 我必须能够模拟当前登录的Windows用户,并根据他们的Windows身份验证执行命令登录..并且...如果他们没有在我必须使用的应用程序中设置Windows身份验证登录,我必须能够接受用户名和密码。 I also have to write the application in .Net 4.0, and secure it as much as possible. 我还必须在.Net 4.0中编写应用程序,并尽可能地保护它。 I got this to work by NOT utilizing Windows Authentication or Forms Authentication in the web.config, and instead setting session variables to guard against user accessing pages in the web app other that the log in. I did this by creating an oddly name session variable with a value based on their user name (windows auth or not), and then a secret session variable. 我通过在web.config中不使用Windows身份验证或表单身份验证来实现这一点,而是设置会话变量以防止用户访问Web应用程序中的其他登录页面。我通过创建奇怪的名称会话变量来实现此目的使用基于用户名的值(windows auth或不是),然后是一个秘密会话变量。 The secret variable is in the web.config as a 256bit encrypted string, in which I decrypt, and set as the session secret. 秘密变量在web.config中作为256位加密字符串,我在其中解密,并设置为会话密钥。 In order for the page to load, the first session variable can't be blank, and the second variable has to equal the decrypted key value... if the variables don't pass inspection, it redirects them to the login page. 为了加载页面,第一个会话变量不能为空,第二个变量必须等于解密的键值...如果变量没有通过检查,它会将它们重定向到登录页面。 I set this up on every page, generic handler, and webservice method in the web app. 我在Web应用程序中的每个页面,通用处理程序和webservice方法上进行了设置。 I make the session timeout after a few minutes of no activity, and on log out, I set all session variables to nothing, and expire all cookies. 我在没有活动几分钟后使会话超时,并且在注销时,我将所有会话变量设置为空,并使所有cookie失效。 (I also disable all cache). (我也禁用所有缓存)。

My question is... Does this offer comparable security to that of Forms authentication? 我的问题是......这是否提供与Forms身份验证相当的安全性? I have always used Forms authentication, but can't use it here. 我一直使用Forms身份验证,但不能在这里使用它。 If I did, the users would have to reconfigure settings in IIS and in he web.config to toggle login procedures (From my knowledge, you can't use both Forms authentication, and windows authentication to manage the security of your pages and other web resources). 如果我这样做,用户将不得不在IIS和web.config中重新配置设置以切换登录过程(据我所知,您不能同时使用Forms身份验证和Windows身份验证来管理页面和其他Web的安全性资源)。 With the method described above, I can accomplish the best of both worlds, but am curious about the security of my methods. 通过上述方法,我可以实现两全其美,但我很好奇我的方法的安全性。 Is there anything else I can implement here to assure the utmost security other that using forms authentication? 还有什么我可以在这里实现,以确保使用表单身份验证的最大安全性? Is it possible to accomplish the same level of security of Forms authentication without using it? 是否可以在不使用Forms身份验证的情况下实现相同级别的安全性?

Thank you for any insight in advance! 感谢您提前了解任何见解!

Does this offer comparable security to that of Forms authentication? 这是否提供与Forms身份验证相当的安全性?

No 没有

The first rule when it comes to security is don't reinvent the wheel unless you absolutely have to. 关于安全性的第一条规则是不要重新发明轮子,除非你绝对必须这样做。 Any home baked solution you come up with has the potential to be as secure as a provided one like Windows or Forms Authentication. 您提出的任何家庭烘焙解决方案都有可能像Windows或Forms身份验证一样安全。 The problem is that home-grown solutions rarely reach that potential. 问题是本土解决方案很少能达到这种潜力。 They may test okay, but subtle bugs can remain. 他们可能会测试好,但可以保留微妙的错误。 You don't want to find out a year later that you were hacked six months ago. 你不想在一年后发现六个月前你被黑了。 Existing solutions have already been tested and used in millions of applications, whereas yours will be used in one application and tested by a handful of people at most. 现有的解决方案已经在数百万个应用程序中进行了测试和使用,而您的解决方案将在一个应用程序中使用,并且最多只能由少数人进行测试。

A quick search suggests that it is possible to implement both Windows and Forms Authentication in the same application, so I'd pursue it further. 快速搜索表明可以在同一个应用程序中实现Windows和Forms身份验证,因此我会进一步追求它。

Mixing Forms and Windows Security in ASP.NET 在ASP.NET中混合表单和Windows安全性

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

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