Search code examples
cookiesidentityserver4

IdentityServer4 external logout doesn't remove Google sign-on cookie


I am having trouble logging out of my identityServer under Google login. I can login through Google (external) with no issues but the logout never worked. After clicking on "Logout" I always get a message says "you are now logged out". But when I try to log back in again, I always get right in after clicking on the Googol button. My Chrome's Dev Tool shows that a cookie associated with my Google login left in there regardless if I click on logout.

enter image description here

And if I clear the cookie via Chrome, I will be able to get to the Google login page.

In trying to delete the cookie in my program when logging out, I tried the following code from the AccountController's Logout function. I watched the code got executed in debug mode, but it doesn't make any difference - the cookie is still there after the code gets executed and I am still get right in.

Could anyone tell me what I am missing here? Or is it just impossible to delete cookie from code?

enter image description here


Solution

  • To do an upstream signout the IDP (Google) would have to support the RP-initiated logout spec:

    https://openid.net/specs/openid-connect-rpinitiated-1_0.html#RPLogout

    However Google's discovery endpoint (https://accounts.google.com/.well-known/openid-configuration) does not advertise an end_session_endpoint so from that we'd have to conclude that it is not supported by Google.

    However you may be able to use prompt=login or max_age={number of seconds} in your authorization_endpoint endpoint request to force interactive authentication again. When you receive the id_token in the callback you can validate that the auth_time claim falls within whatever condition you decide. The end result is that you can insist that users interactively authenticate each time you do a round trip to Google. If auth_time is too far in the past you'd prevent the local session from being established.