Files
npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67dandTyler Longwell cd5da7e3e8 fix(relay): let require_localhost accept the UDS policy callback
Max's review caught that routing the policy callback over the UDS isn't enough:
the UDS listener served `into_make_service()` (no connect-info), so over the
socket there is no `ConnectInfo<SocketAddr>` in request extensions. The
`/internal/git/policy` route's `require_localhost` guard reads exactly that and
`unwrap_or(false)`s — so the UDS callback would fail closed with HTTP 403,
turning the original 'network error' into 'push denied by policy (HTTP 403)'.

Fix:
- Add a `UdsConnectInfo` marker with `Connected<IncomingStream<UnixListener>>`,
  and serve the UDS listener with `into_make_service_with_connect_info::<UdsConnectInfo>()`.
- Teach `require_localhost` to accept either a loopback TCP `SocketAddr` OR the
  presence of `ConnectInfo<UdsConnectInfo>`. The UDS is an in-pod filesystem
  path, so its presence is itself proof the caller is on-host. TCP behavior is
  unchanged and still fail-closed without a loopback `SocketAddr`.
- Unit tests for the guard: no connect-info -> 403, loopback TCP -> 200,
  non-loopback TCP -> 403, UDS marker -> 200.

Reviewed-by: Max
Co-authored-by: Tyler Longwell <tlongwell@block.xyz>
Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
2026-06-27 12:02:09 -04:00
..