2017-03-14 8 views
0

ログイン機能と別個のMVCClientを扱うIndentityServer4プロジェクトがありますが、MVCクライアントからのログアウト機能が必要ですが、これは単にMVCクライアントを持っている必要があります。IdentityServer4のログアウトを正しく処理する

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

が、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); 
    } 

誰かが実際にクライアント上で必要とされるもののロジックを説明することができます。

答えて

1

最初のログアウト方法は、MVCクライアントで使用されます。 2番目のコードはIdentityServerサービスに属します。

最初のログアウトは、ログアウトプロセスの状態を初期化し、IdentityServerのログアウトビューにリダイレクトします(サンプルを見ると、IdentityServer AccountControllerコードに2つのログアウトがあります:ログアウト検証ビュー用と1つのPOSTハンドラ用) 。

+0

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

関連する問題