简体   繁体   中英

How to Authorize SignalR Hub Connection using Cookie?

I am very new to SignalR and I am trying to authorize connections to the SignalR Hub using Cookie.

Below is the code for my Hub Class;

[Authorize]
public class MyHub : Hub
{
    ....
}

and I've below code in the Application_Start

RouteTable.Routes.MapHubs();
GlobalHost.HubPipeline.RequireAuthentication();

Where am I supposed to do the Authorization process? Is there any specific event for this? Or AuthorizeRequest method which I can override?

Use the FormsAuthentication.SetAuthCookie

http://msdn.microsoft.com/en-us/library/twk5762b.aspx

edit: Sorry I read, Authenticate but you ment Authorize. YOu can decorate the Hub methods with the PrincipalPermision attribute to Authorize the hub and its methods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM