mirror of
https://github.com/NVIDIA/OpenShell.git
synced 2026-10-19 05:50:41 +08:00
* feat(auth): implement RFC 0011 Phase 2 workspace authorization Signed-off-by: Derek Carr <decarr@redhat.com> * fix(auth): address PR review feedback on workspace authorization - Docker e2e: add --health-port and switch readiness probe from `openshell status` to `curl /healthz`, fixing a false-positive readiness check in OIDC mode where the CLI exited 0 without actually contacting the gateway - ListWorkspaces: move membership filtering from post-query N+1 lookups into a SQL EXISTS subquery so pagination applies to the visible set, not the global ordering. Add generic list_with_membership to the persistence layer. - Descriptor validator: reject role/scope fields on unauthenticated and sandbox auth modes, and allow-list workspace_role as user/admin and global_role as platform_admin to catch typos at startup Signed-off-by: Derek Carr <decarr@redhat.com> * fix(server): use authed request in delete telemetry test The workspace authorization added by the Phase 2 auth changes requires a Principal on every delete request. The delete-telemetry test was still using a bare Request::new, so extract_principal failed before the handler could acquire the delete gate, causing a 5-second timeout flake. Signed-off-by: Derek Carr <decarr@redhat.com> * fix(auth): address gator review findings for workspace authorization - Inject unauthenticated-local-dev principal in no-auth gateway mode so handlers that call extract_principal() always find one. - Cap label-selector membership query at MAX_PAGE_SIZE instead of u32::MAX to bound the in-memory read. - Authorize workspace membership before resolving workspace existence in all sandbox RPCs to prevent workspace-name enumeration by non-members. - Remove dead_code allow on AuthorizedWorkspace.workspace now that callers use the normalized name from the authz result. Signed-off-by: Derek Carr <decarr@redhat.com> * fix(auth): close workspace-name oracle and label-selector truncation Swap authorize-before-resolve ordering in 27 handlers across provider.rs, service.rs, policy.rs, and workspace.rs to prevent CWE-203 workspace-name enumeration by non-members. Add combined membership+label SQL query (list_with_membership_and_selector) to both persistence backends so ListWorkspaces with label selectors no longer silently drops results beyond the first page of membership matches. Signed-off-by: Derek Carr <decarr@redhat.com> * test(auth): add non-member rejection and membership+label persistence tests Add comprehensive test coverage for workspace authorization changes: - Non-member rejection tests across all 44 workspace-scoped handlers (sandbox, provider, service, policy, workspace, inference) verifying PERMISSION_DENIED is returned instead of NOT_FOUND to prevent CWE-203 workspace-name oracle - Persistence test for list_with_membership_and_selector verifying SQL-level membership EXISTS + label filtering, multiple predicates, no-match cases, and pagination Signed-off-by: Derek Carr <decarr@redhat.com> * fix(auth): format merged import line in sandbox tests Signed-off-by: Derek Carr <decarr@redhat.com> * fix(auth): address gator re-review findings on workspace authorization - Fix TUI unconditionally setting providers_v2_enabled after provider refresh; read the actual gateway setting via GetGatewayConfig at startup instead - Fix SQLite json_extract with dotted label keys (e.g. example.com/env) by quoting the key in the JSON path - Add authed_request wrappers to upstream OCI identity tests that were missing a principal after rebase - Add test proving GetGatewayConfig is accessible without Platform Admin - Add test for dotted/prefixed Kubernetes-style label key filtering Signed-off-by: Derek Carr <decarr@redhat.com> * fix(auth): address second gator re-review findings - Loosen GetGatewayConfig from platform_admin to scope-only so workspace users can discover providers_v2_enabled during sandbox creation with inferred-provider commands; update proto descriptor, descriptor validation, and RFC 0011 access table - Add validate_label_selector to handle_list_workspaces and escape single quotes in SQLite json_extract interpolation (CWE-89 defense-in-depth) - Re-fetch providers_v2_enabled after TUI gateway switch so the new gateway's capability is reflected - Add e2e test for workspace user with inferred-provider command - Add persistence test for adversarial label keys with SQL injection attempts - Add handler test for invalid label selector rejection in ListWorkspaces Signed-off-by: Derek Carr <decarr@redhat.com> * fix(auth): address third gator review findings - Cap label selector pairs at 64 (CWE-400) to bound SQLite dynamic SQL - Add SCOPE_ONLY_METHODS allowlist for scope-without-role RPCs (CWE-863) - Normalize ID-based data-plane handlers to return NOT_FOUND for unauthorized sandboxes, closing the cross-workspace oracle (CWE-203) - Fix TUI provider profile cache lookup key mismatch for legacy providers with empty profile_workspace - Add whoami to CLI skill reference command tree - Update TUI skill doc with workspace, provider, and settings coverage - Document scope/workspace orthogonality on GetGatewayConfig proto Signed-off-by: Derek Carr <decarr@redhat.com> * fix(auth): extend CWE-203 normalization to policy.rs sandbox handlers GetSandboxConfig and GetSandboxLogs in policy.rs had the same fetch-before-authorize pattern that leaked cross-workspace sandbox existence. Promote fetch_and_authorize_sandbox to pub(super) and use it from both sandbox.rs and policy.rs handlers. Signed-off-by: Derek Carr <decarr@redhat.com> * test(auth): update assertions for CWE-203 sandbox ID normalization Cross-workspace sandbox access via ID-based handlers now returns NOT_FOUND instead of PERMISSION_DENIED to prevent existence inference. Update the unit test and OIDC e2e assertion to match. Signed-off-by: Derek Carr <decarr@redhat.com> * fix(auth): narrow CWE-203 error mapping and correct whoami output formats Only remap PERMISSION_DENIED to NOT_FOUND in fetch_and_authorize_sandbox and RevokeSshSession, letting INTERNAL and UNAUTHENTICATED propagate as-is. Fix whoami --output format values in cli-reference.md to match the actual CLI (table/json/yaml, not text/json). Signed-off-by: Derek Carr <decarr@redhat.com> * fix(ci): share network namespace with Keycloak in containerized CI In GitHub Actions job containers, Docker port publishing lands on the host, not inside the job container. Detect this environment and attach Keycloak to the job container's network namespace instead, with hardened defaults (cap-drop ALL, no-new-privileges, loopback-only listener). Signed-off-by: Derek Carr <decarr@redhat.com> --------- Signed-off-by: Derek Carr <decarr@redhat.com>
174 lines
5.6 KiB
Protocol Buffer
174 lines
5.6 KiB
Protocol Buffer
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
syntax = "proto3";
|
|
|
|
package openshell.inference.v1;
|
|
|
|
import "datamodel.proto";
|
|
import "options.proto";
|
|
|
|
// Inference service provides workspace-scoped inference route configuration and bundle delivery.
|
|
service Inference {
|
|
// Return the resolved inference route bundle for sandbox-local execution.
|
|
rpc GetInferenceBundle(GetInferenceBundleRequest)
|
|
returns (GetInferenceBundleResponse) {
|
|
option (openshell.options.v1.authorization) = {
|
|
auth_mode: "sandbox"
|
|
};
|
|
}
|
|
|
|
// Set the inference route for a workspace.
|
|
//
|
|
// This controls how requests sent to `inference.local` are routed
|
|
// for sandboxes in the specified workspace.
|
|
rpc SetInferenceRoute(SetInferenceRouteRequest)
|
|
returns (SetInferenceRouteResponse) {
|
|
option (openshell.options.v1.authorization) = {
|
|
auth_mode: "bearer"
|
|
scope: "inference:write"
|
|
workspace_role: "admin"
|
|
};
|
|
}
|
|
|
|
// Get the inference route for a workspace.
|
|
rpc GetInferenceRoute(GetInferenceRouteRequest)
|
|
returns (GetInferenceRouteResponse) {
|
|
option (openshell.options.v1.authorization) = {
|
|
auth_mode: "bearer"
|
|
scope: "inference:read"
|
|
workspace_role: "user"
|
|
};
|
|
}
|
|
|
|
// Delete an inference route from a workspace.
|
|
rpc DeleteInferenceRoute(DeleteInferenceRouteRequest)
|
|
returns (DeleteInferenceRouteResponse) {
|
|
option (openshell.options.v1.authorization) = {
|
|
auth_mode: "bearer"
|
|
scope: "inference:write"
|
|
workspace_role: "admin"
|
|
};
|
|
}
|
|
}
|
|
|
|
// Persisted inference route configuration.
|
|
//
|
|
// Only `provider_name` and `model_id` are stored; endpoint, protocols,
|
|
// credentials, and auth style are resolved from the provider at bundle time.
|
|
message InferenceRouteConfig {
|
|
// Provider record name backing this route.
|
|
string provider_name = 1;
|
|
// Model identifier to force on generation calls.
|
|
string model_id = 2;
|
|
// Per-route request timeout in seconds. 0 means use default (60s).
|
|
uint64 timeout_secs = 3;
|
|
}
|
|
|
|
// Storage envelope for a workspace-scoped inference route.
|
|
message InferenceRoute {
|
|
openshell.datamodel.v1.ObjectMeta metadata = 1;
|
|
InferenceRouteConfig config = 2;
|
|
// Monotonic version incremented on every update.
|
|
uint64 version = 3;
|
|
}
|
|
|
|
message SetInferenceRouteRequest {
|
|
// Provider record name to use for credentials + endpoint mapping.
|
|
string provider_name = 1;
|
|
// Model identifier to force on generation calls.
|
|
string model_id = 2;
|
|
// Route name to target. Empty string defaults to "inference.local" (user-facing).
|
|
// Use "sandbox-system" for the sandbox system-level inference route.
|
|
string route_name = 3;
|
|
// Verify the resolved upstream endpoint synchronously before persistence.
|
|
bool verify = 4;
|
|
// Skip synchronous endpoint validation before persistence.
|
|
bool no_verify = 5;
|
|
// Per-route request timeout in seconds. 0 means use default (60s).
|
|
uint64 timeout_secs = 6;
|
|
// Target workspace. Empty string defaults to "default".
|
|
string workspace = 7;
|
|
}
|
|
|
|
message ValidatedEndpoint {
|
|
string url = 1;
|
|
string protocol = 2;
|
|
}
|
|
|
|
message SetInferenceRouteResponse {
|
|
string provider_name = 1;
|
|
string model_id = 2;
|
|
uint64 version = 3;
|
|
// Route name that was configured.
|
|
string route_name = 4;
|
|
// Whether endpoint verification ran as part of this request.
|
|
bool validation_performed = 5;
|
|
// The concrete endpoints that were probed during validation, when available.
|
|
repeated ValidatedEndpoint validated_endpoints = 6;
|
|
// Per-route request timeout in seconds that was persisted.
|
|
uint64 timeout_secs = 7;
|
|
// Workspace the route was configured in.
|
|
string workspace = 8;
|
|
}
|
|
|
|
message GetInferenceRouteRequest {
|
|
// Route name to query. Empty string defaults to "inference.local" (user-facing).
|
|
// Use "sandbox-system" for the sandbox system-level inference route.
|
|
string route_name = 1;
|
|
// Target workspace. Empty string defaults to "default".
|
|
string workspace = 2;
|
|
}
|
|
|
|
message GetInferenceRouteResponse {
|
|
string provider_name = 1;
|
|
string model_id = 2;
|
|
uint64 version = 3;
|
|
// Route name that was queried.
|
|
string route_name = 4;
|
|
// Per-route request timeout in seconds. 0 means default (60s).
|
|
uint64 timeout_secs = 5;
|
|
// Workspace the route belongs to.
|
|
string workspace = 6;
|
|
}
|
|
|
|
message DeleteInferenceRouteRequest {
|
|
// Route name to delete. Empty string defaults to "inference.local" (user-facing).
|
|
// Use "sandbox-system" for the sandbox system-level inference route.
|
|
string route_name = 1;
|
|
// Target workspace. Empty string defaults to "default".
|
|
string workspace = 2;
|
|
}
|
|
|
|
message DeleteInferenceRouteResponse {
|
|
// Whether a route was actually deleted.
|
|
bool deleted = 1;
|
|
}
|
|
|
|
message GetInferenceBundleRequest {}
|
|
|
|
// A single resolved route ready for sandbox-local execution.
|
|
message ResolvedRoute {
|
|
string name = 1;
|
|
string base_url = 2;
|
|
repeated string protocols = 3;
|
|
string api_key = 4 [(openshell.options.v1.secret) = true];
|
|
string model_id = 5;
|
|
string provider_type = 6;
|
|
// Per-route request timeout in seconds. 0 means use default (60s).
|
|
uint64 timeout_secs = 7;
|
|
// When true, the model identifier is embedded in the URL path (e.g. Vertex AI).
|
|
bool model_in_path = 8;
|
|
// Optional override for the request path. When set, replaces the protocol-derived path.
|
|
// An empty string means POST directly to base_url/model_id with no additional path.
|
|
optional string request_path_override = 9;
|
|
}
|
|
|
|
message GetInferenceBundleResponse {
|
|
repeated ResolvedRoute routes = 1;
|
|
// Opaque revision tag for cache freshness checks.
|
|
string revision = 2;
|
|
// Timestamp (epoch ms) when this bundle was generated.
|
|
int64 generated_at_ms = 3;
|
|
}
|