使用SignalR和OWIN自托管的Windows身份验证 [英] Windows authentication with SignalR and OWIN self-hosting

查看:104
本文介绍了使用SignalR和OWIN自托管的Windows身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用OWIN的自托管SignalR应用程序. 我想将Windows身份验证添加到传入的请求. 这可能吗?

I have a self-hosted SignalR application using OWIN. I would like to add Windows Authentication to the incoming requests. Is this possible?

我相信我可以添加例如通过这样的方式 .

I believe that I can add e.g. Forms Authentication via something like this.

但是我找不到任何使用Windows身份验证执行类似操作的方法.

However I can't find any way to use Windows Authentication to do something similar.

我的后备计划将改为在IIS中托管,但我希望能够将我的应用保留为Windows服务.

My fallback plan would be to host in IIS instead, but I would prefer to be able to keep my app as a Windows Service if I can.

推荐答案

理想情况下,有一个NTLM中间文件,但是既然没有,您可以通过在HttpListener上获取一个句柄并启用auth来解决(它是由HttpListener本地支持):

Ideally there'd be an NTLM owin middlware but since there is none you can work around it by getting a handle on the HttpListener and enabling auth that way (it's natively supported by HttpListener):

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        var listener = (HttpListener)app.Properties[typeof(HttpListener).FullName];
        listener.AuthenticationSchemes = AuthenticationSchemes.Ntlm;

        app.MapHubs();
    }
}

这篇关于使用SignalR和OWIN自托管的Windows身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