Skip to content

fix!: refuse redirects and set a timeout on every outbound request - #50

Merged
Bccorb merged 1 commit into
mainfrom
fix/refuse-client-redirects
Nov 23, 2026
Merged

Bccorb merged 1 commit into
mainfrom
fix/refuse-client-redirects

Conversation

@Bccorb

@Bccorb Bccorb commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #44 (M15, part of fells-code/seamless-auth-api#603).

Problem

Builder::http_client and VerifierBuilder::http_client took a finished reqwest::Client and used it as-is. A default client follows up to 10 redirects with no timeout. reqwest strips Authorization across hosts but not x-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 by configure_http_client(FnOnce(ClientBuilder) -> ClientBuilder). The adapter builds the client and applies redirect::Policy::none() after the hook, so a hook cannot turn redirects back on.
  • Builder::http_timeout(Duration) (default 15 seconds, as in Go options.go:167-178) sets the client timeout and is also set on every request to the auth API (Inner::call and the live permission read), so it holds whatever the hook does. JWKS, manifest and discovery fetches keep their 5 second per-request timeouts.
  • The console proxy keeps its own client, which follows redirects only inside the console.

This is a breaking API change, declared with fix!: and a BREAKING 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 answers POST /login with a 302 to a second listener, with a hook that sets Policy::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.
  • Existing tests that supplied a client now use http_timeout and configure_http_client.

Checks

  • cargo fmt --check: clean
  • cargo clippy --all-targets -- -D warnings (default, --no-default-features, --no-default-features --features native-tls): clean
  • cargo test and cargo +1.88 test: 156 passed
  • scripts/check-manifest.sh: bundled manifest matches

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.
@Bccorb
Bccorb merged commit 6e9d43d into main Nov 23, 2026
4 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: refuse redirects and set a timeout on caller-supplied HTTP clients

1 participant