-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(oidc): separate state, nonce and codeVerifier for each tab (release) #1402
fix(oidc): separate state, nonce and codeVerifier for each tab (release) #1402
Conversation
aba2663
to
2b33253
Compare
thank you @krzempekk Awesome ! I test it tomorrow morning ! |
Hi @krzempekk , Thank you very much for your PR it is very interresting. It can offer a new mode with the same behavior than using session Storage only. I Think you may add a way to configure if it use add tabid or not at the end of NONCE_SECURED_BY_OIDC_SERVICE_WORKER_default_tabid (for exemple a new property in configuration service_worker_tab_mode) |
Hi @guillaume-chervet! |
2b33253
to
d418ac2
Compare
d418ac2
to
8245239
Compare
hi @krzempekk I smooth switch via a configuration is necessary because it is a breacking change behavior. Default AXA behavior is one login for all pages. If you want we can try to merge your PR like that, I can publish this version as an alpha and add a a property to make it switchable in few days ? I have some code check to to before. |
Hi @guillaume-chervet! |
Hi @guillaume-chervet! |
Thank you so much @krzempekk . Sorry i did not have time to test it today. |
@@ -322,13 +335,16 @@ const handleMessage = async (event: ExtendableMessageEvent) => { | |||
const convertAllRequestsToCorsExceptNavigate = Array.isArray(trustedDomain) | |||
? false | |||
: trustedDomain.convertAllRequestsToCorsExceptNavigate; | |||
const allowMultiTabLogin = Array.isArray(trustedDomain) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may have a bug, demo default behaviors seems like allowMultiTabLogin=true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what do you mean 🤔. If trustedDomain
is an array, then allowMultiTabLogin
will be false. It will be true only if trustedDomain
is an object with allowMultiTabLogin
explicitly set to true. Analogically to showAccessToken
.
I have checked and it looks like it actually defaults to false
. Did you got other behavior?
Hi @krzempekk , Thank you very much your code. I love this functionality ! An update to oidc and react reamde.md would be awesome but I can do it in another PR. |
…n behaviour (release)
6f99747
to
a14dcd4
Compare
Hi @guillaume-chervet! I have updated readme for oidc and react client with examples of new configuration. |
Sorry @krzempekk I was bad at testing :) Thank you so much @krzempekk I merge your very nice PullRequest. |
This resolves #1356. Idea of the solution is similar to #1379.
This is a work-in-progress PR. I created this to share general idea for the solution while still working on details/tests.
Before this PR
state
,nonce
andcodeVerifier
were just single values. If two login flows were initiated from different tabs, one value overwritten the other, resulting in errors.After this PR
state
,nonce
andcodeVerifier
are maps with tab id as key. This means that each tab that initiates login has its value persisted in service worker and won't be overwritten.Tab IDs are generated using crypto.randomUUID function and saved to sessionStorage. Each tab sends its own ID to service worker as part of
init
,setNonce
,getNonce
,setState
,getState
,setCodeVerifier
andgetCodeVerifier
messages.For values that are hidden by service worker (nonce and code verifier, state is not hidden), dummy values now contain tab id as well, for example:
NONCE_SECURED_BY_OIDC_SERVICE_WORKER_default_tabid
. This allows to properly replace them inhandleFetch
logic.