Skip to content
This repository has been archived by the owner on Mar 3, 2022. It is now read-only.

Question: Supporting a single renew that is shared across all tabs? #1344

Open
justinbmeyer opened this issue Apr 20, 2021 · 3 comments
Open

Comments

@justinbmeyer
Copy link

justinbmeyer commented Apr 20, 2021

If multiple tabs are using the same shared access/refresh token and one of the tabs starts renewing, can I prevent the other tabs from renewing and "piggy back" off the tab that is performing the renew?

Could https://developer.mozilla.org/en-US/docs/Web/API/Web_Locks_API be used in browsers that support it?

@justinbmeyer justinbmeyer changed the title Question: Supporting a single refresh that is shared across all tabs? Question: Supporting a single renew that is shared across all tabs? Apr 20, 2021
@justinbmeyer
Copy link
Author

Any thoughts on this? I can work to submit a patch.

@brockallen
Copy link
Member

The main issue is my bottleneck: If it's a complicated solution, then I don't have time to review.

@justinbmeyer
Copy link
Author

Ideally, it should just be putting a web-lock around the code that makes the refresh:

navigator.locks.request('oidc-client-refresh', async lock => {
  await go_do_a_refresh();
});

And telling people to use the polyfill:

https://github.com/bitovi/web-locks-polyfill

Even better, we could feature detect if locks exists:

if(navigator.locks) {
  navigator.locks.request('oidc-client-refresh', async lock => {
   await go_do_a_refresh();
 });
} else {
   go_do_a_refresh();
}

This would allow people to still use oidc-client without the polyfill in browsers that are missing web-locks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants