Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 从Identity Server 4注销赢得';无法从客户端注销_Angular_Security_.net Core_Identityserver4 - Fatal编程技术网

Angular 从Identity Server 4注销赢得';无法从客户端注销

Angular 从Identity Server 4注销赢得';无法从客户端注销,angular,security,.net-core,identityserver4,Angular,Security,.net Core,Identityserver4,我有一个类似的问题 我使用的是Asp Net标识和EF Core组合示例,一切都正常工作,数据库、种子、api调用,但我尝试从IS页面注销时除外。它不会删除保持用户登录客户端的.AspNetCore.Cookies [HttpPost] [ValidateAntiForgeryToken] 公共异步任务注销(LogoutInputModel) { //构建一个模型,以便注销页面知道要显示什么 var vm=await BuildLoggedOutViewModelAsync(model.Logo

我有一个类似的问题

我使用的是Asp Net标识和EF Core组合示例,一切都正常工作,数据库、种子、api调用,但我尝试从IS页面注销时除外。它不会删除保持用户登录客户端的
.AspNetCore.Cookies

[HttpPost]
[ValidateAntiForgeryToken]
公共异步任务注销(LogoutInputModel)
{
//构建一个模型,以便注销页面知道要显示什么
var vm=await BuildLoggedOutViewModelAsync(model.LogoutId);
if(User?.Identity.IsAuthenticated==true)
{
_LogCustomInfo(LoggingType.Information,“+”注销:用户已通过身份验证“+”);
尝试
{
等待_signInManager.SignOutAsync();
等待HttpContext.SignOutAsync(IdentityConstants.ApplicationScheme);
等待HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);
//引发注销事件
wait_events.RaiseAsync(新用户logoutSuccessEvent(User.GetSubjectId(),User.GetDisplayName());
}
捕获(不支持异常)
{
_log.LogCustomInfo(LoggingType.Information,“+”注销:SignOutAsync不支持“+”);
}
}
/* https://github.com/IdentityServer/IdentityServer4/issues/855 */
//检查是否需要在上游身份提供商处触发注销
//删除本地身份验证cookie
Response.Cookies.Delete(“.AspNetCore.Identity.Application”);
Response.Cookies.Delete(“idserv.external”);
Response.Cookies.Delete(“idserv.session”);
_LogCustomInfo(LoggingType.Information,“+”注销:触发外部注销“+vm.TriggerExternalSignout+”);
if(vm.TriggerExternalSignot)
{
//构建一个返回URL,以便上游提供程序将重定向回
//在用户注销后发送给我们。这允许我们
//完成我们的单一注销处理。
字符串url=url.Action(“注销”,新的{logoutId=vm.logoutId});
//url=_配置[“AppSettings:PostLogoutRedirectUri”];
url=vm.PostLogoutRedirectUri;
//url=“redirect.html”;
//这将触发重定向到外部提供程序以进行注销
_LogCustomInfo(LoggingType.Information,“+”注销:重定向到“+url+”);
返回注销(新的AuthenticationProperties{RedirectUri=url},vm.ExternalAuthenticationScheme);
}
返回视图(“LoggedOut”,vm);
}
angular客户端和MVC应用程序也有同样的问题

如果手动删除
.AspNetCore.Identity.Application
,则客户端将注销。我正在使用
keydape
进行身份验证,并使用

options.signnscheme=IdentityServerConstants.ExternalCookieAuthenticationScheme;
options.SignOutScheme=IdentityServerConstants.SignOutScheme;

在启动中是配置选项。

客户端应用程序应删除应用程序Cookie

如果您在应用程序中启动注销,则必须从方案、cookie和oidc中注销。例如:

public IActionResult Logout()
{
    return SignOut(new[] { "Cookies", "oidc" });
}
这样,您已经删除了客户端的cookie

如果您在Idp中启动注销,您可以使用以下规范之一使用全局注销机制:

通过这种方式,您可以在同一会话中从当时登录的所有应用程序客户端注销


identity server 4支持所有这些功能。

我可以通过手动删除应用程序cookie来注销。起初删除它时遇到问题,因为我没有指定应用程序路径。指定cookie路径后,可以删除cookie

  Response.Cookies.Delete(".AspNetCore.Identity.Application", new CookieOptions()
    {
        Path = "/eds-daas"
    });

我知道这是个老问题,但我也有同样的问题

事实证明,我从回购协议中获得的代码没有删除问题所做的cookies的行。一旦我添加了它,注销实际上就注销了

Response.Cookies.Delete(".AspNetCore.Identity.Application");
Response.Cookies.Delete("idserv.external");
Response.Cookies.Delete("idserv.session");

repo是针对当前最新的IdentityServer4.1.1的,应该可以正常工作,因为它是演练的结果。

我构建了一个带有独立API的MVC应用程序。我使用IdentityServer4进行身份验证,并按照上述步骤在IdentityServer4的AccountController中添加Response.Cookies.Delete,工作正常。不管怎样,我的客户保留了饼干

为了从客户端中删除它们,我在返回注销之前向Logout方法添加了相同的行

    /// <summary>
    /// Handle logout page postback
    /// </summary>
    [HttpPost]
    [ValidateAntiForgeryToken]
    public async Task<IActionResult> Logout(LogoutInputModel model)
    {
        // build a model so the logged out page knows what to display
        var vm = await BuildLoggedOutViewModelAsync(model.LogoutId);

        if (User?.Identity.IsAuthenticated == true)
        {
            Response.Cookies.Delete(".AspNetCore.Identity.Application");
            Response.Cookies.Delete("idserv.external");
            Response.Cookies.Delete("idserv.session");

            // delete local authentication cookie
            await HttpContext.SignOutAsync();

            // raise the logout event
            await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName()));
        }

        // check if we need to trigger sign-out at an upstream identity provider
        if (vm.TriggerExternalSignout)
        {
            // build a return URL so the upstream provider will redirect back
            // to us after the user has logged out. this allows us to then
            // complete our single sign-out processing.
            string url = Url.Action("Logout", new { logoutId = vm.LogoutId });

            // this triggers a redirect to the external provider for sign-out
            return SignOut(new AuthenticationProperties { IsPersistent = true, RedirectUri = url }, vm.ExternalAuthenticationScheme);
        }

        return View("LoggedOut", vm);
    }
//
///句柄注销页回发
/// 
[HttpPost]
[ValidateAntiForgeryToken]
公共异步任务注销(LogoutInputModel)
{
//构建一个模型,以便注销页面知道要显示什么
var vm=await BuildLoggedOutViewModelAsync(model.LogoutId);
if(User?.Identity.IsAuthenticated==true)
{
Response.Cookies.Delete(“.AspNetCore.Identity.Application”);
Response.Cookies.Delete(“idserv.external”);
Response.Cookies.Delete(“idserv.session”);
//删除本地身份验证cookie
等待HttpContext.SignOutAsync();
//引发注销事件
wait_events.RaiseAsync(新用户logoutSuccessEvent(User.GetSubjectId(),User.GetDisplayName());
}
//检查是否需要在上游身份提供商处触发注销
if(vm.TriggerExternalSignot)
{
//构建一个返回URL,以便上游提供程序将重定向回
//在用户注销后发送给我们。这允许我们
//完成我们的单一注销处理。
字符串url=url.Action(“注销”,新的{logoutId=vm.logoutId