2
我有一个Azure WebRole(MVC应用程序)和Azure Worker角色。OWIN身份验证
现在,我使用Owin.SelfHost将我的SignalR中心托管在工作者角色中。
MVC应用程序需要在worker角色中调用这个集线器 - 这非常简单。
现在我的问题是身份验证。
我需要访问WebRole上的WebRole的Context.User.Identity,以便我仍然可以验证对集线器的呼叫。
Worker角色
public class MyHub: Hub
{
public override Task OnConnected() {
var id = Context.User.Identity.Name; // NULL
var connectionId = Context.ConnectionId;
}
[Authorize]
public void SendMessage() ....
}
目前 - IM坚持这一
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);
});
.....
});
}
不知怎的,我需要从我的WebRole通过User.Context(Asp.net同一性)Owin管道工作者角色。
任何想法如何做到这一点?
任何人谁可以帮助吗? – 2014-09-25 07:20:58
是在同一个域中的网站和信号员自己的主机?只需设置Cookie的路径,您就可以在它们之间共享Cookie。我没有列出答案,因为那里会有几条龙。 – 2014-09-25 15:08:10
是它位于同一个域中,网站位于端口80,使用IIS中托管的CookieAuthentication和ASP.NET Identity,而SignalR位于端口8088,OWIN自己托管在工作角色中。你可以给我指针如何在应用程序之间共享cookie? – 2014-09-25 23:33:17