允许任何用户访问 'signalr/hubs' 而无需凭据,使用 cors(服务器运行 windows 身份验证)
Allow any user to access 'signalr/hubs' without credentials, using cors (server runs windows authentication)
我有两台服务器
- SignalR 主机(windows 身份验证、IIS)
- 其余网页主机(表单认证、IIS)
我已经全部设置好了,它可以在 Chrome 中使用长轮询。 (1) 在使用 Firefox 并导航到 https://localhost:44301/signalr/hubs
时要求输入用户名和密码。
(1) 使用 windows 身份验证。我试图通过在 web.config
中执行以下操作来避免身份验证:
<location path="signalr">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
但是SignalR不是路径,因为它是自动生成的。
我也曾尝试这样做以暴露集线器,但无济于事:
<location path="~/Hubs">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
谁能帮我找到从 https://localhost:12321/signalr/* 中删除身份验证的方法? (这也包括所有 signalr/negotiate 调用 ++)
尝试
<allow users="?"/>
因为它允许匿名,星号“*”允许 "All users"。
我通过改变问题的前提解决了这个问题。
现在整个服务器都可以匿名访问,但是需要windows身份验证的路径已经自己指定了。
需要保护的控制器的示例:
<location path="#####.ashx">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="false"/>
<windowsAuthentication enabled="true"/>
</authentication>
<authorization>
<remove users="?" roles="" verbs="" />
<add accessType="Deny" users="?" />
</authorization>
</security>
</system.webServer>
< /location>
以及服务器的常规设置:
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="true"/>
<windowsAuthentication enabled="true"/>
</authentication>
<authorization>
<add accessType="Allow" users="?" />
</authorization>
<requestFiltering>
<!--Auction searches with 250 results generates slightly longer string than standard setting of 2048-->
<requestLimits maxQueryString="3072" />
</requestFiltering>
</security>
</system.webServer>
这可能不是对每个人都可行的解决方案,但它对我有用...:)
顺便说一句:在使用此工具时,我还与 IIS Express 进行了斗争,并且能够在 web.config 中设置 windows 身份验证。这个 post 对我帮助很大 -> IIS Express Windows Authentication
我有两台服务器
- SignalR 主机(windows 身份验证、IIS)
- 其余网页主机(表单认证、IIS)
我已经全部设置好了,它可以在 Chrome 中使用长轮询。 (1) 在使用 Firefox 并导航到 https://localhost:44301/signalr/hubs
时要求输入用户名和密码。
(1) 使用 windows 身份验证。我试图通过在 web.config
中执行以下操作来避免身份验证:
<location path="signalr">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
但是SignalR不是路径,因为它是自动生成的。 我也曾尝试这样做以暴露集线器,但无济于事:
<location path="~/Hubs">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
谁能帮我找到从 https://localhost:12321/signalr/* 中删除身份验证的方法? (这也包括所有 signalr/negotiate 调用 ++)
尝试
<allow users="?"/>
因为它允许匿名,星号“*”允许 "All users"。
我通过改变问题的前提解决了这个问题。
现在整个服务器都可以匿名访问,但是需要windows身份验证的路径已经自己指定了。
需要保护的控制器的示例:
<location path="#####.ashx">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="false"/>
<windowsAuthentication enabled="true"/>
</authentication>
<authorization>
<remove users="?" roles="" verbs="" />
<add accessType="Deny" users="?" />
</authorization>
</security>
</system.webServer>
< /location>
以及服务器的常规设置:
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="true"/>
<windowsAuthentication enabled="true"/>
</authentication>
<authorization>
<add accessType="Allow" users="?" />
</authorization>
<requestFiltering>
<!--Auction searches with 250 results generates slightly longer string than standard setting of 2048-->
<requestLimits maxQueryString="3072" />
</requestFiltering>
</security>
</system.webServer>
这可能不是对每个人都可行的解决方案,但它对我有用...:)
顺便说一句:在使用此工具时,我还与 IIS Express 进行了斗争,并且能够在 web.config 中设置 windows 身份验证。这个 post 对我帮助很大 -> IIS Express Windows Authentication