Skip to content

feat(auth): add discovery-only readers and workspace scopes - #4964

Open
TaylorMutch wants to merge 8 commits into
feat/4722-gateway-service-auth/TaylorMutchfrom
feat/4668-discovery-readers/TaylorMutch
Open

TaylorMutch wants to merge 8 commits into
feat/4722-gateway-service-auth/TaylorMutchfrom
feat/4668-discovery-readers/TaylorMutch

Conversation

@TaylorMutch

@TaylorMutch TaylorMutch commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

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 on feat/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.ServiceDiscovery service 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_file explicitly enables discovery-only certificate classification. Without it, an existing OU=discovery certificate 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

  • Rebased authentication branch: 2,942 server tests passed; 52 ignored.
  • Combined auth/discovery-reader stack: 2,953 server tests passed; 52 ignored.
  • Combined stack: 317 supervisor tests and 77 Rust SDK client-mock tests passed.
  • Supervisor coverage includes reserved-cookie filtering through native gRPC and HTTP/2-to-HTTP/1.1 forwarding, preserving ordinary application cookies.
  • All 148 gateway Helm configuration tests passed.
  • Strict server/supervisor all-target Clippy, Rust formatting, and whitespace checks passed.
  • Range-diff confirms runtime patches are unchanged; the discovery schema inventory fingerprint was refreshed for main.

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

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Relevant implementation, configuration, and API documentation updated

PR dependency order: #4963 → #4964.

@copy-pr-bot

copy-pr-bot Bot commented Oct 27, 2026

Copy link
Copy Markdown

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.

@github-actions

Copy link
Copy Markdown

@TaylorMutch
TaylorMutch added this pull request to stack #4965 October 27, 2026 05:46
@TaylorMutch
TaylorMutch removed this pull request from stack #4965 October 27, 2026 05:47
@TaylorMutch
TaylorMutch force-pushed the feat/4722-gateway-service-auth/TaylorMutch branch from 18b394a to ce2a99e Compare October 27, 2026 06:24
@TaylorMutch
TaylorMutch force-pushed the feat/4668-discovery-readers/TaylorMutch branch from 6d1fb23 to 9b730e6 Compare October 27, 2026 06:24
@TaylorMutch
TaylorMutch force-pushed the feat/4722-gateway-service-auth/TaylorMutch branch from ce2a99e to de94456 Compare October 27, 2026 06:25
@TaylorMutch
TaylorMutch force-pushed the feat/4668-discovery-readers/TaylorMutch branch 2 times, most recently from 8fef4ac to 8d568c1 Compare October 27, 2026 06:46
@TaylorMutch
TaylorMutch force-pushed the feat/4722-gateway-service-auth/TaylorMutch branch from de94456 to 3b08d4c Compare October 27, 2026 06:46
@TaylorMutch
TaylorMutch force-pushed the feat/4668-discovery-readers/TaylorMutch branch from 8d568c1 to de13e31 Compare October 27, 2026 21:06
@TaylorMutch
TaylorMutch force-pushed the feat/4722-gateway-service-auth/TaylorMutch branch 2 times, most recently from c35e581 to caacd27 Compare October 28, 2026 17:05
@TaylorMutch
TaylorMutch force-pushed the feat/4668-discovery-readers/TaylorMutch branch from de13e31 to 05974d6 Compare October 28, 2026 17:05
@TaylorMutch
TaylorMutch force-pushed the feat/4722-gateway-service-auth/TaylorMutch branch from caacd27 to 6e5245e Compare October 28, 2026 22:52
@TaylorMutch
TaylorMutch force-pushed the feat/4668-discovery-readers/TaylorMutch branch from 05974d6 to 2441c08 Compare October 28, 2026 22:52
@TaylorMutch
TaylorMutch force-pushed the feat/4722-gateway-service-auth/TaylorMutch branch from 6e5245e to c37b455 Compare October 29, 2026 01:16
@TaylorMutch
TaylorMutch force-pushed the feat/4668-discovery-readers/TaylorMutch branch from 2441c08 to 1c8e5a4 Compare October 29, 2026 01:16
@TaylorMutch
TaylorMutch force-pushed the feat/4722-gateway-service-auth/TaylorMutch branch from c37b455 to dd566cd Compare October 30, 2026 17:57
@TaylorMutch
TaylorMutch force-pushed the feat/4668-discovery-readers/TaylorMutch branch 2 times, most recently from 5ec14a7 to d4a1630 Compare October 30, 2026 18:13
@TaylorMutch
TaylorMutch force-pushed the feat/4722-gateway-service-auth/TaylorMutch branch from 00061b6 to acc3754 Compare October 30, 2026 21:11
@TaylorMutch
TaylorMutch force-pushed the feat/4668-discovery-readers/TaylorMutch branch from d4a1630 to a3be433 Compare October 30, 2026 21:11
@purp purp added topic:documentation Architecture docs, READMEs, project website updates, and automated documentation generation. topic:security Vulnerability management, security analysis/auditing, bypass detection, and abuse prevention. labels Nov 15, 2026
@TaylorMutch
TaylorMutch marked this pull request as ready for review November 16, 2026 19:22
@github-actions

Copy link
Copy Markdown

Compatibility review (advisory)

New or updated breaking changes; see the full report for all findings.

1. rust-sdk — No explicit risk acceptance found

GetServiceRouteSnapshotRequest and WatchServiceRoutesRequest previously allowed exhaustive literals containing only workspace_scope; both now require a workspaces field.

  • Impact: Downstream Rust callers and mocks constructing these public raw::proto messages fail with missing-field errors, although Default-based construction and generated server-trait signatures remain compatible.
  • Action: Preserve the existing request structs in this patch by exposing multi-workspace requests separately, or defer the break to a minor release with notice and guidance to add workspaces: Vec::new() or ..Default::default().
  • PR: feat(auth): add discovery-only readers and workspace scopes #4964

2. typescript-sdk — No explicit risk acceptance found

Complete objects typed as the exported GetServiceRouteSnapshotRequest or WatchServiceRoutesRequest previously needed no workspaces property but now require workspaces: string[].

  • Impact: Consumers constructing complete typed discovery requests or mock messages stop type-checking, while schema-based initialization and ordinary partial RPC arguments remain compatible.
  • Action: Preserve the existing exported message shapes in this patch, or defer their expansion to a minor release with notice and guidance to add workspaces: [] or use create(RequestSchema, init).
  • PR: feat(auth): add discovery-only readers and workspace scopes #4964

3. api-behavior — No explicit risk acceptance found

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

  • Impact: Existing CLI and SDK consumers using such certificates receive PERMISSION_DENIED for ordinary authenticated RPCs, and presenting a valid bearer credential alongside the certificate no longer restores access.
  • Action: Make discovery-only certificate classification explicitly opt-in while preserving existing mTLS identities in v0.1.9, and reserve any unconditional OU restriction for a minor release with certificate-reissuance guidance.
  • PR: feat(auth): add discovery-only readers and workspace scopes #4964
Review details
  • Execution: complete
  • Candidate: PR #4964 (9f7482585aeaaac43a6efc96a2d3d01411f86986)
  • Baseline: 5f664899ec7e4475e15fa71ec50e3b8c01a141d2 (5f664899ec7e4475e15fa71ec50e3b8c01a141d2)
  • Reviewed: rust-sdk, python-sdk, typescript-sdk, api-behavior, cli, configuration, policy, helm, state

Advisory review; publication gates are unchanged.

Branch check run

