oidc-client icon indicating copy to clipboard operation
oidc-client copied to clipboard

Won't disconnect current user if connected to another one in another tab

Open ludojmj opened this issue 3 years ago • 41 comments

Issue and Steps to Reproduce

Issue

"react-oidc-redux": "^3.1.7": Even if disconnected in another tab, the current session is still alive in the actual tab (until the token times out). No such issue with "react-oidc-redux": "3.1.6".

Steps to Reproduce

New tab 1

  • Link "protected1" or "protected2": connection to "Alice".

New tab 2

  • https://demo.identityserver.io/Account/Logout
  • https://demo.identityserver.io/Account/Login: connection to "Bob".

Back to tab 1

  • Link "protected1" or "protected2": still being connected to "Alice".
  • Won't switch to "Bob" session.

Expected

If disconnected in another tab, the current user must be disconnected in the working tab too.

Actual

Still connected to initial user even if another user has logged in in another tab.

Versions

"@axa-fr/react-oidc-redux": "^3.1.7",

Additional Details

Installed packages:

  • "@axa-fr/react-oidc-redux": "^3.1.7",
  • "oidc-client": "^1.11.5",
  • "redux-oidc": "^3.1.7"

ludojmj avatar Jul 05 '21 08:07 ludojmj

Hi @ludojmj , do you have update something more than our lib?

guillaume-chervet avatar Jul 08 '21 17:07 guillaume-chervet

And also thank you for that awesome bug report :)

guillaume-chervet avatar Jul 08 '21 17:07 guillaume-chervet

@ludojmj can you help for #611 issue ? It is missing in the redux and context readme

guillaume-chervet avatar Jul 08 '21 19:07 guillaume-chervet

Are you using inmemory storage?

guillaume-chervet avatar Jul 08 '21 19:07 guillaume-chervet

I didn't update anything : I took the project as is. Since I didn't update anything, yes I use InMemoryWebStorage. Next step: trying without InMemoryWebStorage.

ludojmj avatar Jul 09 '21 12:07 ludojmj

Same issue if I don't use InMemoryWebStorage. "oidc-client": "^1.11.5",

ludojmj avatar Jul 09 '21 13:07 ludojmj

Is there a solution to this problem? I have a similar situation. Help me solve it

MEnenko avatar Jan 19 '22 19:01 MEnenko

I have the same problem here when I disconnect I'm always connected to another tab. I use InMemoryStorage.

"@axa-fr/react-oidc-context": "^3.1.7",

allemas avatar Feb 18 '22 11:02 allemas

The same for me, is there any way to handle it?

lomboboo avatar Jun 30 '22 13:06 lomboboo

Hi @lomboboo which version are you using? I think i can implement it quickly in v5.

guillaume-chervet avatar Jun 30 '22 14:06 guillaume-chervet

Hello, thanks for quick response. I am using v5.12.0. My scenario is a follows (and this is really the only thing missing for me to cover all my cases):

  • login with Tab1 in ApplicationA
  • login with Tab2 in ApplicationB
  • logout or delete idsrv (IdentityServer4) cookie from ApplicationB
  • in Tab1 I am still logged in, no sessiontermination events fired. We previously used another library which actually handled this case, but your solution I like your solution more. Would be nice if there would be an option to establish "monitoring" OP somehow and give an ability to handle this case.

lomboboo avatar Jun 30 '22 14:06 lomboboo

Hi @lomboboo , thank you for your information.

Are you using serviceworker version? When do you need it.

I think it is not too hard to implement, but i need some times.

guillaume-chervet avatar Jun 30 '22 15:06 guillaume-chervet

You where previously using oidc client? (In background)

guillaume-chervet avatar Jun 30 '22 15:06 guillaume-chervet

We used redux-oidc which is based on oidc-client-js. No, I don’t use service worker configuration, but can try if you think it should help. How long do you think this implementation can take?

lomboboo avatar Jun 30 '22 15:06 lomboboo

Thank you for the information. I do not know about the time to do it. I have no idea how oidc client can do it because we are at client side. May be it use post message between tabs. I have to check how do oidc client do if you need app A oidc client be disconnected at the same time as application B oidc react. I need to use exactly the same mecanisum. Did you configure something special in oidc client to have this behavior? oidc react V3 was using oidc client but we dis not have the behavior.

guillaume-chervet avatar Jun 30 '22 20:06 guillaume-chervet

I think i understood https://link.medium.com/OQ2r94gLirb I will continue to investigate and test that.

guillaume-chervet avatar Jul 01 '22 06:07 guillaume-chervet

I don't think it has anything to do with the tabs specifically. You can logout from a different browser and it still emits logout from chrome tab. Basically, when you logout your idsrv cookie is deleted from all browsers/tabs, maybe there is a watch on that. I can take a look how it is triggered on the weekend.

lomboboo avatar Jul 01 '22 07:07 lomboboo

@guillaume-chervet Hello, I've spent some time looking of how it is implemented in the oidc-client-js. It is actually defined by openid specs. Oidc-client-js implementation is actually very similar and handled by CheckSessionIFrame and SessionMonitor

lomboboo avatar Jul 02 '22 18:07 lomboboo

Thank you very much for your help, i will try to implement that quickly.

guillaume-chervet avatar Jul 03 '22 02:07 guillaume-chervet

It is my next objective to set this behavior ul.

guillaume-chervet avatar Jul 11 '22 20:07 guillaume-chervet

Great, looking forward to

lomboboo avatar Jul 12 '22 07:07 lomboboo

I was figthing with mozilla but it is just a cookie problem in local development :]

I have to finish the pr (finish behavior and lot of clean refactor), but I got it how it works. I think I will need few more days. It is a great feature thank @lomboboo for your help !

guillaume-chervet avatar Jul 15 '22 12:07 guillaume-chervet

my pleasure, can't wait to test it :)

lomboboo avatar Jul 15 '22 13:07 lomboboo

Hi @lomboboo,

if you want you can make a try :

https://black-rock-0dc6b0d03-817.westeurope.1.azurestaticapps.net/

Published under version 6.0.0-alpha0 The breaking change is that it require a new silent_signin_uri property and the silent_redirect_uri need to be declared to OIDC server.

It seem stable, i need to clean and document it.

guillaume-chervet avatar Jul 17 '22 21:07 guillaume-chervet

Thanks a lot for the effort! I am pretty busy at the moment, but will take a look closer probably next week

lomboboo avatar Jul 18 '22 12:07 lomboboo

here a quick migration guide https://github.com/AxaGuilDEv/react-oidc/blob/295776fbfeabde78f6d39ae5326f3a7da5050a11/MIGRATION_GUIDE_V5_TO_V6.md

guillaume-chervet avatar Jul 19 '22 13:07 guillaume-chervet

@guillaume-chervet First of all thanks for the awesome feature! I was wondering is it possible to pass auth or oidc object to the sessionLostComponent? For example, I would like to wait 5s and call signinRedirect there. I saw how you implemented this in the examples, but I think it would be much cleaner solution. Also, can you please explain silent_signin_uri and silent_redirect_uri a bit more?

lomboboo avatar Jul 20 '22 12:07 lomboboo

Hi @lomboboo , if you have that screen it is that silentsignin won't work.

In my app i set up a button in order to signin again. I will send you a sample in a next message.

Does the logout work well for you?

guillaume-chervet avatar Jul 20 '22 12:07 guillaume-chervet

Here a sample used in production https://github.com/AxaGuilDEv/ml-cli/blob/master/src/Ml.Cli.WebApp/ClientApp/src/Server/shared/Oidc/SessionLost.component.js sample

guillaume-chervet avatar Jul 20 '22 12:07 guillaume-chervet

redirect_uri: manage callback inforation after login and must be declared to your OIDC server silent_signin_uri: route that trigger silent signin

guillaume-chervet avatar Jul 20 '22 13:07 guillaume-chervet