Skip to content

Allow marking custom headers as sensitive on redirects - #177

Merged
floitsch merged 1 commit into
mainfrom
followup/redirect-sensitive-headers
Oct 11, 2026
Merged

floitsch merged 1 commit into
mainfrom
followup/redirect-sensitive-headers

Conversation

@floitsch

Copy link
Copy Markdown
Member

Custom credentials such as X-Api-Key currently follow cross-origin redirects. Add --sensitive-headers to both Client constructors so callers can name additional headers to strip whenever the scheme, host, or port changes. Matching is ASCII case-insensitive; same-origin redirects retain credentials, and credentials removed during a chain are never restored. The configuration list is copied and caller-owned request headers remain unchanged.

This is an additive policy: ordinary custom headers continue to be forwarded. Applications must list their custom credential headers (for example, http.Client network --sensitive-headers=["X-Api-Key"]) or disable redirect following. The three standard credential headers remain unconditionally protected. This avoids introducing a restrictive allowlist that would break existing custom-header forwarding.

Follow-up to #174: #174 (comment).

Validation on Toit v2.0.0-alpha.199:

  • 19/19 local tests passed with ctest --test-dir build -j4 --output-on-failure -E 'google|webdriver', configured with ENABLE_HTTPBIN_TESTS=OFF.
  • New regressions cover both constructors, GET/POST/WebSocket redirects, 303/307 responses, host/port/scheme changes, duplicate values, mixed-case configuration, configuration mutation, caller ownership, and return-to-origin chains.
  • Removing the additional-header filter makes the new regression fail.
  • Source and test analysis and git diff --check passed.

Live Google, browser, and httpbin integration tests were not run locally. This PR targets merged main and can be reviewed independently of the downgrade-policy follow-up.

@floitsch

Copy link
Copy Markdown
Member Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Oct 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 19455250-6e46-4584-8e1c-2bb74ecbf317

📥 Commits

Reviewing files that changed from the base of the PR and between fcad902 and a038618.


📒 Files selected for processing (2)
  • src/client.toit
  • tests/client-sensitive-headers-test.toit

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@floitsch
floitsch force-pushed the followup/redirect-sensitive-headers branch from a038618 to 6e1bfc4 Compare October 11, 2026 20:40
@floitsch
floitsch merged commit 4ae82b7 into main Oct 11, 2026
13 checks passed
@floitsch
floitsch deleted the followup/redirect-sensitive-headers branch October 11, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant