Repository navigation
fix(client): don't follow cross-origin redirects with a bearer token - #192
Merged
Merged
Conversation
A token-bearing request asks fetch for redirect: 'manual', follows only redirects to trusted origins itself, and rejects others with UntrustedRedirectError. Where a platform follows anyway, a response that ended on another origin is rejected. Refs #177
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.
Refs #177. Part of the v0.19 release (fells-code/seamless-auth-api#385).
What
In bearer transport, a request that carries a token (
authorizedFetchand adapter calls):fetchforredirect: 'manual'and follows a redirect itself only when the target isapiHostor atrustedOriginsentry, up to five hops, withfetch's method rules (303, or 301/302 after a POST, becomes a GET without a body)UntrustedRedirectError(exported from client, react and react-native) without sending the token onfetch), rejects a response thatredirectedto another origin. The token may already have gone on that platform, which is why the iOS check below mattersredirectalone, with the final-origin check still appliedRequests without a token and cookie transport are unchanged. Client minor changeset, since redirect-following behaviour changes.
Checks
npm run lint,npm run format:check,npm run typecheck: passnpm test: 45 suites, 604 tests (Jest) and 41 (Vitest) pass, 8 new redirect casesnpm run build,npm run check-npm-build: passUntrustedRedirectErrorand that server received no request; a same-origin 302 is followed withAuthorizationkeptNot done (why this says Refs, not Closes)
#177's done-when also asks to verify iOS
NSURLSessionon a device or simulator against a 302 to another origin. That needs a React Native build; it is left open on the issue.