Skip to content

control-plane: authorize create-data-plane and update-l2-reporting via the request Snapshot (6/7) - #3350

Open
bbartman wants to merge 1 commit into
bmb/2781-stack-5-spec-fetch-policyfrom
bmb/2781-stack-6-admin-endpoints
Open

control-plane: authorize create-data-plane and update-l2-reporting via the request Snapshot (6/7)#3350
bbartman wants to merge 1 commit into
bmb/2781-stack-5-spec-fetch-policyfrom
bmb/2781-stack-6-admin-endpoints

Conversation

@bbartman

Copy link
Copy Markdown
Contributor

Description:

Part 6 of the snapshot-authorization stack (follows the stack-5 spec-fetch-policy PR). Decomposed from #3300.

create-data-plane and update-l2-reporting replace their raw ops/-admin SQL pre-check (select ... from internal.user_roles($1, 'admin') where role_prefix = 'ops/') with the standard Envelope idiom — evaluate_names_authorization + authorization_outcome — extracted as server::authorize_ops_admin. The request's pinned Snapshot now serves both the pre-check and the subsequent ops publication: one request, one authorization view.

Behavior change: a denial under a Snapshot which predates the request is now a 307 AuthZRetry rather than an immediate 403. Correspondingly, the flow-plane-link systemd unit gains curl -L so a redirect can't read as success.

The now-unused .sqlx metadata for the user_roles ops-admin query is removed.

Verified locally: cargo nextest run -p control-plane-api -p agent — 296/296 passing at this branch tip, including new denial tests for both endpoints.

Workflow steps:

Operators calling create-data-plane / update-l2-reporting while their ops/ admin grant is newer than the server's authorization snapshot now receive a retryable 307 instead of a 403; clients following redirects (as flowctl and the updated flow-plane-link unit do) converge without intervention.

Documentation links affected:

None.

Notes for reviewers:

  • Focus first on authorize_ops_admin in crates/control-plane-api/src/server/mod.rs — it is small, and everything else hangs off it.
  • Then the 403-vs-307 semantics: the denial tests in update_l2_reporting.rs and create_data_plane.rs pin the new behavior. Confirm the retry-on-stale outcome is what you want for these admin endpoints.
  • The create_data_plane.rs diff is the largest in the PR but is mostly mechanical: threading the Envelope through, plus new tests. The local/systemd/flow-plane-link@.service change (curl -L) is required by the 307, not optional.

…a the request Snapshot

create-data-plane and update-l2-reporting replace their raw ops/-admin SQL
pre-check (internal.user_roles) with the standard Envelope idiom
(evaluate_names_authorization + authorization_outcome), extracted as
server::authorize_ops_admin. The request's pinned Snapshot now serves both
the pre-check and the ops publication: one request, one authorization view.

A denial under a Snapshot which predates the request is now a 307 AuthZRetry
rather than an immediate 403; the flow-plane-link unit gains curl -L so a
redirect can't read as success.
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