使用SignalR和OWIN自托管的Windows身份验证
我有一个使用OWIN的自托管的使用SignalR和OWIN自托管的Windows身份验证,signalr,windows-authentication,owin,Signalr,Windows Authentication,Owin,我有一个使用OWIN的自托管的signal应用程序。 我想将Windows身份验证添加到传入的请求中。这可能吗 我相信我可以添加例如表单验证 但是,我找不到任何方法使用Windows身份验证来执行类似的操作 我的备用计划是在IIS中托管,但如果可以的话,我更希望能够将我的应用程序作为Windows服务保留。理想情况下,middlware中会有一个NTLM owin,但由于没有NTLM owin owin owin,因此您可以通过在HttpListener上获得句柄并以这种方式启用身份验证来解决它
signal
应用程序。
我想将Windows身份验证添加到传入的请求中。这可能吗
我相信我可以添加例如表单验证
但是,我找不到任何方法使用Windows身份验证来执行类似的操作
我的备用计划是在IIS中托管,但如果可以的话,我更希望能够将我的应用程序作为Windows服务保留。理想情况下,middlware中会有一个NTLM owin,但由于没有NTLM owin owin owin,因此您可以通过在HttpListener上获得句柄并以这种方式启用身份验证来解决它(HttpListener本机支持):
我面临着与您相同的问题,并决定实现一个NTLM/Windows身份验证中间件 您可以在Nuget上找到它:
Install-Package Pysco68.Owin.Authentication.Ntlm
有关如何使用它的来源和更详细的信息,请访问:
最小使用示例可能如下所示:
public void Configuration(IAppBuilder app)
{
// use default sign in with application cookies
app.SetDefaultSignInAsAuthenticationType(
DefaultAuthenticationTypes.ApplicationCookie);
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie
});
// Enable NTLM authentication
app.UseNtlmAuthentication();
// .....
}
请注意,出于性能原因,我最终决定坚持使用Cookie身份验证,并仅在初始身份验证往返过程中使用NTLM(因为请求数量很大)。谢谢!这看起来像是在耍花招。我现在遇到了另一个问题,启用NTLM auth后,我得到了一个
Access Control Allow Origin
错误。这看起来可能已经修复了,所以当我有时间测试它时,我需要尝试获取最新的SignalR版本。我假设您启用了跨域。读这篇文章是的,我想我已经做得很好了-如果我注释掉AuthenticationSchemes
行,它肯定会起作用。我提出了一个问题,因为感觉这是一个单独的问题。
public void Configuration(IAppBuilder app)
{
// use default sign in with application cookies
app.SetDefaultSignInAsAuthenticationType(
DefaultAuthenticationTypes.ApplicationCookie);
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie
});
// Enable NTLM authentication
app.UseNtlmAuthentication();
// .....
}