0
我試圖通過SignOut刪除它,但它不會被刪除或過期。如何刪除Owin Token?
var authentication = HttpContext.Current.GetOwinContext().Authentication;
authentication.SignOut(Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ApplicationCookie,
Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ExternalCookie,
Microsoft.AspNet.Identity.DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie,
Microsoft.AspNet.Identity.DefaultAuthenticationTypes.TwoFactorCookie);
authentication.SignOut(Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ExternalCookie);
authentication.SignOut(Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ApplicationCookie);
authentication.SignOut();
我試圖找到許多博客(MSDN,堆棧溢出等)的解決方案,但還沒有看到解決方案。
我通過生成令牌:
// Set claim
var identityType = new GenericIdentity(userName, Config.Constants.BASICIDENTITYTYPE);
string[] roles = null;
var principal = new GenericPrincipal(identityType, roles);
Thread.CurrentPrincipal = principal;
if (HttpContext.Current != null)
{
HttpContext.Current.User = principal;
}
var identity = new ClaimsIdentity(StartUp.OAuthBearerOptions.AuthenticationType);
identity.AddClaim(new Claim(ClaimTypes.Name, userName));
identity.AddClaim(new Claim(Config.Constants.USERNAME, userName));
identity.AddClaim(new Claim(Config.Constants.USERID, userId.ToString()))
// Generate ticket
AuthenticationTicket ticket = new AuthenticationTicket(identity, new AuthenticationProperties());
var currentUtc = new SystemClock().UtcNow;
ticket.Properties.IssuedUtc = currentUtc;
TimeSpan expiryTime = Constants.TOKEN_EXPIRY_TIME_SECOND);
ticket.Properties.ExpiresUtc = currentUtc.Add(expiryTime);
return StartUp.OAuthBearerOptions.AccessTokenFormat.Protect(ticket);
'Owin Token'是什麼意思?會話Cookie? –
@Brent Schmaltz我要刪除或過期Owin Token。 –
你的startup.cs是什麼樣的? –