Skip to content

fix: scope bearer auth to API host#143

Merged
pquerna merged 1 commit into
mainfrom
paul.querna/restrict-bearer-redirects
Jun 26, 2026
Merged

fix: scope bearer auth to API host#143
pquerna merged 1 commit into
mainfrom
paul.querna/restrict-bearer-redirects

Conversation

@c1-squire-dev

@c1-squire-dev c1-squire-dev Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

What changed

  • Pass the configured API host into the uhttp token transport.
  • Attach the bearer token only when the outgoing request host matches that API host.
  • Clear any copied Authorization header before sending a request to a different host.
  • Add redirect coverage for same-host redirects, cross-host redirects, and copied auth headers on untrusted hosts.

Why

Cone's SDK HTTP client follows redirects by default. Since bearer auth is injected in the transport on each request, a redirect to a different host could otherwise receive a freshly attached token. This keeps normal same-host redirects working while avoiding credentials on cross-host hops.

Validation

  • go test ./pkg/uhttp
  • make lint
  • go test ./...
  • git diff --check --cached && git diff --check

Only attach the OAuth bearer token when the outgoing request host matches the configured API host, and clear any copied Authorization header before untrusted redirect hops.

Add uhttp coverage for same-host redirects, cross-host redirects, and copied Authorization headers on untrusted hosts.

Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
@pquerna pquerna merged commit aa17ef1 into main Jun 26, 2026
2 checks passed
@pquerna pquerna deleted the paul.querna/restrict-bearer-redirects branch June 26, 2026 05:54
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.

1 participant