I have an Azure WebRole (MVC app) and Azure Worker role.
Now, I have my SignalR hubs hosted in the Worker Role using Owin.SelfHost.
The MVC app need to call this hubs in the worker role - which is quite straightforward.
Now my problem is authentication.
I need to access the WebRole's Context.User.Identity on the webrole so that I can still authenticate the calls to my hubs.
Worker Role
public class MyHub: Hub
{
public override Task OnConnected() {
var id = Context.User.Identity.Name; // NULL
var connectionId = Context.ConnectionId;
}
[Authorize]
public void SendMessage() ....
}
Currently - im stuck with this
public void Configuration(IAppBuilder app)
{
app.Map("/signalr", map =>
{
map.Run(async context =>
{
var userName = context.Request.Query["user"]; //NULL
var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationType);
identity.AddClaim(new Claim(ClaimTypes.Name, userName));
context.Authentication.SignIn(identity);
});
.....
});
}
Somehow, I need to pass the User.Context (Asp.net identity) from my WebRole to the Owin Pipeline in the worker role.
Any idea how to do that?