[Bug] OIDC login fails in Firefox — app POSTs /api/auth/logout during the callback and the callback request is aborted (nginx 499)
Describe the bug
Login via OIDC (Microsoft Entra ID) fails in Firefox with Network error during OIDC callback. The same flow works in Chrome.
The request that completes the login — POST /api/auth/oidc/callback — is aborted by the browser before the server responds. The reverse proxy logs it as 499 with a 0-byte response, so the backend never processes it and nothing appears in the application log.
At the same moment the app sends POST /api/auth/logout, which succeeds with 200. Both requests are logged within the same second.
This looks like a race in the frontend: while LoginScreen is exchanging the authorization code, AuthProvider runs its own session check, gets a 401, and calls logout() — tearing down the session in the middle of the login it is supposed to complete. Whether that is also what aborts the request I cannot prove from the outside, but the sequence is consistent across attempts, and the timing-dependent nature matches the fact that Chrome succeeds and Firefox does not.
Steps to Reproduce
- Configure OIDC (Entra ID) and log out completely.
- Open the login page in Firefox and click Sign in with Microsoft.
- Authenticate at Microsoft and get redirected back to
/oidc/callback?code=…&state=…. - The login screen reappears with
Network error during OIDC callback.
Expected behavior
The authorization code should be exchanged and the user logged in, as happens in Chrome. The app should not log itself out while an OIDC callback is in flight.
Environment
- PegaProx Version: 1.0.1
- Installation Method: Docker (Docker Swarm)
- OS: Debian 12
- Browser: Firefox 153 (macOS) — works in Chrome
- Behind Reverse Proxy? nginx-proxy
- UI? Corporate
Logs
nginx access log, both requests in the same second (code/state redacted):
"POST /api/auth/logout HTTP/2.0" 200 17 "https://…/oidc/callback?code=REDACTED&state=REDACTED" "Mozilla/5.0 (Macintosh; …) Firefox/153.0"
"POST /api/auth/oidc/callback HTTP/2.0" 499 0 "https://…/oidc/callback?code=REDACTED&state=REDACTED" "Mozilla/5.0 (Macintosh; …) Firefox/153.0"
499 is nginx's status for a client that closed the connection before the response was sent. The application log contains no entry for the callback, which is consistent.
A same-origin POST with a ~4 kB JSON body from the same Firefox returns normally (405 from POST /api/auth/check, 221 ms), so this is not a transport, TLS, HTTP/2, proxy or CSP problem.
Analysis
web/src/auth.js:25-60 — on mount, LoginScreen posts the code and state:
if (code && state) {
setOidcLoading(true);
fetch(`${API_URL}/auth/oidc/callback`, { method: 'POST', credentials: 'include', ... })
web/src/contexts.js:266-271 — in parallel, checkSession() treats any non-OK response as a reason to log out:
} else {
try { const errData = await r.json(); … } catch(e) {}
logout();
}
web/src/contexts.js:421-441 — logout() posts to /auth/logout and then re-checks:
const logout = async () => {
try { await fetch(`${API_URL}/auth/logout`, { method: 'POST', credentials: 'include' }); } …
On a callback URL there is no session yet, so /auth/check returns 401 and the logout always fires — including on the OIDC callback page, where the login is still in progress. The oidc_state cookie set before the redirect (pegaprox/api/auth.py:107) is exactly what the callback needs to validate state.
As a side note, this also means every unauthenticated page load sends a POST /api/auth/logout.
Screenshots
Suggested fix
Skip the logout path when the current URL carries OIDC callback parameters, e.g. do not call logout() from checkSession() when code and state are present in window.location.search. More generally, a 401 from /auth/check for a visitor who was never logged in is the normal case and arguably should not trigger a logout request at all.
Checklist
- [x] I have searched existing issues to make sure this is not a duplicate
- [x] I am using the latest version of PegaProx
This is an excellent bug report — thank you. The sequence you've reconstructed is very plausible: if AuthProvider's session check races the callback exchange, a 401 → logout() firing mid-flight would tear the session down (and abort the in-flight callback POST, which lines up exactly with the 499 / 0-byte the proxy logs). Chrome vs. Firefox coming down to request-scheduling timing fits that shape too.
So this reads as a frontend ordering problem: the session check needs to stand down while an OIDC callback is in progress, instead of logging itself out from under it. We'll get it looked at. Thanks for doing most of the diagnosis for us — the proxy logs and the Chrome/Firefox split are exactly the details that make this actionable.
Fixed in v1.0.2 — the app no longer fires a logout during the OIDC callback exchange in Firefox. Thanks for the precise repro. https://github.com/PegaProx/project-pegaprox/releases/tag/v1.0.2