I have an MVC5 web application using OWIN CookieAuthentication. When the user is successfully registered in the web application, the connection occurs with the SignalR hub running in the console application, also configured using OWIN CookieAuthentication.
At the start of SignalR, I specified GlobalHost.HubPipeline.RequireAuthentication (), because I want the HubCallerContext.User property to be humidified using ClaimsPrincipal sent from the web application. Checking the available cookies, I see that the auth cookie was received successfully, but I canβt understand how to configure the OWIN configuration so that the readonly main editor is selected from it.
I have seen related suggestions, such as the options below:
var cookieAuthenticationOptions = new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, AuthenticationMode = AuthenticationMode.Active, Provider = new CookieAuthenticationProvider { OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>( TimeSpan.FromSeconds(30), (manager, user) => manager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie)) } }; app.UseCookieAuthentication(cookieAuthenticationOptions);
But I canβt get them to have any effect, and in any case, it seems to include a lot of peripheral classes related to the Identity framework that need to be configured (which I have now ported from the MVC5 project template just for checking with). I just want to dampen the User property with claims encrypted in the ticket, and then look for the identified user in my SignalR system, but I find it necessary. How can I do it?
EDIT . As a workaround, I create a separate server cookie at the time I sign up for the user in the web application. I binary serialize ClaimsIdentity, encrypts that with AES, base 64 encodes this and puts it in a cookie. Then, in my Hub class, I have a User property on demand that reads this cookie and unpacks it. Not a perfect solution!