2017-03-14 1 views
0

로그인 기능과 별도의 MVCClient를 처리하는 IndentityServer4 프로젝트가 있지만 MVC 클라이언트의 로그 아웃 기능이 필요하지만 이름을 보면이 MVC 클라이언트가 있습니다.IdentityServer4 올바른 로그 아웃 처리

[HttpPost] 
    [ValidateAntiForgeryToken] 
    [AllowAnonymous] 
    public async Task<IActionResult> Logout(LogoutViewModel model) 
    { 
     var vm = await _account.BuildLoggedOutViewModelAsync(model.LogoutId); 
     if (vm.TriggerExternalSignout) 
     { 
      string url = Url.Action("Logout", new { logoutId = vm.LogoutId }); 
      try 
      { 
       // hack: try/catch to handle social providers that throw 
       await HttpContext.Authentication.SignOutAsync(vm.ExternalAuthenticationScheme, 
        new AuthenticationProperties { RedirectUri = url }); 
      } 
      catch (NotSupportedException) // this is for the external providers that don't have signout 
      { 
      } 
      catch (InvalidOperationException) // this is for Windows/Negotiate 
      { 
      } 
     } 

     // delete authentication cookie 
     await _signInManager.SignOutAsync(); 

     return View("LoggedOut", vm); 
    } 

사람이 정말 클라이언트에서 필요한 것을 논리를 설명 할 수 :

public async Task Logout() 
    { 
     await HttpContext.Authentication.SignOutAsync("Cookies"); 
     await HttpContext.Authentication.SignOutAsync("oidc"); 
    } 

하지만 identityserver4 프로젝트 훨씬 더 할 것 같다 더 복잡한 로그 아웃이 있습니다.

답변

1

첫 번째 로그 아웃 방법은 MVC 클라이언트에서 사용됩니다. 두 번째 코드는 IdentityServer 서비스에 속합니다.

첫 번째 로그 아웃은 로그 아웃 프로세스의 일부 상태를 초기화하고 IdentityServer의 로그 아웃보기로 리디렉션합니다 (샘플을 보면 IdentityServer AccountController 코드에 두 개의 로그 아웃이 있습니다 : 하나는 로그 아웃 확인보기 용이고 다른 하나는 POST 핸들러) .

+0

https://github.com/IdentityServer/IdentityServer4.Demo/blob/master/src/IdentityServer4Demo/Quickstart/Account/AccountController.cs –

관련 문제