我们如何美分的基于p $ pform OWIN承载的OAuth令牌身份验证和授权的SignalR? [英] How do we preform OWIN oAuth Bearer token based Authentication and Authorization in SignalR?

查看:507
本文介绍了我们如何美分的基于p $ pform OWIN承载的OAuth令牌身份验证和授权的SignalR?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用的是内置的OWIN的OAuth服务器的功能,生成承载令牌。我们有他们的ASP.NET Web API的工作,但不知道如何让他们与SignalR(和AngularJS javscript客户端)工作。我们如何使用承载令牌与SignalR进行身份验证和授权?我还没有看到关于如何实现这一目标的任何真正的好明确的答案。

We are using the built in OWIN oAuth server functionality to generate Bearer tokens. We have them working with ASP.NET Web API but not sure how to get them working with SignalR (and an AngularJS javscript client). How do we use Bearer tokens with SignalR for authentication and authorization? I have not seen any really good clear answers on how to achieve this.

先谢谢了。

推荐答案

不幸的是,JS的WebSocket API不会使它可以设置自定义标头。

Unfortunately, the JS WebSocket API does not make it possible to set custom headers.

然而,应该可以增加承载令牌到<一href=\"http://www.asp.net/signalr/overview/guide-to-the-api/hubs-api-guide-javascript-client#querystring\"相对=nofollow>所有SignalR的查询字符串请求其中包括WebSocket的请求。

However, it should be possible to add the bearer token to the query string of all SignalR requests which includes the WebSocket requests.

$.connection.hub.qs = { 'access_token' : accessToken };

一旦你这样做,你可以创建一个<一个href=\"http://stackoverflow.com/questions/20585872/get-iprincipal-from-oauth-bearer-token-in-owin\">custom OAuthBearerAuthenticationProvider从查询字符串拉令牌。

这篇关于我们如何美分的基于p $ pform OWIN承载的OAuth令牌身份验证和授权的SignalR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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