swift-server / swift-server/async-http-client

Support a pluggable redirect strategy in RedirectConfiguration

Open
#923 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
1.1k
Forks
156
PR merge metrics
No merged PRs in 30d

Description

Following up on #604: is fine-grained control over redirects (a pluggable strategy, not just .disallow/.follow) still something you'd want upstream?

Security motivation, not just convenience: .follow already strips Authorization/Cookie on cross-origin redirects, but that policy is fixed and all-or-nothing. There's no way for a caller to go further: refuse a redirect to a host outside an allow-list, strip additional headers, or just audit where a request ends up. URLSession gives callers that hook via its per-task delegate; AsyncHTTPClient has none.

Prototyped it in a fork: request-dl/async-http-client#6. A HTTPClientRedirectStrategy protocol (conforming types, not just closures) gets the full per-request history plus the candidate request/response for each redirect, and decides follow/refuse/throw. Aims at the "pluggable redirect strategies" + "pass data around" gap from this comment: https://github.com/swift-server/async-http-client/issues/604#issuecomment-1192345532

Happy to open this as a real PR against main if there's still interest, or adjust the design first.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading RedirectConfiguration and issue #604, then compare the proposed HTTPClientRedirectStrategy protocol in request-dl/async-http-client#6 with the current redirect behavior. Determine how per-request history and candidate request/response data should be exposed, and confirm that callers can follow, refuse, throw, restrict hosts, modify headers, or audit redirects.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.