Repository navigation
fix: keep the session cookies when a refresh fails transiently - #37
Merged
Merged
Conversation
…nswers 401 Covers silent refresh and cookie-transport POST /refresh, in the core and through the FastAPI and Django bindings: a transport error, a 2xx with no session or an unverifiable one, and a waiter timing out answer 502 upstream_unavailable; any other non-2xx passes through; only a 401 or an unreadable refresh cookie clears the cookies.
In cookie transport, silent refresh and POST /refresh cleared every session cookie on any refresh failure, so an auth API outage or a 503 during a deploy signed every browser out. Now only a 401 from the auth API, or a refresh cookie that cannot be read, ends the session. A transport error, a 2xx with no session or one that fails verification, and a waiter timing out on another rotation answer 502 upstream_unavailable; any other non-2xx passes its status and body through. The cookies are kept in each case. Matches seamless-auth-go.
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.
Parity with fells-code/seamless-auth-go#22 and fells-code/seamless-auth-server#273 for cookie transport. Today every refresh failure signs the browser out, including an auth API outage or a 5xx during a deploy.
Cookies are now cleared only when the auth API answers the refresh with 401, or the refresh cookie cannot be read; those keep today's answers (silent refresh 401
Refresh failed,POST /refresh401invalid_refresh_token).POST /refreshupstream_unavailableupstream_errorfor a non-JSON body)_silent_refreshreturns the rotated session, a_RefreshFailed(reason, reply), orNonewith no refresh cookie, replacing the old string sentinel. In-flight sharing, the cookie-only 5 second window (successful rotations only), bearer refresh, logout and the post-enrollment refresh are unchanged.c087de1addstests/test_refresh_failures.pyalone (38 cases across silent refresh, cookiePOST /refresh, FastAPI and Django); 26 fail onmain. Client code that treated any refresh failure as signed out may now see 502, 503 or 429; the README's "How it runs" section has the table.ruff, ruff format, mypy strict,
check-manifest.shpass; pytest 634 passed. Not covered: Python does not forwardRetry-After(Rust does on bearer refresh).