2781: Follow up to finish updates to switch over to using the snapshot for auth - #3300
Open
bbartman wants to merge 1 commit into
Open
2781: Follow up to finish updates to switch over to using the snapshot for auth#3300bbartman wants to merge 1 commit into
bbartman wants to merge 1 commit into
Conversation
…on call sites Follows #3155, which moved publication and discover authorization onto the in-memory Snapshot and left five internal.user_roles() call sites for follow-up. This removes all of them, by migration or by deletion. Evolutions: resolve_specs no longer filters by user_roles() in SQL. The query becomes a plain fetch (fetch_evolution_specs) and authorization moves to an in-process wrapper applying the shared spec-fetch policy: admin required per live spec, authoritative denials suppress the live join (preserving the "was never published" surfacing), and provisional denials surface as the retryable AuthorizationSnapshotStale error. Evolution gains a `started_at` anchor, threaded through its live-spec fetches in place of hardcoded None. One intentional delta, pinned by test: the Rust grant walk also traverses role grants whose subject is a parent of the held role, which the one-way SQL walk could not reach. The Rust implementation is authoritative over the legacy SQL semantics. Admin endpoints: create-data-plane and update-l2-reporting replace their raw ops/-admin SQL pre-check 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. Storage-mappings directive: deleted rather than migrated. The GraphQL storage-mapping mutations superseded it on 2026-03-16 (the last routine production application), so the agent-side handler, its Directive variant, and user_has_admin_capability are removed — the latter taking with it a loose-direction prefix comparison that let a sub-prefix admin rewrite the whole tenant's mapping. The still-shared persistence helpers move out of directives/ to control-plane-api/src/storage_mappings.rs. That authorization boundary is now pinned on the GraphQL path instead: sub-prefix and attenuated raw-admin shapes are denied. The spec-fetch policy shared by get_live_specs, get_connected_live_specs, and evolutions::resolve_specs is centralized as Snapshot::spec_fetch_authorization so the three enforcement points cannot drift, and the per-module test Snapshot helpers consolidate into a shared test_support module. The agent crate now sets recursion_limit = 256: laying out the publication pipeline's nested poll future needs a ~130-deep rustc query descent, over the 128 default. Earlier trees compiled only because the since-deleted directive chain happened to pre-compute shared sub-layouts. Tests: evolutions parity/delta/staleness (sqlx), endpoint denial and 307-retry paths (test_server), GraphQL storage-mapping authorization denials, plus the pre-existing suites: 194/194 control-plane-api, 112/112 agent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
control-plane: remove the remaining internal.user_roles() authorization call sites
Follows #3155, which moved publication and discover authorization onto the in-memory Snapshot and left five internal.user_roles() call sites for follow-up. This removes all of them, by migration or by deletion.
Evolutions: resolve_specs no longer filters by user_roles() in SQL. The query becomes a plain fetch (fetch_evolution_specs) and authorization moves to an in-process wrapper applying the shared spec-fetch policy: admin required per live spec, authoritative denials suppress the live join (preserving the "was never published" surfacing), and provisional denials surface as the retryable AuthorizationSnapshotStale error. Evolution gains a
started_atanchor, threaded through its live-spec fetches in place of hardcoded None. One intentional delta, pinned by test: the Rust grant walk also traverses role grants whose subject is a parent of the held role, which the one-way SQL walk could not reach. The Rust implementation is authoritative over the legacy SQL semantics.Admin endpoints: create-data-plane and update-l2-reporting replace their raw ops/-admin SQL pre-check 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 -Lso a redirect can't read as success.Storage-mappings directive: deleted rather than migrated. The GraphQL storage-mapping mutations superseded it on 2026-03-16 (the last routine production application), so the agent-side handler, its Directive variant, and user_has_admin_capability are removed — the latter taking with it a loose-direction prefix comparison that let a sub-prefix admin rewrite the whole tenant's mapping. The still-shared persistence helpers move out of directives/ to control-plane-api/src/storage_mappings.rs. That authorization boundary is now pinned on the GraphQL path instead: sub-prefix and attenuated raw-admin shapes are denied.
The spec-fetch policy shared by get_live_specs, get_connected_live_specs, and evolutions::resolve_specs is centralized as
Snapshot::spec_fetch_authorization so the three enforcement points cannot drift, and the per-module test Snapshot helpers consolidate into a shared test_support module.
The agent crate now sets recursion_limit = 256: laying out the publication pipeline's nested poll future needs a ~130-deep rustc query descent, over the 128 default. Earlier trees compiled only because the since-deleted directive chain happened to pre-compute shared sub-layouts.
Tests: evolutions parity/delta/staleness (sqlx), endpoint denial and 307-retry paths (test_server), GraphQL storage-mapping authorization denials, plus the pre-existing suites: 194/194 control-plane-api, 112/112 agent.
Workflow steps:
(How does one use this feature, and how has it changed)
Documentation links affected:
(list any documentation links that you created, or existing ones that you've identified as needing updates, along with a brief description)
Notes for reviewers:
(anything that might help someone review this PR)