在SignalR集线器中传递userId [英] passing userId in Hub of SignalR

查看:79
本文介绍了在SignalR集线器中传递userId的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候..!,我要使用SignalR创建一个asp.net聊天webApplication,以便跟踪每个用户并在其中存储操作.我使用userId来跟踪它们.我的问题是我不想将客户端表单中的机密数据(例如userId)传递给signalR集线器.我知道SignalR集线器类不支持会话.所以我该怎么做.

Greeting..!, I am making a asp.net chat webApplication using SignalR were I want to keep track of every user and store there actions is database. I use userId to keep track of them. My problem is that I don't want to pass confidential data(like userId) from client form to signalR hub.And I know SignalR hub class does not support sessions. so how can I do that.

我是SignalR的新手,我在Google上搜索了很多有关此问题的内容,但找不到任何简单的答案.

I am new to signalR and I googled a lot about this problem but couldn't find any simple answer.

推荐答案

SignalR支持不同的身份验证和授权方式:

SignalR supports different ways to authenticate and authorize users:

  • 饼干
  • Windows身份验证
  • 证书
  • 连接头

您可以在此处找到有关SignalR和安全性的更多信息:

You can find more information about SignalR and security here:

http://www.asp.net/信号器/概述/signalr-20/安全性/安全性介绍

请记住,即使可能传输了某些信息,但通常存在一种抽象,它实际上并不能真正使某人将用户映射到令牌,反之亦然,而不是服务器之外的任何事物.

Keep in mind that even though some info might be transferred, there is often an abstraction that does not really let someone map a user to a token or vice versa on anything else than the server.

身份验证和授权只是安全性的一小部分,通过使用SSL并仔细考虑您已经说过的内容来进行传输,等等.

Authentication and authorization is only a small part of security which goes further by using SSL and to carefully think what you transmit as you already said., etc.

但是在某些时候,您需要服务器端应用程序和调用者之间的相关信息之间的链接.这可能是cookie经过经典的基于表单的身份验证,基于散列的标头或您要创建的任何内容之后由cookie标识的会话.SignalR非常灵活,因此您可以考虑针对不同的系统进行身份验证之类的事情,并且仅传递委派令牌.

But on some point you need a link between relevant information on your server side application and the caller. This might be a session identified by the cookie after a classic forms based authentication, an hash based header or whatever you want to create. SignalR is flexible so you could think about something like authentication against a different system and pass only a delegation token.

这篇关于在SignalR集线器中传递userId的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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