Repository navigation
fix!: refuse redirects and set a timeout on every outbound request - #50
Merged
Merged
Conversation
A caller-supplied reqwest::Client was used as-is, so a default client followed up to 10 redirects with no timeout. reqwest strips Authorization across hosts but not x-seamless-service-token, whose refresh variant carries the user's refresh token. The adapter and the verifier now always build their own client and apply redirect::Policy::none() after any caller hook. Calls to the auth API also carry a per-request timeout (15 seconds by default, set with http_timeout), matching the Go adapter. Fixes #44 BREAKING CHANGE: Builder::http_client(reqwest::Client) and VerifierBuilder::http_client(reqwest::Client) are removed, because a built client's redirect policy cannot be changed. Use configure_http_client(|b| ...) to adjust the reqwest::ClientBuilder (proxy, TLS roots, DNS), and Builder::http_timeout(Duration) for the timeout.
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.
Fixes #44 (M15, part of fells-code/seamless-auth-api#603).
Problem
Builder::http_clientandVerifierBuilder::http_clienttook a finishedreqwest::Clientand used it as-is. A default client follows up to 10 redirects with no timeout. reqwest stripsAuthorizationacross hosts but notx-seamless-service-token, and the refresh variant of that token embeds the user's refresh token.Decision
reqwest cannot change the redirect policy of a built
Client, so a supplied client is no longer accepted:http_client(reqwest::Client)is replaced on both builders byconfigure_http_client(FnOnce(ClientBuilder) -> ClientBuilder). The adapter builds the client and appliesredirect::Policy::none()after the hook, so a hook cannot turn redirects back on.Builder::http_timeout(Duration)(default 15 seconds, as in Gooptions.go:167-178) sets the client timeout and is also set on every request to the auth API (Inner::calland the live permission read), so it holds whatever the hook does. JWKS, manifest and discovery fetches keep their 5 second per-request timeouts.This is a breaking API change, declared with
fix!:and aBREAKING CHANGE:footer so release-plz makes the 0.x minor bump. The README options table and the verifier section document the new options and why a built client is refused.Tests
a_302_to_another_listener_never_receives_the_service_token: the fake API answersPOST /loginwith a 302 to a second listener, with a hook that setsPolicy::limited(10). The adapter passes the 302 back, the first listener received the service token, and the second listener received nothing. The test fails when the forced policy is removed.http_timeoutandconfigure_http_client.Checks
cargo fmt --check: cleancargo clippy --all-targets -- -D warnings(default,--no-default-features,--no-default-features --features native-tls): cleancargo testandcargo +1.88 test: 156 passedscripts/check-manifest.sh: bundled manifest matches