【发布时间】:2017-05-24 04:28:00
【问题描述】:
我有一个处理登录功能的 IndentityServer4 项目和一个单独的 MVCClient,我需要有一个来自 MVC 客户端的注销功能,但是查看相同的只是有这个(MVC 客户端):
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);
}
有人能解释一下客户端真正需要什么的逻辑吗?
【问题讨论】:
标签: asp.net-core identityserver4