Repository navigation
feat(auth): add discovery-only readers and workspace scopes - #4964
TaylorMutch wants to merge 8 commits into
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
🌿 Preview your docs: https://nvidia-preview-pr-4964.docs.buildwithfern.com/openshell |
18b394a to
ce2a99e
Compare
6d1fb23 to
9b730e6
Compare
ce2a99e to
de94456
Compare
8fef4ac to
8d568c1
Compare
de94456 to
3b08d4c
Compare
8d568c1 to
de13e31
Compare
c35e581 to
caacd27
Compare
de13e31 to
05974d6
Compare
caacd27 to
6e5245e
Compare
05974d6 to
2441c08
Compare
6e5245e to
c37b455
Compare
2441c08 to
1c8e5a4
Compare
c37b455 to
dd566cd
Compare
5ec14a7 to
d4a1630
Compare
00061b6 to
acc3754
Compare
d4a1630 to
a3be433
Compare
Compatibility review (advisory)New or updated breaking changes; see the full report for all findings. 1. rust-sdk — No explicit risk acceptance foundGetServiceRouteSnapshotRequest and WatchServiceRoutesRequest previously allowed exhaustive literals containing only workspace_scope; both now require a workspaces field.
2. typescript-sdk — No explicit risk acceptance foundComplete objects typed as the exported GetServiceRouteSnapshotRequest or WatchServiceRoutesRequest previously needed no workspaces property but now require workspaces: string[].
3. api-behavior — No explicit risk acceptance foundA trusted OU=discovery certificate previously authenticated as an ordinary mTLS user but now becomes a discovery-only principal even when discovery_grants_file is unset.
Review details
Advisory review; publication gates are unchanged. |
a18cc74 to
df8f36d
Compare
2bc4518 to
f79878c
Compare
5a248b8 to
0baec0a
Compare
0b04cc3 to
c0123e1
Compare
78300dd to
d70a49b
Compare
|
/ok to test 36a4c97 |
|
/ok to test fdccee0 |
|
/ok to test fe3b0bb |
|
/ok to test 0309cf2 |
|
/ok to test c12b2fd |
|
/ok to test a72cd2e |
Compatibility review (advisory)New or updated breaking changes; see the full report for all findings. 1. state — No explicit risk acceptance foundPersisted gateway_application_revocation keys change from a digest of the complete JWT to a jwt-prefixed digest of header.payload, without legacy lookup or migration.
Review details
Advisory review; publication gates are unchanged. |
Implement discovery-only certificate grants, bounded single/set/all workspace views, and live grant and certificate expiry checks. Preserve existing user authorization and reject discovery credentials on other APIs and application requests. Closes #4668 Signed-off-by: Taylor Mutch <taylormutch@gmail.com>
Signed-off-by: Taylor Mutch <taylormutch@gmail.com>
Signed-off-by: Taylor Mutch <taylormutch@gmail.com>
Signed-off-by: Taylor Mutch <taylormutch@gmail.com>
Signed-off-by: Taylor Mutch <taylormutch@gmail.com>
Signed-off-by: Taylor Mutch <taylormutch@gmail.com>
Signed-off-by: Taylor Mutch <taylormutch@gmail.com>
Signed-off-by: Taylor Mutch <taylormutch@gmail.com>
| count += page.len(); | ||
| for record in &page { | ||
| bytes = bytes.saturating_add(record.payload.len()); | ||
| if count > crate::auth::discovery::MAX_WORKSPACES || bytes > MAX_BYTES { |
There was a problem hiding this comment.
All-workspaces discovery fails permanently once the gateway has more than 64 workspace rows.
count += page.len() counts raw rows, including terminating workspaces, before the deletion_time filter. So 65 rows makes every all-workspaces snapshot and watch return RESOURCE_EXHAUSTED "workspace discovery limit exceeded". Nothing else limits how many workspaces a gateway can have. The proto comment and configuration.mdx promise "all active workspaces" and "the whole platform", and all-workspaces is the mode the sandbox proxy in #4668 uses.
Suggested fix: count only active workspaces, and bound the combined view by the existing route and byte caps. If a hard workspace ceiling is intended, document it on the request messages, in configuration.mdx, and in the error text, so clients can tell it apart from transient capacity errors.
| /// Configuring grants opts into the restricted OU, never an authority grant. | ||
| /// Missing or unreadable configured files must not restore ordinary mTLS access. | ||
| pub fn is_certificate(identity: &Identity, grants_file: Option<&Path>) -> bool { | ||
| grants_file.is_some() |
There was a problem hiding this comment.
OU=discovery certificates fall back to full mTLS user authority whenever discovery_grants_file is unset.
This happens when an operator removes the key to turn discovery off, when one replica is missing it, or after a rollback. The reader certificate then becomes an ordinary mTLS user. On an mTLS-only gateway with an empty admin_role, authorize_workspace treats every user as platform admin, so a route reader can create sandboxes, exec, and manage providers. Nothing signals the change.
authentication.mdx also says these certificates "cannot act as users or operators, even when ordinary mTLS user authentication … is enabled". That holds only while the grants file is configured.
Suggested fix: always classify OU=discovery from the client CA as a discovery principal, and deny it when no grants file is configured, so it fails closed. If the opt-in behavior is intentional for compatibility, fix the authentication doc and warn against issuing discovery certificates from a CA that pre-upgrade or unconfigured gateways trust with mtls_auth.enabled.
| let mut permits = Vec::new(); | ||
| for workspace in workspaces { | ||
| permits.push(self.share( | ||
| format!("{kind}:workspace:{workspace}"), |
There was a problem hiding this comment.
Multi-workspace watches and snapshots are charged against every selected workspace's per-tenant budget.
admit_workspaces takes a WATCHES_PER_WORKSPACE slot (16), or 8 for snapshots, in each selected workspace. So:
- If one tenant holds 16 watches on its own workspace, the platform proxy's all-workspaces watch gets
RESOURCE_EXHAUSTED. When the workspace set changes, an existing watch ends at its next refresh. Reconnects keep failing for as long as that tenant holds its slots, so "the client can reconnect" does not help. - The reverse also holds: 16 platform watchers use up the slots of every workspace and lock that workspace's users out.
Suggested fix: do not charge per-workspace tenant budgets to multi-workspace callers. Bound them by the caller and global permits plus the existing workspace, route, and byte caps.
| message GetServiceRouteSnapshotRequest { | ||
| openshell.datamodel.v1.WorkspaceSelector workspace_scope = 1; | ||
| // Up to 64 distinct canonical workspace references; exclusive with workspace_scope. | ||
| repeated string workspaces = 2; |
There was a problem hiding this comment.
Design question: is a second, request-level workspace selector needed?
#4668 asks for single-workspace queries plus an explicitly authorized all-workspaces selector. This field adds a third mode on two RPCs that shipped in v0.1.10. It also brings a mutually exclusive selector rule, a one-off exception in proto/README.md, and per-reader workspace lists in the grants file. All of that becomes permanent at the next release.
WorkspaceSelector.all_workspaces already means "all workspaces the caller is authorized to access". Resolving it to the reader's granted set would cover finite grants without a new field. Today a reader granted team-a and team-b that sends all-workspaces gets PERMISSION_DENIED.
Options:
- Drop field 2 and resolve all-workspaces to the granted set.
- If a consumer truly needs subsets, add a list variant to the
WorkspaceSelectoroneof, so the wire enforces exclusivity.
buf breaking against v0.1.10 passes, so this is about API shape, not wire compatibility.
| )); | ||
| } | ||
| let grants: Grants = serde_json::from_slice(&bytes) | ||
| .map_err(|_| Status::unavailable("invalid discovery grants"))?; |
There was a problem hiding this comment.
A broken grants file is invisible to operators, and several boundary cases have no tests.
Operator visibility:
- A missing path, an empty path, or a JSON typo (for example
"all_workspace": true) starts the gateway normally. Every discovery call then returns a genericUNAVAILABLE, because the IO or serde error is discarded bymap_err(|_| …)and nothing is logged. Suggest validating the file at startup and logging awarn!with the specific error on each failed reload, while keeping the client-facing status generic. - Grant denials inside
authorize_selectionemit no audit event: an ungranted workspace, all-workspaces without that grant, or revocation during a watch. The router audits expiry and revocation asMethodNotPermitted.
Tests missing at the gRPC boundary:
- a discovery certificate plus
Authorization: Bearerreturns PermissionDenied; - a certificate with both
OU=operatorandOU=discoverywhileoperator_enabledcannot call operator methods; - the restricted case with
mtls_auth.enabled = true(the TLS test inlib.rsturns mTLS users off when restricted); - a non-admin user, and an empty
admin_role, requesting all workspaces; - a live watch ending when the certificate expires (expiry is only tested through
get_snapshot).
Also, explicit_workspace_and_membership_are_required_and_watch_capacity_is_bounded now asserts is_ok for all-workspaces, which is the opposite of what its name says.
Summary
Allow noninteractive discovery consumers to read routes for one workspace, a selected set, or all active workspaces using narrowly authorized certificate-bound identities.
Based on main at
cb3e701b5. Stacked onfeat/4722-gateway-service-auth/TaylorMutch.Related Issue
Closes #4668. Part of RFC 0017.
Changes
Reserve caller/global capacity before workspace lookups. Bound setup and watch refreshes, including collection and reauthorization, to ten seconds; retain caller reservations when workspace sets change.
Scope discovery-only credentials to the separate
openshell.v1.ServiceDiscoveryservice and apply discovery admission budgets to single, finite, and all-workspace selections.Add administrator-managed discovery grants bound to trusted OU=discovery certificates without operator credentials or workspace membership.
Authorize only snapshot/watch RPCs; deny general resource APIs, mutations, credentials, and supervisor APIs. Discovery-only credentials do not satisfy gateway application authentication when
enable_gateway_service_auth = true; that independent flag defaults to false, preserving legacy application routing.Bound and validate workspace selection and aggregate snapshots, preserving existing user authorization and workspace lifecycle handling.
Reauthorize watches against grant changes and certificate expiry; document file reload, renewal, and revocation propagation.
Release Notes
Compatibility
discovery_grants_fileexplicitly enables discovery-only certificate classification. Without it, an existingOU=discoverycertificate retains ordinary mTLS behavior. Once configured, missing, invalid, or revoked grants fail closed. The added workspace selector fields are additive protobuf fields; ordinary SDK request initialization and single-workspace calls remain compatible.Testing
Current-head GitHub CI is pending. Earlier GKE feature-stack validation has not been repeated for this rebase.
Qualification limits
Live Kubernetes qualification covers dedicated/shared supervisors, graceful shared-owner replacement, gateway outage, and policy isolation. Hashed URL/public-port behavior is covered by unit tests. Whole-node failure, real network partitions, metric-driven HPA, sustained production load, external ingress/DNS automation, and published release artifacts remain unqualified. Installation-status presentation (#4670) remains separate work. The example Kubernetes HTTPRoute controller remains a separate compatibility POC.
Checklist
PR dependency order: #4963 → #4964.