Repository navigation
feat(gateway): take the control token on the older /svc REST state routes - #822
Conversation
58f18f0 to
f3ff3b3
Compare
ab1fd64 to
c614945
Compare
The legacy REST helpers (reset_via_rest, add_via_rest, export_state, reset) take headers and default to the run's grant. Legacy loads, resets, state reads and streamed snapshots send the deployment's token. A grant covers a URL only when it resolves under the grant's address, by whole path segments. A legacy reset refused with 401 or 403 raises instead of falling back to the MCP tool.
…utes LEGACY_STATE_ROUTES lists the older state routes a backing server serves beside its data plane. On a gateway with a control token, every /svc/<key>/ route takes the token for each of them, after path normalization. A site's /website route serves none of them. A gateway booted without a token behaves as before.
A site at http://host/base receives ../base/x as /base/x, which is /x under its base. The route's path check now reads the path the site receives against the site's own address, decoded, with the base path taken off, so it matches the same paths the site's card names.
c614945 to
475e53d
Compare
|
🤖 Automated Claude routine — Env Pod PR Context Review. This is a bot, not Edgar Arakelyan; not a human review. Context from outside this diff, in case it hasn't crossed paths yet: #776 (open since Nov 18, still open) changes the same two halves as this stack, and neither PR references the other.
Two places the two route contracts disagree, both checkable from the diffs:
Also worth noting for sequencing: this PR's description pins the gateway half to merge last, after the caller rollout, or untokened callers get 401. #776 carries both halves in one PR with no such guard, so if it merges first the gateway half ships ahead of that rollout. No action implied — just surfacing that these are competing implementations so the pod can pick one before either lands. Generated by Claude Code |
# Conflicts: # src/agent_env/env/legacy_protocol.py # src/agent_env/task_step/task_steps/snapshot_env.py # tst/unit/env/test_env.py
Merge order for this pair:
Why
The gateway's data plane routes take the control token. This PR applies the same rule to the older REST state routes behind
/svc/<key>/, so every state-changing or state-reading route behind the gateway uses one auth scheme.What changed
LEGACY_STATE_ROUTESingateway/constants.pylists the older state routes:/api/reset,/api/add,/api/bridge/apply,/export-state,/export-snapshot,/snapshot-dirty,/reset-memory,/validate-rows,/api/_state,/api/_resetand/api/debug/seed.token_pathsadds them to every/svc/<key>/route. Matching reusesreaches, so paths are normalized before the check./website/<site>/route serves none of these routes. The harness reaches sites through/svc/<site>/.run_bundle_built_envs_test.pyembeds sends the run's grant to/export-state.Rollout
Verification
tst/unit/env/gateway/control_token_test.py: 354 passed.tst/unit/env/gateway: 1356 passed.ruff checkis clean.

Confidence Score: 5/5
The code appears safe to merge once the required caller deployments are complete.Summary
The gateway now requires its control token for the listed legacy state routes behind
/svc. With a token configured, website HTTP and WebSocket routes refuse those paths./svc/<key>/now need the control token./website/routes now block legacy state paths on tokened gateways.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Request for a legacy state route] --> B{Gateway has a token?} B -->|No| C[Existing behavior] B -->|Yes| D{Route} D -->|/svc| E{Correct token?} E -->|Yes| F[Forward to backing service] E -->|No| G[401] D -->|/website| H[404 before forwarding]Reviews (9) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile