Repository navigation
fix: keep the session cookies when a refresh fails transiently - #39
Merged
Merged
Conversation
…nswers 401 Reproduces cookie-transport refreshes (the silent refresh on an auth route and POST /refresh) that sign a browser out when the auth API is unreachable, answers another error, returns no usable session, or the rotation times out or its task panics. Only a 401 or an unreadable refresh cookie should clear the session cookies. Turns on tokio's test-util for a paused clock in tests.
In cookie transport, the silent refresh on an auth route and POST /refresh now clear the session cookies only when the auth API answers the refresh with 401 or the refresh cookie cannot be read. An unreachable API, a rotation that times out or whose task panics, a 2xx other than a 200 with a verifiable session, all answer 502 upstream_unavailable; any other error from the API passes through with its status, body and Retry-After. The cookies are kept in every one of these cases so the next request tries again, matching the Go, Node and Python adapters. Bearer refresh is unchanged.
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, fells-code/seamless-auth-server#273 and fells-code/seamless-auth-python#37 for cookie transport. Today every cookie refresh failure collapses into
SilentRefreshError::Failedand a 401 that clears the cookies, so an auth API outage or a 5xx during a deploy signs browsers out.Cookies are now cleared only when the auth API answers 401 or the refresh cookie cannot be read (today's
Refresh failed/invalid_refresh_tokenanswers).POST /refreshupstream_unavailableRetry-Afterpass throughSilentRefreshErroris nowNoRefreshCookie,Rejected(cookies cleared) andTransient(Box<Reply>)(the answer to send, cookies kept);refresh_routeandcredential_forreturn the transient reply. Bearer refresh, in-flight sharing and the cookie-only 5 second window (successful rotations only) are unchanged. A failure to sign the internal service token now answers 500internal_errorwith cookies kept, matching the bearer path.8daf82aadds the tests alone; 8 fail onmain(closed port, 503 withRetry-After, no session, 201, unknown key, timeout on a paused clock, panic, failure not kept). The paused clock adds tokio'stest-utildev-dependency feature;Cargo.lockis unchanged.fmt, clippy
-D warningson all three feature sets,cargo testandcargo +1.88 test(136 + 1 doctest),check-manifest.shpass.