feat(egress): add preserve_auth flag to pass agent Authorization through
tracker-policy-pr / check-pr (pull_request) Successful in 6s
test / integration-docker (pull_request) Successful in 13s
test / unit (pull_request) Successful in 35s
lint / lint (push) Successful in 2m28s
test / integration-firecracker (pull_request) Successful in 3m34s
test / coverage (pull_request) Successful in 16s
test / publish-infra (pull_request) Has been skipped
tracker-policy-pr / check-pr (pull_request) Successful in 6s
test / integration-docker (pull_request) Successful in 13s
test / unit (pull_request) Successful in 35s
lint / lint (push) Successful in 2m28s
test / integration-firecracker (pull_request) Successful in 3m34s
test / coverage (pull_request) Successful in 16s
test / publish-infra (pull_request) Has been skipped
Adds a per-route boolean field preserve_auth (default false) that skips the gateway's Authorization header stripping for that host. Intended for registry endpoints like Docker Hub (registry-1.docker.io) and GHCR (ghcr.io) where the agent must supply its own per-scope bearer token. Threaded through ManifestEgressRoute → EgressRoute → Route, serialized in route_to_yaml_dict, and parsed in parse_routes. The strip at egress_addon.py now checks route.preserve_auth before popping the header. Closes #392
This commit is contained in:
@@ -413,6 +413,28 @@ class TestAuthInjection(unittest.TestCase):
|
||||
assert flow.response is not None
|
||||
self.assertEqual(403, flow.response.status_code)
|
||||
|
||||
def test_preserve_auth_passes_agent_token_through(self) -> None:
|
||||
route = Route(host="registry-1.docker.io", preserve_auth=True)
|
||||
addon = _addon(Config(routes=(route,)))
|
||||
flow = _Flow(_Request(
|
||||
host="registry-1.docker.io",
|
||||
headers={"authorization": "Bearer agent-registry-token"},
|
||||
))
|
||||
_run_request(addon, flow)
|
||||
self.assertEqual("Bearer agent-registry-token", flow.request.headers.get("authorization"))
|
||||
self.assertIsNone(flow.response)
|
||||
|
||||
def test_default_route_strips_agent_auth(self) -> None:
|
||||
route = Route(host="registry-1.docker.io")
|
||||
addon = _addon(Config(routes=(route,)))
|
||||
flow = _Flow(_Request(
|
||||
host="registry-1.docker.io",
|
||||
headers={"authorization": "Bearer agent-registry-token"},
|
||||
))
|
||||
_run_request(addon, flow)
|
||||
self.assertIsNone(flow.request.headers.get("authorization"))
|
||||
self.assertIsNone(flow.response)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# git push / fetch over HTTPS
|
||||
|
||||
Reference in New Issue
Block a user