Implementing Authorization in a Self Hosted SignalR Server accessed from Web -


i'm looking guidance on how implement authorization security signalr on end service running in self-hosted (non-iis) environment, called web application. backend app monitor fires signalr events html based client. works fine (amazingly actually).

however, need restrict access server authenticated users web site. if user authenticated on web site, need somehow pick crendentials (user name enough) , validation state in backend app decide whether allow connection avoid unauthorized access.

can point @ strategies or patterns on how accomplish sort of auth forwarding?

signalr not provide additional features authentication. instead, designed work authentication mechanism of application.

hubs

you should authentication , use authorize attribute provided signalr enforce results of authentication on hubs.

the authorize attribute can applied entire hub or particular methods in hub. examples:

  • [authorize] – authenticated users
  • [authorize(roles = "admin,manager")] – authenticated users in specified .net roles
  • [authorize(users = "user1,user2")] – authenticated users specified user names

you can require hubs require authentication adding following method in application_start method:

globalhost.hubpipeline.requireauthentication();

persistent connections

you can use user object in request see if user authenticated:

request.user.isauthenticated


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -