Note that there are some explanatory texts on larger screens.

plurals
  1. PONancy and SignalR Authentication
    primarykey
    data
    text
    <p>I think I am missing something here because this shouldn't be this difficult.</p> <p>I have a nancy IIS hosted application that uses authentication which works (Sets a cookie _nca). Then I have a signalR hub that needs to get the username of the logged in person so I can then pull the "Group" that the user belongs to.</p> <p>I thought I would just grab the username from Context.User.Identity.Name but that is empty and the hub appears to think I am not authorized. I am guessing that there is something else I need to do to tell signalR how to authenticate.</p> <p>I thought that maybe setting HttpContext.Current.User would help but that apparently didn't do anything either.</p> <p>I did this by the following</p> <pre><code> protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) { base.ApplicationStartup(container, pipelines); pipelines.AfterRequest.AddItemToStartOfPipeline(SetUpContext); //pipelines.AfterRequest.AddItemToEndOfPipeline(SetUpContext); CookieBasedSessions.Enable(pipelines); RouteTable.Routes.MapHubs(); } private void SetUpContext(NancyContext ctx) { if (ctx.CurrentUser == null) return; string[] Roles = { "Recipient" }; var userIdent = new UserIdent(); userIdent.IsAuthenticated = true; userIdent.Name = ctx.CurrentUser.UserName; GenericPrincipal principal = new GenericPrincipal(userIdent, Roles); IPrincipal Identity = (IPrincipal)principal; HttpContext.Current.User = Identity; } </code></pre> <p>I also tried pipelines.BeforeRequest.AddItemToEndOfPipeline. Still not having any luck.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload