Skip to content

[fix] Re-initialize Dex UserManager on cluster switch and use sessionStorage for callback dexUrl#569

Merged
dcharles525 merged 1 commit into1.14.0from
fix/extension-dex-issues
Apr 28, 2026
Merged

[fix] Re-initialize Dex UserManager on cluster switch and use sessionStorage for callback dexUrl#569
dcharles525 merged 1 commit into1.14.0from
fix/extension-dex-issues

Conversation

@dcharles525
Copy link
Copy Markdown
Member

@dcharles525 dcharles525 commented Apr 28, 2026

PR Checklist

  • Linting Test is passing
  • Code is well documented
  • If applicable, a PR in the epinio/docs repository has been opened

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-initialize dexUserManager on cluster switch

EpinioAuth is a singleton. Previously login() only initialized dexUserManager if it was null, so switching from one Epinio cluster to another reused the first cluster's Dex manager (wrong authority/Dex URL). The fix re-initializes the manager whenever the target cluster's Dex URL differs from the current manager's authority. A missing await on initialiseDex was also corrected.

2. utils/auth.ts + pages/auth/verify.vue — Use sessionStorage for dexUrl in callback

verify.vue previously used document.referrer as the dexUrl when processing the Dex callback, which is empty when Dex sends a Referrer-Policy: no-referrer header. initialiseDex now writes the cluster's dexUrl to sessionStorage before opening the popup, and verify.vue reads it back. document.referrer is retained as a fallback.

Technical notes summary

  • UserManager.settings.authority (from oidc-client-ts) is used to compare the current Dex URL against the target cluster's dexUrl to detect when re-initialization is needed.
  • sessionStorage is used rather than localStorage so the stored dexUrl is scoped to the current browser session/tab.
  • initialiseDex already handled re-initialization correctly (logs out existing user, replaces manager) — the only change needed in login() was the condition that gates the call.

Areas or cases that should be tested

  1. Stand up two Epinio clusters (e.g. dev and prod) with separate Dex instances on rancher.internal
  2. Log in to the prod cluster via Dex — confirm you land on prod's dashboard
  3. Log out of prod, navigate to dev, and log in via Dex — confirm the popup opens against dev's Dex URL and you land on dev's dashboard
  4. Reverse order: log into dev first, then prod — confirm correct behavior
  5. Confirm single-cluster Dex login still works normally
  6. Confirm local (non-Dex) login is unaffected

Browser used for local testing: Chrome

Areas which could experience regressions

  • Single-cluster Dex login — low risk; the new authority !== dexUrl condition is a no-op when there is only one cluster, since the manager initializes correctly on first call
  • sessionStorage in popup context — parent and popup share the same origin so sessionStorage is accessible; document.referrer fallback is retained if sessionStorage returns null

Screenshot/Video

Verified working on rancher.internal with dev and prod Epinio instances.

@github-actions github-actions Bot added the kind/bug Something isn't working label Apr 28, 2026
@dcharles525 dcharles525 changed the base branch from main to 1.14.0 April 28, 2026 20:07
@dcharles525 dcharles525 changed the title Fix/extension dex issues [fix] Re-initialize Dex UserManager on cluster switch and use sessionStorage for callback dexUrl Apr 28, 2026
…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.
@dcharles525 dcharles525 force-pushed the fix/extension-dex-issues branch from e95dbe6 to cd2589c Compare April 28, 2026 20:15
@dcharles525 dcharles525 merged commit 510b8e1 into 1.14.0 Apr 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant