c# - Is it possible to update the current IPrincipal without creating a new connection in SignalR 2.0.x? -
We use custom form authentication in MVC4. We create a FormsAuthenticationTicket with custom data (another authentication ticket for a backend sub-system) and store it in a cookie. This cookie is read and dectypted in Global.asax by the FormsAuthentication_OnAuthenticate method, from decrypted data, we create a custom i.purcted object that we set as the current user.
We also use a sliding termination plan for the ticket and if it is about to expire, then we create a new ticket and update the cookie and make a new custom IPCR object.
We have set the signal R to routinely ping the server, and the ticket is renenewd properly. The problem is that the update IPrincipal is never prompted (this is only set for the first time). Is it also possible or do we need to make a new connection to renew the ticket?
Protected Zero form etiquette_onnect (object sender, formAdministrationAventEurge E) {var authCookie = Request.Cookies [FormsAuthentication.FormsCookieName]; If return (authCookie == faucet); Var Ticket Manager = Dependency Resolver. Getswives (typef (iTicket Manager)) as iitat manager; Var Ticket = ticketManager.DecryptAndValidateTicket (authCookie.Value); Var newTicket = ticketManager.RefreshTicketIfNeeded (ticket); If (newTicket! = Null) {var cookie = ticketManager.CreateCookie (newTicket); E.Context.Response.Cookies.Add (cookie); Ticket = Nutcrack; } Var user = ticketManager.Authenticate (ticket); Thread.CurrentPrincipal = Users; HttpContext.Current.User = User; E. User = user; }
If you want to update the current IPrinith, you need to create a new connection Requires a signal R connection.
The reason for this is very simple: Signal R requests may end indefinitely.
Cookies are sent and authentication / authorization occurs at the beginning of a request. This also happens when the IPRinist is set. At least in the signalar, the IPRincile is stored on it.
I think that if you were referring to the requests of the active signal R for the given user, it may be possible to update the ipernist, but I think your best bet is if a new signal If the R connection has been established, then the IPrinist change
Comments
Post a Comment