简体   繁体   English

通过Web请求C ++ / Node.js进行Windows身份验证

[英]Windows Authentication via Web Request C++ / Node.js

Problem I want to be able to use Windows Authentication with Node.js. 问题我希望能够使用Node.js进行Windows身份验证。

I understand that IIS handles Windows Authentication in ASP.NET, however what I can't figure out is, how I can get at the current Client Windows username from node.js. 我知道IIS在ASP.NET中处理Windows身份验证,但我无法弄清楚的是,我如何从node.js获取当前的客户端Windows用户名。 I get that it's not running via IIS (and don't really want to go down the IISNode route). 我知道它不是通过IIS运行(并且真的不想沿着IISNode路线运行)。

There must be a way of getting at the Client's windows username via Node.js - even if I have to write a C++ library / service. 必须有一种方法通过Node.js获取客户端的Windows用户名 - 即使我必须编写C ++库/服务。

Initial thoughts were that I'd be able to setup a web service within ASP.NET, which would use Windows authentication, and allow me to use a web request to get that user - but this is perhaps too naive! 最初的想法是,我可以在ASP.NET中设置一个Web服务,它将使用Windows身份验证,并允许我使用Web请求来获取该用户 - 但这可能太天真了!

I don't want to ask the user for their username and password - as this misses the point. 我不想向用户询问他们的用户名和密码 - 因为这没有注意到这一点。

Any ideas, thoughts, or places I can look? 我能看到的任何想法,想法或地点? Or is this just not possible? 或者这是不可能的?

Note: This is within a closed Intranet, and Windows Authentication is used within our ASP.NET applications along with Active Directory. 注意:这是在一个封闭的Intranet中,Windows身份验证在我们的ASP.NET应用程序中与Active Directory一起使用。

Approach 途径

Unless I miss some of the requirements, you should be able to setup a IIS web site to relay requests to your Node.js application so that 除非我错过了一些要求,否则您应该能够设置IIS网站以将请求转发到Node.js应用程序,以便

  • A client browser will authenticate against your IIS site; 客户端浏览器将针对您的IIS站点进行身份验证;
  • The IIS site will forward the authenticated request to the Node.js app and back to client. IIS站点将经过身份验证的请求转发到Node.js应用程序并返回给客户端。

Make sure to disable anonymous access and only use IWA for the IIS site. 确保禁用匿名访问,并仅将IIS用于IIS站点。

Please see Relaying a request in ASP.NET for a couple of examples of how to relay requests in ASP.NET with C# or VB. 有关如何使用C#或VB在ASP.NET中中继请求的几个示例,请参阅在ASP.NET中中继请求。 You would also need to pass the user name with a header or a GET/POST parameter: 您还需要使用标头或GET / POST参数传递用户名:

Response.AppendHeader("CustomUserNameHeader", Page.User.Identity.Name);

Assumptions 假设

  • The Node.js app needs to know the name of the user logged in on the client computer. Node.js应用程序需要知道在客户端计算机上登录的用户的名称。
  • It's possible to make the Node.js app accessible only from the IIS site, otherwise, the solution is completely insecure. 可以只从IIS站点访问Node.js应用程序,否则,解决方案是完全不安全的。

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

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