2014-12-02 5 views
4

인증 용 OWIN 미들웨어가 있습니다. 두 가지 유형의 인증이 있습니다. 사용자 로그 아웃, 우리는 실제로 두 개의 로그 아웃OWIN 인증, 현재 토큰 만료 및 쿠키 제거

Request.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ExternalCookie); 

을 실행하면 첫 번째 유형은 외부 로그인

app.UseCookieAuthentication(new CookieAuthenticationOptions 
{ 
    AuthenticationType = DefaultAuthenticationTypes.ExternalCookie, 
    AuthenticationMode = Microsoft.Owin.Security.AuthenticationMode.Passive, 
    CookieHttpOnly = true, 
    CookieSecure = CookieSecureOption.SameAsRequest, 
    CookieName = ".AspNet." + DefaultAuthenticationTypes.ExternalCookie, 
    ExpireTimeSpan = TimeSpan.FromMinutes(5), 
    TicketDataFormat = new SecureTokenFormatter(GetMachineKey()) 
}); 

에 대한 다음과 같은 구성

var OAuthOptions = new OAuthAuthorizationServerOptions 
    { 
     AuthenticationType = DefaultAuthenticationTypes.ExternalBearer, 
     TokenEndpointPath = new PathString("/Token"), 
     Provider = new ApplicationOAuthProvider(PublicClientId), 
     AccessTokenExpireTimeSpan = TimeSpan.FromDays(14), 
     AllowInsecureHttp = true, 
     AccessTokenFormat = new SecureTokenFormatter(GetMachineKey()) 
    }; 

그리고 두 번째 유형 사용 인증 쿠키를 사용하여 베어러 토큰 및

Request.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ExternalBearer); 

처음에는 브라우저에서 .AspNet.ExternalCookie 쿠키가 삭제 될 것으로 예상됩니다. 둘째로, 내 토큰을 무효화하고 User.Current.Identity = null을 기대하고 있습니다. 그렇지 않습니다.

어떻게 할 수 있습니까? 1) 현재 세션의 현재 ID를 물리적으로 로그 아웃 하시겠습니까? 2) 브라우저에서 외부 쿠키를 제거 하시겠습니까?

+0

나는 같은 문제를 해결 : Request.GetOwinContext(). Authentication.SignOut (DefaultAuthenticationTypes.ApplicationCookie); FederatedAuthentication.SessionAuthenticationModule.SignOut(); – Alex

답변

0

나는 당신이 가지고 있던 동일한 문제점을 가지고 있었고, 3 일간의 검색 후에 나는 asnwer (일종의 ...)를 발견했다.

로그 아웃 할 때이 코드 줄 중 하나만 사용하십시오. (오른쪽, 그들 모두가 나를 위해 일하지만, 내가 첫 번째를 사용하고 있지만, 더 많은 예제 더 나은 ??)

Request.GetOwinContext().Authentication.SignOut(); 

Request.GetOwinContext().Authentication.SignOut(Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ApplicationCookie); 

HttpContext.Current.GetOwinContext().Authentication.SignOut(Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ApplicationCookie); 

가 문제가 아니라이 문서에 설명되어 있지만, 그것은을 제공하지 않습니다 작업 수정 (적어도 나를 위해 않았다) http://coding.abel.nu/2014/11/catching-the-system-webowin-cookie-monster/