没有 .NET 的 Windows 身份验证标头。可能的?
我想知道是否有人知道一种无需托管在 ASP 站点上即可使用 Windows 身份验证的方法。这是一个可以访问 LDAP 的 Intranet,所以我想知道是否有办法强制客户端向我提供数据,就像数据来自 ASP 站点一样。我只需要登录域和用户名,我就可以从那里运行。在 Ubuntu 上使用 Node.js。有人有这方面的经验吗?
I was wondering if anyone knew of a way to use Windows Authentication without hosting on an ASP site. It's an intranet w/ access to LDAP, so I'm wondering if there's a way to force the client to provide me the data as if it was coming from an ASP site. I just need the login domain and username and I can run from there. Using Node.js on Ubuntu. Anyone have any experience with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以在 Apache 中使用 NTLM 模块,也可以在 IIS 下设置一个脚本来捕获登录信息并将其 POST 到您的 node.js 站点。
You can use an NTLM module in Apache, or you can setup a script under IIS to capture the login information and POST it over to your node.js site.
如果您使用的是 Ubuntu,请执行
sudo apt-get ntlmaps
或下载“ntlmaps-xx-xx.deb”并配置您的代理,该代理会询问您的域名、用户名和密码。
然后运行 ntlmaps 作为您的代理。 Ntlmaps 将使用您的用户名和密码进行身份验证。您编写的任何程序 ntlmaps 都会使用您给定的配置详细信息自动验证您的程序。然而,安装 ntlmaps 后还需要配置一些东西。首先让我知道这是否是您正在寻找的东西?
If you are using Ubuntu, do a
sudo apt-get ntlmaps
or download 'ntlmaps-xx-xx.deb'and configure your proxy which would ask you for your domain, username and password.
Then run ntlmaps as your proxy. Ntlmaps will authenticate using your username and password. You write any program ntlmaps will authenticate your program automatically using your given configuration details. However there are few things you need to configure as well after installing ntlmaps. First let me know if is this something you are looking for?
更新:现在有实现 Windows 集成身份验证的模块 。
在
401
响应中,您需要提供值为NTLM
的WWW-Authenticate
标头,该标头通知浏览器需要发送 Windows证书。然后您就可以享受实施 NTLM 身份验证的乐趣了。引用这篇关于NTLM身份验证协议的文档:
客户端请求受保护的资源来自服务器:
服务器响应
401
状态,表明客户端必须进行身份验证。NTLM
通过WWW-Authenticate
标头呈现为受支持的身份验证机制。通常,服务器此时关闭连接:请注意,如果 NTLM 是第一个提供的机制,Internet Explorer 将仅选择它;这与 RFC 2616 不一致,RFC 2616 规定客户端必须选择支持的最强身份验证方案。
客户端使用包含 类型 1 的
Authorization
标头重新提交请求消息参数。类型 1 消息采用 Base-64 编码进行传输。从此时起,连接将保持打开状态;关闭连接需要重新验证后续请求。这意味着服务器和客户端必须通过 HTTP 1.0 样式的“Keep-Alive”标头或 HTTP 1.1(默认情况下使用持久连接)支持持久连接。相关请求头如下所示:服务器回复
401
状态,其中包含 WWW-Authenticate 标头中的“noreferrer">类型 2 消息(同样采用 Base-64 编码)。如下所示。客户端通过重新提交带有包含 Base-64 编码 类型 3 消息:
最后,服务器验证客户端 Type 3 消息中的响应并允许访问资源。
<预><代码> HTTP/1.1 200 确定
获取用户的用户名应该很容易——它在 Type 3 消息中以纯文本形式发送。实际上验证他们是否提供了正确的密码完全是另一回事。实现所有这些都作为读者的练习。
Update: There's now a module that implements Windows-integrated authentication.
In your
401
response, you need to provide aWWW-Authenticate
header with a value ofNTLM
, which informs browsers that they need to send Windows credentials.You then have the fun of implementing NTLM authentication. Quoting from this document about the NTLM authentication protocol:
The client requests a protected resource from the server:
The server responds with a
401
status, indicating that the client must authenticate.NTLM
is presented as a supported authentication mechanism via theWWW-Authenticate
header. Typically, the server closes the connection at this time:Note that Internet Explorer will only select NTLM if it is the first mechanism offered; this is at odds with RFC 2616, which states that the client must select the strongest supported authentication scheme.
The client resubmits the request with an
Authorization
header containing a Type 1 message parameter. The Type 1 message is Base-64 encoded for transmission. From this point forward, the connection is kept open; closing the connection requires reauthentication of subsequent requests. This implies that the server and client must support persistent connections, via either the HTTP 1.0-style "Keep-Alive" header or HTTP 1.1 (in which persistent connections are employed by default). The relevant request headers appear as follows:The server replies with a
401
status containing a Type 2 message in theWWW-Authenticate
header (again, Base-64 encoded). This is shown below.The client responds to the Type 2 message by resubmitting the request with an
Authorization
header containing a Base-64 encoded Type 3 message:Finally, the server validates the responses in the client's Type 3 message and allows access to the resource.
It should be easy enough to get the user's username – it's sent as plain text in the Type 3 message. Actually validating that they've supplied the correct password is another matter entirely. Implementing all of this is left as an exercise for the reader.
尝试 Apache mod_ntlm 或 mod_auth_ntlm_winbind。
在Ubuntu中:
Try Apache mod_ntlm or mod_auth_ntlm_winbind.
In Ubuntu: