Skip to content

feat(gateway): take the control token on the older /svc REST state routes - #822

Draft
andrewpark-scaleai wants to merge 1 commit into
andrewpark/legacy-rest-callers-send-tokenfrom
andrewpark/legacy-rest-routes-take-token
Draft

andrewpark-scaleai wants to merge 1 commit into
andrewpark/legacy-rest-callers-send-tokenfrom
andrewpark/legacy-rest-routes-take-token

Conversation

@andrewpark-scaleai

Copy link
Copy Markdown
Contributor

DO NOT MERGE until the scaleapi and synthetic-pipelines caller PRs are merged and deployed. Once this ships in a gateway image, a caller of these routes that does not send the control token gets a 401.

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_ROUTES in gateway/constants.py lists the older state routes: /api/reset, /api/add, /api/bridge/apply, /export-state, /export-snapshot, /snapshot-dirty, /reset-memory, /validate-rows, /api/_state, /api/_reset and /api/debug/seed.
  • token_paths adds them to every /svc/<key>/ route. Matching reuses reaches, so paths are normalized before the check.
  • A site's /website/<site>/ route serves none of these routes. The harness reaches sites through /svc/<site>/.
  • A gateway booted without a token behaves as before.
  • The verifier that run_bundle_built_envs_test.py embeds 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 check is clean.
  • Integration tests on local Docker through a token-booted gateway pass.

…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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant