Skip to content

Fixes redirect-based OAuth login when OAUTH_DISABLE_POPUP=true is set - #2171

Merged
henrygd merged 2 commits into
henrygd:mainfrom
polter-rnd:2170-fix-oauth-without-popup
Aug 11, 2026
Merged

Fixes redirect-based OAuth login when OAUTH_DISABLE_POPUP=true is set#2171
henrygd merged 2 commits into
henrygd:mainfrom
polter-rnd:2170-fix-oauth-without-popup

Conversation

@polter-rnd

Copy link
Copy Markdown
Contributor

📃 Description

Fixes redirect-based OAuth login when OAUTH_DISABLE_POPUP=true is set. Two defects prevented the redirect flow from completing:

  1. The required redirect_uri parameter was commented out of the OAuth authorization request, producing a malformed request and a redirect_uri mismatch at the code-exchange step.
  2. The provider state (used for CSRF state verification and the PKCE codeVerifier), was persisted in sessionStorage, which is tab-scoped. When the OAuth callback is delivered in a new browsing context - as happens with e.g. Authelia - the stored provider is missing and state verification always fails.

Both changes are confined to auth-form.tsx.

Fixes #2170

📖 Documentation

N/A — no documentation changes required.

🪵 Changelog

🔧 Fixed

  • Restore the required redirect_uri parameter on the OAuth authorization redirect URL so redirect-based login (OAUTH_DISABLE_POPUP=true) works.
    Store OAuth redirect provider state in localStorage instead of sessionStorage, so the callback succeeds when delivered in a new browsing context.
    Clean up the stored provider entry and strip the OAuth callback parameters from the URL on both the success and failure paths.

📷 Screenshots

N/A — no visual/UI changes.

@polter-rnd
polter-rnd requested a review from henrygd as a code owner July 31, 2026 09:36
@polter-rnd

Copy link
Copy Markdown
Contributor Author

Hi @svenvg93, this builds on top of your redirect-based OAuth work in #1900. Since you're most familiar with that flow, would you mind reviewing?

sessionStorage is tab-scoped, so when Authelia (or similar) deliver
the OAuth callback in a new browsing context, the stored provider
is not found and state verification always fails.

Switch to localStorage, which is shared across all tabs/windows of the
same origin. Also clean up the stored entry and strip the callback URL
on both success and failure paths.
@polter-rnd
polter-rnd force-pushed the 2170-fix-oauth-without-popup branch from 701eb1b to 2cde1ae Compare July 31, 2026 09:40

@henrygd henrygd left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thanks! Tested and it's working as intended.

@henrygd
henrygd merged commit 1aa9fcd into henrygd:main Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OAuth login fails when OAUTH_DISABLE_POPUP=true is set

2 participants