You can declare a static property CookieAuthOptions
if you configured CookieAuthOptions
in ConfigureAuth or any other AuthOption should also implement ISecureDataFormat<AuthenticationTicket>
(eg: OAuthBearerOptions.AccessTokenFormat
). This one contains Protect
& Unprotect
methods.
Whenever you need to access AuthenticationProperties
, you have to be able to get a grip of Owin context to get a reference to a ticket that implements your correct format.
As a basic example steps,
Startup.cs => public static CookieAuthenticationOptions CookieAuthOptions;
Startup.cs => ConfigureAuth => CookieAuthOptions.CookieName = "xxx";
BaseController.cs => Startup.CookieAuthOptions.TicketDataFormat.Unprotect(Request.Cookies["xxx"].Value).Properties;
to get what you want.
PS: You did not mention where you need this and I assumed it would be in a controller.