IdentityServer4 icon indicating copy to clipboard operation
IdentityServer4 copied to clipboard

How do I get the logoutid?

Open mithun-daa opened this issue 9 years ago • 7 comments

  • [x] I read and understood how to enable logging

Hello there, I have a node application that is using IdSrv4 to authenticate users using OpenIdConnect. Everything works great. The only thing I have missing right now is that the logoutId does not get passed to my Idsrv from my application. The openid connect client that I am using for node says that I am on my own when it comes to logout. How and where is this available? The id_token does not have anything like this in it. Is one of the properties of the id_token being used as the logout id? I also see id_token_hint being passed. I am assuming these 2 fields are needed for a proper logout.

mithun-daa avatar Mar 30 '17 18:03 mithun-daa

The logoutId is an internal detail that stays within IdentityServer -- it won't ever be passed to your client apkplication. It allows the logout page at IdentityServer to know the correct context for achieving single signout.

brockallen avatar Mar 30 '17 19:03 brockallen

The following bit of code from the samples gave me the impression that it needed to be passed in if I decide to call the AccountController.Logout action directly:

[HttpGet]
        public async Task<IActionResult> Logout(string logoutId)
        {
            var vm = await _account.BuildLogoutViewModelAsync(logoutId);
       ....

mithun-daa avatar Mar 30 '17 21:03 mithun-daa

The following bit of code from the samples gave me the impression that it needed to be passed in if I decide to call the AccountController.Logout action directly:

Your client should be hitting thr end session endpoint, not the logout controller/page directly.

brockallen avatar Mar 30 '17 21:03 brockallen

Docs have (finally) been written covering this topic: https://identityserver4.readthedocs.io/en/release/topics/signout.html

brockallen avatar Apr 09 '17 19:04 brockallen

For core 2.1, add scaffolding files for Microsoft' Identity, in Logout.cshtml.cs, add namespaces of using IdentityServer4.Services; using IdentityServer4.Models; using IdentityServer4.Events; using Microsoft.AspNetCore.Authentication; using IdentityServer4.Extensions;

And inject of private readonly IIdentityServerInteractionService _interaction; private readonly IEventService _events;

Change public void OnGet(){} to public async Task OnGet(string logoutId)

For me, just following codes

public async Task OnGet(string logoutId) { var logout = await _interaction.GetLogoutContextAsync(logoutId); if (User?.Identity.IsAuthenticated == true) { // delete local authentication cookie await HttpContext.SignOutAsync();

            await _signInManager.SignOutAsync();

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

    } 

michaelsun2016 avatar Oct 30 '18 03:10 michaelsun2016

I had a similar issue and realize that this happens when you have not properly configured the PostLogoutRedirectUri in ClientPostLogoutRedirectUris table. In my case, I began experiencing it when I moved environment and didn't register the new environment's url.

janmchan avatar Aug 08 '19 00:08 janmchan

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jan 10 '20 22:01 lock[bot]