node.js - 使用 iisnode 和 WebMatrix 的 Windows 身份验证问题

标签 node.js windows-authentication webmatrix iis-express iisnode

我尝试使用 IIS Express 7.5 上托管的 node.js(通过 WebMatrix)编写一个简单的网站。 我想使用集成 Windows 身份验证。

我按照一些类似帖子中的描述配置了applicationhost.config。我还配置了 web.config

<system.webServer>
    <security>
        <authentication>
            <anonymousAuthentication enabled="false" />
            <basicAuthentication enabled="false" />
            <windowsAuthentication enabled="true" />
        </authentication>
    </security>
</system.webServer>

现在,当请求该网站时,它会要求提供凭据。目前来说这已经很好了。然后我提供了正确的域凭据并收到错误 401.1

嗯,受信任区域中的站点和 Fidler 表示提供了 Kerberos 票证。

出了什么问题?

我检查了跟踪并收到以下错误:

<EventData>
  <Data Name="ContextId">{00000000-0000-0000-3F03-0080000000F8}</Data>
  <Data Name="ModuleName">WindowsAuthenticationModule</Data>
  <Data Name="Notification">2</Data>
  <Data Name="HttpStatus">401</Data>
  <Data Name="HttpReason">Unauthorized</Data>
  <Data Name="HttpSubStatus">1</Data>
  <Data Name="ErrorCode">2147942485</Data>
  <Data Name="ConfigExceptionInfo"></Data>
</EventData>
<RenderingInfo Culture="en-US">
<Opcode>MODULE_SET_RESPONSE_ERROR_STATUS</Opcode>
<Keywords>
  <Keyword>RequestNotifications</Keyword>
</Keywords>
<freb:Description Data="Notification">AUTHENTICATE_REQUEST</freb:Description>
<freb:Description Data="ErrorCode">The local device name is already in use. (0x80070055)</freb:Description>
</RenderingInfo>

好吧,然后我花了几个小时试图找出问题,结果发现如果从 web.config 中删除规则或 URL 重写模块

    <rewrite>
        <rules>
            <!-- Don't interfere with requests for logs -->
            <rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true">
                <match url="^[a-zA-Z0-9_\-]+\.js\.logs\/\d+\.txt$" />
            </rule>

            <!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
            <rule name="StaticContent">
                <action type="Rewrite" url="public{REQUEST_URI}" />
            </rule>

            <!-- All other URLs are mapped to the Node.js application entry point -->
            <rule name="DynamicContent">
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                </conditions>
                <action type="Rewrite" url="app.js" />
            </rule>
        </rules>
    </rewrite>

然后一切都会很好(除了app.js的正确处理)

那么,问题是如何保留 WebMatrix 的原始 Node.js 模板并使用 Windows 身份验证而不会出现此类错误?

还有一个问题是如何获取 Node.js 中 IIS 模块管道收集的所有上下文信息?

最佳答案

从iisnode v0.1.13开始,IIS管道收集的信息不会暴露给node.js应用程序。这是一个已知的限制,将通过 https://github.com/tjanczuk/iisnode/issues/87 解决。和 https://github.com/tjanczuk/iisnode/issues/94

需要调查使用重写规则时的身份验证问题;创建https://github.com/tjanczuk/iisnode/issues/127

关于node.js - 使用 iisnode 和 WebMatrix 的 Windows 身份验证问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8588320/

相关文章:

c# - 通过 ASP.NET 访问 Active Directory 记录

c# - 取消记住远程调试器凭据

SQL Server Management Studio 2008 Runas 用户在不同的域上通过 VPN

c# - 当前上下文中不存在名称 'Database'?

c# - 如何在 WebMatrix C# 中声明充当整数或 bool 值的(全局?)变量

session - Webmatrix、Razor 和 session

sql - 将 SQL 查询结果作为 Node.js 中的变量返回

javascript - 在单独的函数中调用 passport.authenticate 不起作用

linux - Node 服务器错误时 "node index.js"(EADDRINUSE)

node.js - 在哪里建立 Mongoose 连接/任何数据库连接