@TaylorMutch
TaylorMutch force-pushed the feat/4668-discovery-readers/TaylorMutch branch from a18cc74 to df8f36d Compare November 16, 2026 19:55
@TaylorMutch
TaylorMutch force-pushed the feat/4722-gateway-service-auth/TaylorMutch branch 2 times, most recently from 2bc4518 to f79878c Compare November 16, 2026 21:48
@TaylorMutch
TaylorMutch force-pushed the feat/4668-discovery-readers/TaylorMutch branch 2 times, most recently from 5a248b8 to 0baec0a Compare November 16, 2026 22:27
@TaylorMutch
TaylorMutch force-pushed the feat/4722-gateway-service-auth/TaylorMutch branch 2 times, most recently from 0b04cc3 to c0123e1 Compare November 17, 2026 00:48
@TaylorMutch
TaylorMutch force-pushed the feat/4668-discovery-readers/TaylorMutch branch 2 times, most recently from 78300dd to d70a49b Compare November 17, 2026 23:14
@TaylorMutch

Copy link
Copy Markdown
Contributor Author

/ok to test 36a4c97

@TaylorMutch

Copy link
Copy Markdown
Contributor Author

/ok to test fdccee0

@TaylorMutch

Copy link
Copy Markdown
Contributor Author

/ok to test fe3b0bb

@TaylorMutch

Copy link
Copy Markdown
Contributor Author

/ok to test 0309cf2

@TaylorMutch

Copy link
Copy Markdown
Contributor Author

/ok to test c12b2fd

@TaylorMutch

Copy link
Copy Markdown
Contributor Author

/ok to test a72cd2e

@github-actions

Copy link
Copy Markdown

Compatibility review (advisory)

New or updated breaking changes; see the full report for all findings.

1. state — No explicit risk acceptance found

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

  • Impact: Existing token revocations stop blocking application access after upgrade, including browser sessions using those tokens, and mixed-version replicas disagree about revocation.
  • Action: Read both revocation-key formats and preserve backward-compatible writes during rolling upgrades, retaining legacy checks until their tokens expire and documenting the rollout.
  • PR: feat(auth): add discovery-only readers and workspace scopes #4964
Review details
  • Execution: complete
  • Candidate: PR #4964 (01436d7fe2d30b2260d8cc6dc0d28776f4eff864)
  • Baseline: b9c3cd74f0e5400fc020b79ab56cef16b94a93b9 (b9c3cd74f0e5400fc020b79ab56cef16b94a93b9)
  • Reviewed: rust-sdk, python-sdk, api-behavior, cli, configuration, policy, helm, state

Advisory review; publication gates are unchanged.

Branch check run

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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread proto/openshell.proto
message GetServiceRouteSnapshotRequest {
openshell.datamodel.v1.WorkspaceSelector workspace_scope = 1;
// Up to 64 distinct canonical workspace references; exclusive with workspace_scope.
repeated string workspaces = 2;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 WorkspaceSelector oneof, 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"))?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 generic UNAVAILABLE, because the IO or serde error is discarded by map_err(|_| …) and nothing is logged. Suggest validating the file at startup and logging a warn! with the specific error on each failed reload, while keeping the client-facing status generic.
  • Grant denials inside authorize_selection emit no audit event: an ungranted workspace, all-workspaces without that grant, or revocation during a watch. The router audits expiry and revocation as MethodNotPermitted.

Tests missing at the gRPC boundary:

  • a discovery certificate plus Authorization: Bearer returns PermissionDenied;
  • a certificate with both OU=operator and OU=discovery while operator_enabled cannot call operator methods;
  • the restricted case with mtls_auth.enabled = true (the TLS test in lib.rs turns 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.

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

area:enterprise Authentication, multitenancy, gateway interceptors, FIPS, and enterprise requirements. topic:api Public APIs, gRPC/protobuf, SDK interfaces, versioning, compatibility, and API design standards. topic:authnz Authentication, authorization, identity, sessions, credential protection, and policy integrity. topic:security Vulnerability management, security analysis/auditing, bypass detection, and abuse prevention.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants