Skip to content

Commit cae8cfe

Browse files
committed
docs,fix: Address CodeRabbit review on transparent-proxy PR
- config: clarify TransparentProxyAddr doc — the proxy-sidecar/lite presets default it to :8082 (always-on by design); empty only disables it for modes without a preset default. Removes the misleading 'empty disables' claim that the preset contradicts. - transparentproxy.NewServer: guard against a nil ConnHandler (fall back to a close-and-log handler) so a misconfiguration degrades to no-capture instead of a dispatch-time panic. - proxy-init README: list 'lite' alongside 'proxy-sidecar' in the mode table to match the injection section. Declined: SSH (port 22) exclusion for enforce-redirect. Excluding 22 would punch a deliberate egress bypass hole, contradicting the fail-closed purpose; the transparent listener blind-tunnels any TCP so captured SSH still works (unlike redirect mode, which forwards to Envoy's HTTP listener — the reason it excludes 22). enforce-drop does not exclude 22 either. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
1 parent f884dc4 commit cae8cfe

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

authbridge/authlib/config/config.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,13 @@ type ListenerConfig struct {
321321
// listener used by proxy-sidecar enforce-redirect mode: iptables REDIRECTs
322322
// the agent's bypass egress here, and the listener recovers the original
323323
// destination via SO_ORIGINAL_DST and tunnels it through the same outbound
324-
// pipeline as the forward proxy. Default per proxy-sidecar preset is
325-
// ":8082". Empty disables the listener (cooperative HTTP_PROXY only).
324+
// pipeline as the forward proxy. The proxy-sidecar / lite presets default it
325+
// to ":8082", so for those shapes the listener is effectively always on —
326+
// binding is harmless when nothing is redirected to it (cooperative
327+
// HTTP_PROXY deployments simply never receive connections on it). An empty
328+
// value only disables the listener for modes that have no preset default for
329+
// this field (e.g. waypoint / envoy-sidecar); under proxy-sidecar / lite the
330+
// preset refills it, matching the always-on enforce-redirect design.
326331
TransparentProxyAddr string `yaml:"transparent_proxy_addr" json:"transparent_proxy_addr"`
327332

328333
// SessionAPIAddr is the bind address for the session events HTTP server

authbridge/authlib/listener/transparentproxy/server.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ type Server struct {
3434
// forwardproxy.Server.HandleTransparentConn, so transparent and explicit-proxy
3535
// egress share one auth pipeline.
3636
func NewServer(handle ConnHandler) *Server {
37+
if handle == nil {
38+
// Defensive: a nil handler would panic at dispatch and take down the
39+
// process. Fall back to closing the connection so a misconfiguration
40+
// degrades to "no capture" rather than a crash.
41+
handle = func(conn net.Conn, _ string) {
42+
slog.Error("transparent-proxy: nil connection handler; closing connection",
43+
"remote", conn.RemoteAddr().String())
44+
_ = conn.Close()
45+
}
46+
}
3747
return &Server{handle: handle}
3848
}
3949

authbridge/proxy-init/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ env var:
88
| `MODE` | Used by | What it does |
99
|---|---|---|
1010
| `redirect` (default) | `envoy-sidecar` | Transparently **REDIRECT**s pod traffic to the Envoy listeners. |
11-
| `enforce-redirect` | `proxy-sidecar` | Fail-closed egress guard that **captures**: REDIRECTs external TCP that bypasses the forward proxy to AuthBridge's transparent listener; DROPs non-TCP external egress. |
12-
| `enforce-drop` | `proxy-sidecar` | Fail-closed egress guard that **DROP**s any egress that bypasses the forward proxy. Predates `enforce-redirect`; retained as a no-transparent-listener fallback. |
11+
| `enforce-redirect` | `proxy-sidecar`, `lite` | Fail-closed egress guard that **captures**: REDIRECTs external TCP that bypasses the forward proxy to AuthBridge's transparent listener; DROPs non-TCP external egress. |
12+
| `enforce-drop` | `proxy-sidecar`, `lite` | Fail-closed egress guard that **DROP**s any egress that bypasses the forward proxy. Predates `enforce-redirect`; retained as a no-transparent-listener fallback. |
1313

1414
## `redirect` mode (envoy-sidecar)
1515

0 commit comments

Comments
 (0)