fix(egress+orchestrator): inject per-bottle auth tokens in the shared gateway
The cut-over dropped the per-bottle token flow, so an authed egress route on the shared gateway failed with 'env var EGRESS_TOKEN_0 is unset' — the gateway reads the token from its env, but a shared gateway has no per-bottle env. Now the bottle's egress auth tokens travel to the gateway over /resolve and the addon injects from them, mirroring what the per-bottle sidecar's env did: - launch resolves the token values from the host env and hands them to the orchestrator, which holds them IN MEMORY (keyed by bottle_id, never written to the registry DB) and serves them on /resolve; - PolicyResolver.resolve_policy_and_bottle_id + resolve_client_context now return the token map alongside policy + bottle_id (one round-trip); - the egress addon overlays the process env with the bottle's tokens per request and uses that env for auth injection AND DLP — the agent never sees the credential. Secrets stay off disk (validated: /resolve returns the token, the registry DB does not contain it). SecretProvider (#355) is the future hardening. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WBMWTEtQdJ4W5UrWuLHCck
This commit is contained in:
@@ -92,6 +92,18 @@ class TestOrchestrator(unittest.TestCase):
|
||||
assert got is not None
|
||||
self.assertEqual('{"routes":[]}', got.policy)
|
||||
|
||||
def test_tokens_held_in_memory_and_cleared_on_teardown(self) -> None:
|
||||
rec = self.orch.launch_bottle("10.243.0.5", tokens={"EGRESS_TOKEN_0": "sk"})
|
||||
self.assertEqual({"EGRESS_TOKEN_0": "sk"}, self.orch.tokens_for(rec.bottle_id))
|
||||
# not persisted in the registry (redacted record has no tokens field)
|
||||
self.assertNotIn("tokens", rec.redacted())
|
||||
self.orch.teardown_bottle(rec.bottle_id)
|
||||
self.assertEqual({}, self.orch.tokens_for(rec.bottle_id))
|
||||
|
||||
def test_tokens_default_empty(self) -> None:
|
||||
rec = self.orch.launch_bottle("10.243.0.6")
|
||||
self.assertEqual({}, self.orch.tokens_for(rec.bottle_id))
|
||||
|
||||
def test_set_policy_live_reload(self) -> None:
|
||||
rec = self.orch.launch_bottle("10.243.0.3")
|
||||
self.assertTrue(self.orch.set_policy(rec.bottle_id, '{"x":1}'))
|
||||
|
||||
Reference in New Issue
Block a user