[fix] Re-initialize Dex UserManager on cluster switch and use sessionStorage for callback dexUrl#569
Merged
dcharles525 merged 1 commit into1.14.0from Apr 28, 2026
Merged
Conversation
…orage for callback dexUrl): This fixes issue if there are several Epinio instances with Dex, the first Epinio instance would be where the user would be routed to due to the re-init the dex url on click.
e95dbe6 to
cd2589c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Summary
Fixes EPINIO-577 — When clicking on one Epinio cluster (e.g. dev) while another (e.g. prod) had been previously authenticated, the login popup opened against the wrong cluster's Dex instance, routing the user to the wrong cluster or the front Rancher cluster after auth.
Occurred changes and/or fixed issues
1.
utils/auth.ts— Re-initializedexUserManageron cluster switchEpinioAuthis a singleton. Previouslylogin()only initializeddexUserManagerif it was null, so switching from one Epinio cluster to another reused the first cluster's Dex manager (wrongauthority/Dex URL). The fix re-initializes the manager whenever the target cluster's Dex URL differs from the current manager's authority. A missingawaitoninitialiseDexwas also corrected.2.
utils/auth.ts+pages/auth/verify.vue— UsesessionStoragefordexUrlin callbackverify.vuepreviously useddocument.referreras thedexUrlwhen processing the Dex callback, which is empty when Dex sends aReferrer-Policy: no-referrerheader.initialiseDexnow writes the cluster'sdexUrltosessionStoragebefore opening the popup, andverify.vuereads it back.document.referreris retained as a fallback.Technical notes summary
UserManager.settings.authority(fromoidc-client-ts) is used to compare the current Dex URL against the target cluster'sdexUrlto detect when re-initialization is needed.sessionStorageis used rather thanlocalStorageso the storeddexUrlis scoped to the current browser session/tab.initialiseDexalready handled re-initialization correctly (logs out existing user, replaces manager) — the only change needed inlogin()was the condition that gates the call.Areas or cases that should be tested
rancher.internalBrowser used for local testing: Chrome
Areas which could experience regressions
authority !== dexUrlcondition is a no-op when there is only one cluster, since the manager initializes correctly on first callsessionStoragein popup context — parent and popup share the same origin sosessionStorageis accessible;document.referrerfallback is retained ifsessionStoragereturns nullScreenshot/Video
Verified working on
rancher.internalwith dev and prod Epinio instances.