From c12bb516defa51eec9799a96b364872cdf0f8a8f Mon Sep 17 00:00:00 2001 From: Shiju Date: Fri, 4 Dec 2026 21:30:03 +0530 Subject: [PATCH] refactor(gateway): move the sandbox identity provider interface to core SandboxIdentityProvider lived in openshell-spiffe, which cannot depend on core. The trait therefore carried an associated error type, and every use set it to TokenGrantFailure. Its return type and method were also named after SPIFFE: SandboxJwtSvid, its spiffe_id field, and fetch_jwt_svid. Move the trait to openshell_core::sandbox_identity and return TokenGrantFailure directly. The interface now names no identity system: issue_assertion returns a SandboxIdentityAssertion with an identity field. openshell-spire documents that its assertion is a JWT-SVID for the sandbox's stable SPIFFE ID. openshell-spiffe keeps SPIFFE ID mapping and claim parsing, and no longer needs async-trait. Behavior is unchanged. SPIRE stays the only implementation. Signed-off-by: Shiju --- AGENTS.md | 4 +- Cargo.lock | 1 - crates/openshell-core/README.md | 10 +++ crates/openshell-core/src/lib.rs | 1 + crates/openshell-core/src/sandbox_identity.rs | 78 +++++++++++++++++++ crates/openshell-server/README.md | 11 +-- .../src/grpc/provider/access_token.rs | 28 +++---- crates/openshell-server/src/lib.rs | 10 +-- crates/openshell-server/src/spiffe_broker.rs | 5 +- crates/openshell-spiffe/Cargo.toml | 3 +- crates/openshell-spiffe/README.md | 6 -- crates/openshell-spiffe/src/lib.rs | 69 +--------------- crates/openshell-spire/README.md | 6 +- crates/openshell-spire/src/broker.rs | 8 +- crates/openshell-spire/src/lib.rs | 12 +-- e2e/rust/Cargo.lock | 1 - examples/governance-interceptor/Cargo.lock | 1 - examples/isolation-backend-v8/Cargo.lock | 1 - .../Cargo.lock | 1 - tests/suites/conformance/Cargo.lock | 1 - tests/suites/continuity/Cargo.lock | 1 - tests/suites/drivers/docker/Cargo.lock | 1 - tests/suites/drivers/podman/Cargo.lock | 1 - tests/suites/features/Cargo.lock | 1 - tests/support/Cargo.lock | 1 - tests/testkit/Cargo.lock | 1 - 26 files changed, 136 insertions(+), 127 deletions(-) create mode 100644 crates/openshell-core/src/sandbox_identity.rs diff --git a/AGENTS.md b/AGENTS.md index 0133dd3de3..0b3fcff4ab 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -49,8 +49,8 @@ Do not rely on this file for a full inventory. The detailed public and contribut | `crates/openshell-gateway/` | Gateway binary composition | Links selected first-party compute drivers into the backend-agnostic server registry | | `crates/openshell-sdk/` | Shared client SDK | Async Rust gateway client (gRPC transport, TLS, OIDC refresh, edge tunnel); consumed by CLI, TUI, and `@openshell/sdk` | | `crates/openshell-providers/` | Provider management | Credential provider backends | -| `crates/openshell-spiffe/` | SPIFFE identity types | Dependency-light SPIFFE ID mapping, claim parsing, and the sandbox identity provider interface | -| `crates/openshell-spire/` | SPIRE adapter | Gateway-owned SPIFFE Broker API client that issues and verifies stable sandbox JWT-SVIDs | +| `crates/openshell-spiffe/` | SPIFFE identity types | Dependency-light SPIFFE ID mapping and claim parsing | +| `crates/openshell-spire/` | SPIRE adapter | Gateway-owned SPIFFE Broker API client that issues and verifies stable sandbox JWT-SVIDs; implements the sandbox identity provider interface in `openshell-core` | | `crates/openshell-tui/` | Terminal UI | Ratatui-based dashboard for monitoring | | `crates/openshell-driver-launch/` | Driver launch protocol | `DriverLaunch` `GetLaunchInfo`/`Configure` service and the `Deferred` wrapper for launched compute drivers | | `crates/openshell-driver-sdk/` | Launched-driver SDK | Stdin table reader, start-up exit codes, staged network-trust loader, telemetry and admission conversion, and gateway context | diff --git a/Cargo.lock b/Cargo.lock index 528d92a719..ac0b24cf1e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5791,7 +5791,6 @@ dependencies = [ name = "openshell-spiffe" version = "0.0.0" dependencies = [ - "async-trait", "base64 0.22.1", "serde", "serde_json", diff --git a/crates/openshell-core/README.md b/crates/openshell-core/README.md index b3d9a50349..4ab5c6a766 100644 --- a/crates/openshell-core/README.md +++ b/crates/openshell-core/README.md @@ -104,3 +104,13 @@ Use `openshell_core::proto_struct` when crossing between `serde_json` values and `prost_types::{Struct, Value}`. Both conversion directions live in this module; JSON-to-protobuf conversion is fallible so callers cannot silently replace an unrepresentable number. + +## Sandbox Identity + +`sandbox_identity::SandboxIdentityProvider` is the gateway's interface for +obtaining a `SandboxIdentityAssertion`: a signed assertion of a sandbox's stable +identity, verified for one audience. The gateway passes its persisted driver +runtime identity as the workload reference. The implementation decides the +assertion's format and how it is verified. The interface reports the sanitized +`TokenGrantFailure`, and `SandboxIdentityAssertion` omits the token from `Debug` +output. `openshell-spire` implements the interface. diff --git a/crates/openshell-core/src/lib.rs b/crates/openshell-core/src/lib.rs index 4bc48e01d1..1d0825268d 100644 --- a/crates/openshell-core/src/lib.rs +++ b/crates/openshell-core/src/lib.rs @@ -62,6 +62,7 @@ pub mod resource_admission; pub mod rpc_error; pub mod sandbox_env; pub mod sandbox_generation; +pub mod sandbox_identity; pub mod sandbox_session; pub mod sandbox_update; pub mod secrets; diff --git a/crates/openshell-core/src/sandbox_identity.rs b/crates/openshell-core/src/sandbox_identity.rs new file mode 100644 index 0000000000..17ed953686 --- /dev/null +++ b/crates/openshell-core/src/sandbox_identity.rs @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! The gateway's source of sandbox identities for brokered provider tokens. +//! +//! The provider broker asks a [`SandboxIdentityProvider`] for a signed +//! assertion of a sandbox's identity and presents it to the token service. +//! The implementation decides the assertion's format and how it is verified. +//! `openshell-spire` implements the interface. + +use std::fmt; + +use crate::token_grant_failure::TokenGrantFailure; + +/// A signed assertion of a sandbox's stable identity, verified for one +/// audience. +#[derive(Clone)] +pub struct SandboxIdentityAssertion { + /// The stable identity the assertion was issued and verified for. + pub identity: String, + /// The signed assertion. It is a credential and never printed. + pub token: String, + /// The verified expiry, in Unix seconds. + pub expires_at: i64, +} + +impl fmt::Debug for SandboxIdentityAssertion { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("SandboxIdentityAssertion") + .field("identity", &self.identity) + .field("token", &"[REDACTED]") + .field("expires_at", &self.expires_at) + .finish() + } +} + +/// Source of verified sandbox identity assertions for the gateway's provider +/// broker. +/// +/// The gateway authorizes the sandbox session and the provider credential +/// before each request; implementations own issuance and verification only. +#[async_trait::async_trait] +pub trait SandboxIdentityProvider: fmt::Debug + Send + Sync { + /// Issue an assertion for `audience` whose identity is exactly the stable + /// identity of `sandbox_id` under `gateway_id`. + /// `runtime_identity` is the compute driver's immutable runtime reference + /// persisted by the gateway. It must never come from a workload request; + /// adapters use it to bind issuance to the attested backing object. + /// + /// # Errors + /// + /// Fails when issuance or verification fails, or when the IDs cannot + /// form a stable identity. The failure must not carry credentials or + /// upstream diagnostics. + async fn issue_assertion( + &self, + gateway_id: &str, + sandbox_id: &str, + audience: &str, + runtime_identity: &str, + ) -> Result; +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn sandbox_identity_assertion_debug_redacts_the_token() { + let assertion = SandboxIdentityAssertion { + identity: "openshell/gateway/gw/sandbox/sb".into(), + token: "secret-token".into(), + expires_at: 1, + }; + let printed = format!("{assertion:?}"); + assert!(!printed.contains("secret-token")); + assert!(printed.contains("sandbox/sb")); + } +} diff --git a/crates/openshell-server/README.md b/crates/openshell-server/README.md index 7789a767ae..7e8ae4b6ef 100644 --- a/crates/openshell-server/README.md +++ b/crates/openshell-server/README.md @@ -373,8 +373,8 @@ revision, the matched configured key and grant, and the subject token, which is resolved before every lookup so its revocation or rotation also applies to cached tokens. Concurrent misses for one cache key wait for a single acquisition, then use its cached token. A token is served until the usual skew -before the earliest of its `expires_in`, its JWT `exp`, and the session, SVID, -and subject expiries, and no longer than the default cache lifetime; a +before the earliest of its `expires_in`, its JWT `exp`, and the session, +identity assertion, and subject expiries, and no longer than the default cache lifetime; a configured cache TTL can only shorten that. The response reports the remaining lifetime. The session is authorized again around each SPIRE and token-service call. A cache hit and a fresh token then pass the same final @@ -383,9 +383,10 @@ authorized. A fresh token is cached only after that check. Startup validates the Broker API settings, and gateway state construction builds the [`openshell-spire`](../openshell-spire/README.md) adapter once and returns a configuration error when they are invalid. The broker depends only on -[`openshell-spiffe`](../openshell-spiffe/README.md)'s `SandboxIdentityProvider` -with `TokenGrantFailure` as its error, which returns a JWT-SVID -verified for the requested gateway, sandbox, and audience; each cache miss +[`openshell-core`](../openshell-core/README.md)'s `SandboxIdentityProvider`, +which returns an identity assertion +verified for the requested gateway, sandbox, and audience. With the SPIRE +adapter the assertion is a JWT-SVID; each cache miss fetches a new SVID and the agent's current JWT bundle. SPIRE attests the referenced Sandbox resource UID and enforces the gateway's `impersonate-via-spire` authorization for that object. diff --git a/crates/openshell-server/src/grpc/provider/access_token.rs b/crates/openshell-server/src/grpc/provider/access_token.rs index a65d10cf52..8e26f71af6 100644 --- a/crates/openshell-server/src/grpc/provider/access_token.rs +++ b/crates/openshell-server/src/grpc/provider/access_token.rs @@ -19,8 +19,8 @@ use openshell_core::proto::{ GetSandboxProviderAccessTokenRequest, GetSandboxProviderAccessTokenResponse, ProviderCredentialTokenGrant, }; +use openshell_core::sandbox_identity::SandboxIdentityProvider; use openshell_core::token_grant_failure::BROKERED_TOKEN_GATEWAY_DEADLINE; -use openshell_spiffe::SandboxIdentityProvider; use std::time::Duration; static ACCESS_TOKENS: LazyLock = LazyLock::new(IntermediateTokenCache::new); @@ -382,7 +382,7 @@ async fn acquire( state: &ServerState, bearer: &str, session: &AuthenticatedSandboxSession, - identity: &dyn SandboxIdentityProvider, + identity: &dyn SandboxIdentityProvider, gateway_id: &str, grant: &ProviderCredentialTokenGrant, subject: Option<&Subject>, @@ -406,8 +406,8 @@ async fn acquire( .get(crate::compute::COMPUTE_RUNTIME_IDENTITY_ANNOTATION) }) .map_or("", String::as_str); - let svid = identity - .fetch_jwt_svid( + let assertion = identity + .issue_assertion( gateway_id, session.sandbox_id.as_str(), &audience, @@ -435,7 +435,7 @@ async fn acquire( client_assertion_type: &grant.client_assertion_type, subject_token: &subject.value, subject_token_type: &subject.token_type, - audience: &svid.spiffe_id, + audience: &assertion.identity, scopes: &[], requested_token_type: &grant.requested_token_type, }, @@ -447,7 +447,7 @@ async fn acquire( client, &grant.token_endpoint, &TokenExchangeParams { - client_assertion: &svid.token, + client_assertion: &assertion.token, client_assertion_type: &grant.client_assertion_type, subject_token: &intermediate.access_token, subject_token_type: oauth::ACCESS_TOKEN_TYPE, @@ -464,7 +464,7 @@ async fn acquire( client, &grant.token_endpoint, &oauth::TokenGrantParams { - client_assertion: &svid.token, + client_assertion: &assertion.token, client_assertion_type: &grant.client_assertion_type, audience: &grant.audience, scopes: &grant.scopes, @@ -478,7 +478,7 @@ async fn acquire( let identity_expires_at_ms = session .expires_at .saturating_mul(1000) - .min(svid.expires_at.saturating_mul(1000)) + .min(assertion.expires_at.saturating_mul(1000)) .min(subject_expiry.unwrap_or(i64::MAX)); let serve_until_ms = serve_until_ms(&token, ttl_override, obtained_at_ms, identity_expires_at_ms).ok_or_else( @@ -498,12 +498,12 @@ async fn acquire( /// or `None` when it is already expired. /// /// The issuer's `expires_in`, a parseable JWT `exp` of the access token, and -/// the session, SVID, and subject expiries each bound the token; `exp` can -/// only shorten it. Serving stops the usual skew before the earliest bound, -/// after at least one second, and never later than the default cache lifetime -/// (whose fallback applies when the issuer omits `expires_in`). A configured -/// cache TTL may shorten that lifetime but, unlike a dedicated supervisor's -/// cache, never extends it. +/// the session, identity assertion, and subject expiries each bound the token; +/// `exp` can only shorten it. Serving stops the usual skew before the earliest +/// bound, after at least one second, and never later than the default cache +/// lifetime (whose fallback applies when the issuer omits `expires_in`). A +/// configured cache TTL may shorten that lifetime but, unlike a dedicated +/// supervisor's cache, never extends it. fn serve_until_ms( token: &oauth::OAuthTokenResponse, ttl_override: Option, diff --git a/crates/openshell-server/src/lib.rs b/crates/openshell-server/src/lib.rs index dd0ef762cc..3fa2a0640b 100644 --- a/crates/openshell-server/src/lib.rs +++ b/crates/openshell-server/src/lib.rs @@ -74,14 +74,13 @@ use hyper_util::{ service::TowerToHyperService, }; use openshell_core::net::set_tcp_nodelay_best_effort; +use openshell_core::sandbox_identity::SandboxIdentityProvider; use openshell_core::telemetry::TelemetryComputeDriver; -use openshell_core::token_grant_failure::TokenGrantFailure; use openshell_core::{Config, Error, NetworkSupervisorTrustBundle, ObjectLabels, Result}; use openshell_extension_core::{ BearerTokenSlot, ExtensionAudience, ExtensionCallerKind, ExtensionKind, MAX_EXTENSION_TOKEN_TTL, }; use openshell_ocsf::{ConfigStateChangeBuilder, SeverityId, StateId, StatusId}; -use openshell_spiffe::SandboxIdentityProvider; use openshell_supervisor_middleware::MiddlewareRegistry; use std::collections::{BTreeMap, HashMap}; use std::io::ErrorKind; @@ -453,10 +452,9 @@ pub struct ServerState { /// on demand when the user source is configured. pub(crate) provider_profile_sources: provider_profile_sources::ProviderProfileSources, - /// Source of sandbox JWT-SVIDs for brokered provider tokens, built once - /// from the SPIRE broker settings. `None` when disabled. - pub(crate) sandbox_identity: - Option>>, + /// Source of sandbox identity assertions for brokered provider tokens, + /// built once from the SPIRE broker settings. `None` when disabled. + pub(crate) sandbox_identity: Option>, /// OIDC admin role name for workspace-level authorization. /// Empty when OIDC is not configured — `authorize_workspace()` treats diff --git a/crates/openshell-server/src/spiffe_broker.rs b/crates/openshell-server/src/spiffe_broker.rs index 886b2b4902..5deb8848c8 100644 --- a/crates/openshell-server/src/spiffe_broker.rs +++ b/crates/openshell-server/src/spiffe_broker.rs @@ -9,8 +9,7 @@ use std::sync::Arc; use openshell_core::config::{Config, SpiffeBrokerConfig}; -use openshell_core::token_grant_failure::TokenGrantFailure; -use openshell_spiffe::SandboxIdentityProvider; +use openshell_core::sandbox_identity::SandboxIdentityProvider; /// Check the broker settings `config` enables without building them. /// @@ -29,7 +28,7 @@ pub fn validate_config(config: &Config) -> Result<(), String> { /// Rejects what [`validate_config`] rejects. pub fn sandbox_identity_provider( config: &Config, -) -> Result>>, String> { +) -> Result>, String> { let Some(broker) = enabled(config)? else { return Ok(None); }; diff --git a/crates/openshell-spiffe/Cargo.toml b/crates/openshell-spiffe/Cargo.toml index 258e062841..40559ef96c 100644 --- a/crates/openshell-spiffe/Cargo.toml +++ b/crates/openshell-spiffe/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "openshell-spiffe" -description = "SPIFFE identity types, parsing, and sandbox identity provider interface for OpenShell" +description = "SPIFFE identity types and parsing for OpenShell" version.workspace = true edition.workspace = true rust-version.workspace = true @@ -11,7 +11,6 @@ license.workspace = true repository.workspace = true [dependencies] -async-trait = "0.1" base64 = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } diff --git a/crates/openshell-spiffe/README.md b/crates/openshell-spiffe/README.md index ac13366591..455887b4a9 100644 --- a/crates/openshell-spiffe/README.md +++ b/crates/openshell-spiffe/README.md @@ -12,12 +12,6 @@ depend on it without a cycle. be SPIFFE path segments; nothing is encoded, so distinct IDs always map to distinct SPIFFE IDs. `SpiffeBrokerConfig::validate` in `openshell-core` uses it. -- `SandboxIdentityProvider` is the gateway's interface for obtaining a - `SandboxJwtSvid` verified for that stable identity and one audience, using - the gateway's persisted driver runtime identity as the workload reference. The - error is an associated type: the SPIRE adapter in `openshell-spire` uses the - sanitized `TokenGrantFailure`. `SandboxJwtSvid` omits the token from `Debug` - output. - `workload_api_endpoint`, `trust_domain`, and `is_spiffe_path_segment` handle Workload API endpoints and SPIFFE ID parts. - `parse_unverified_jwt_svid_claims` decodes JWT-SVID claims without checking diff --git a/crates/openshell-spiffe/src/lib.rs b/crates/openshell-spiffe/src/lib.rs index 07ea123e43..0556ecc3aa 100644 --- a/crates/openshell-spiffe/src/lib.rs +++ b/crates/openshell-spiffe/src/lib.rs @@ -3,11 +3,10 @@ //! Shared SPIFFE helpers used by the gateway and sandbox supervisor. //! -//! Protocol types, unverified claim parsing, stable sandbox identity mapping, -//! and the sandbox identity provider interface. Signature verification and -//! SPIRE access belong to the crates that implement the interface. +//! Protocol types, unverified claim parsing, and stable sandbox identity +//! mapping. This crate verifies no signatures and has no Workload API or +//! Broker API client. -use std::fmt; use std::path::Path; use base64::Engine as _; @@ -144,56 +143,6 @@ impl SandboxSpiffeIdPrefix { } } -/// A JWT-SVID verified for a sandbox's stable SPIFFE ID and one audience. -#[derive(Clone)] -pub struct SandboxJwtSvid { - /// The stable SPIFFE ID the token was issued and verified for. - pub spiffe_id: String, - /// The signed token. It is a credential and never printed. - pub token: String, - /// The verified `exp` claim, in Unix seconds. - pub expires_at: i64, -} - -impl fmt::Debug for SandboxJwtSvid { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("SandboxJwtSvid") - .field("spiffe_id", &self.spiffe_id) - .field("token", &"[REDACTED]") - .field("expires_at", &self.expires_at) - .finish() - } -} - -/// Source of verified sandbox JWT-SVIDs for the gateway's provider broker. -/// -/// The gateway authorizes the sandbox session and the provider credential -/// before each request; implementations own issuance and verification only. -#[async_trait::async_trait] -pub trait SandboxIdentityProvider: fmt::Debug + Send + Sync { - /// Failure the implementation reports. It must not carry credentials or - /// upstream diagnostics. - type Error; - - /// Obtain a JWT-SVID for `audience` whose identity is exactly the stable - /// SPIFFE ID of `sandbox_id` under `gateway_id`. - /// `runtime_identity` is the compute driver's immutable runtime reference - /// persisted by the gateway. It must never come from a workload request; - /// adapters use it to bind issuance to the attested backing object. - /// - /// # Errors - /// - /// Fails when issuance or verification fails, or when the IDs cannot - /// form a stable SPIFFE ID. - async fn fetch_jwt_svid( - &self, - gateway_id: &str, - sandbox_id: &str, - audience: &str, - runtime_identity: &str, - ) -> Result; -} - /// A non-empty SPIFFE path segment other than `.` and `..`. #[must_use] pub fn is_spiffe_path_segment(segment: &str) -> bool { @@ -313,18 +262,6 @@ mod tests { } } - #[test] - fn sandbox_jwt_svid_debug_redacts_the_token() { - let svid = SandboxJwtSvid { - spiffe_id: "spiffe://example.org/openshell/gateway/gw/sandbox/sb".into(), - token: "secret-token".into(), - expires_at: 1, - }; - let printed = format!("{svid:?}"); - assert!(!printed.contains("secret-token")); - assert!(printed.contains("sandbox/sb")); - } - #[test] fn trust_domain_extracts_domain_from_spiffe_id() { assert_eq!( diff --git a/crates/openshell-spire/README.md b/crates/openshell-spire/README.md index e6f73f67df..946d939135 100644 --- a/crates/openshell-spire/README.md +++ b/crates/openshell-spire/README.md @@ -3,8 +3,10 @@ SPIFFE Broker API adapter for gateway-owned sandbox identities. Only the gateway obtains sandbox JWT-SVIDs; supervisors receive final provider tokens. -`SpireSandboxIdentity` implements `SandboxIdentityProvider` using -`openshell_core::token_grant_failure::TokenGrantFailure` as its error type. +`SpireSandboxIdentity` implements +`openshell_core::sandbox_identity::SandboxIdentityProvider`. The +`SandboxIdentityAssertion` it returns is a JWT-SVID, and its `identity` is the +sandbox's stable SPIFFE ID. Startup selects it from `[openshell.gateway.spiffe_broker]`. The provider-token broker owns session authorization, provider configuration, exchange, and caching. diff --git a/crates/openshell-spire/src/broker.rs b/crates/openshell-spire/src/broker.rs index e58d9cf14e..ce3f675952 100644 --- a/crates/openshell-spire/src/broker.rs +++ b/crates/openshell-spire/src/broker.rs @@ -6,10 +6,10 @@ use crate::{configuration_failure, identity_rejected}; use hyper_util::rt::TokioIo; use openshell_core::config::SpiffeBrokerConfig; +use openshell_core::sandbox_identity::SandboxIdentityAssertion; use openshell_core::token_grant_failure::{ TokenGrantFailure, TokenGrantFailureKind, TokenGrantStage, WORKLOAD_IDENTITY_CALL_TIMEOUT, }; -use openshell_spiffe::SandboxJwtSvid; use prost::Message; use rustls::{ RootCertStore, @@ -272,7 +272,7 @@ pub async fn fetch( runtime: &str, expected: &str, audience: &str, -) -> Result { +) -> Result { let reference = reference(runtime)?; tokio::time::timeout(WORKLOAD_IDENTITY_CALL_TIMEOUT, async { let mut grpc = tonic::client::Grpc::new(channel(config, endpoint).await?); @@ -337,8 +337,8 @@ pub async fn fetch( if verified.spiffe_id().to_string() != expected { return Err(identity_rejected()); } - Ok(SandboxJwtSvid { - spiffe_id: expected.to_string(), + Ok(SandboxIdentityAssertion { + identity: expected.to_string(), token: svid.svid.clone(), expires_at: verified.claims().exp(), }) diff --git a/crates/openshell-spire/src/lib.rs b/crates/openshell-spire/src/lib.rs index c19f8d430e..0ca9bd9e4b 100644 --- a/crates/openshell-spire/src/lib.rs +++ b/crates/openshell-spire/src/lib.rs @@ -6,13 +6,17 @@ mod broker; use openshell_core::config::SpiffeBrokerConfig; +use openshell_core::sandbox_identity::{SandboxIdentityAssertion, SandboxIdentityProvider}; use openshell_core::token_grant_failure::{ TokenGrantFailure, TokenGrantFailureKind, TokenGrantStage, }; -use openshell_spiffe::{SandboxIdentityProvider, SandboxJwtSvid, SandboxSpiffeIdPrefix}; +use openshell_spiffe::SandboxSpiffeIdPrefix; /// SPIRE Broker API adapter. Each acquisition gets current Workload API /// credentials and verifies an exact sandbox identity and audience. +/// +/// The assertion it issues is a JWT-SVID, and the assertion's identity is the +/// sandbox's stable SPIFFE ID. #[derive(Debug)] pub struct SpireSandboxIdentity { config: SpiffeBrokerConfig, @@ -37,15 +41,13 @@ impl SpireSandboxIdentity { #[async_trait::async_trait] impl SandboxIdentityProvider for SpireSandboxIdentity { - type Error = TokenGrantFailure; - - async fn fetch_jwt_svid( + async fn issue_assertion( &self, gateway_id: &str, sandbox_id: &str, audience: &str, runtime_identity: &str, - ) -> Result { + ) -> Result { let expected = self .prefix .sandbox_spiffe_id(gateway_id, sandbox_id) diff --git a/e2e/rust/Cargo.lock b/e2e/rust/Cargo.lock index 927d67f502..b375760a5c 100644 --- a/e2e/rust/Cargo.lock +++ b/e2e/rust/Cargo.lock @@ -2125,7 +2125,6 @@ dependencies = [ name = "openshell-spiffe" version = "0.0.0" dependencies = [ - "async-trait", "base64 0.22.1", "serde", "serde_json", diff --git a/examples/governance-interceptor/Cargo.lock b/examples/governance-interceptor/Cargo.lock index 6cd788fab3..638aa54ab7 100644 --- a/examples/governance-interceptor/Cargo.lock +++ b/examples/governance-interceptor/Cargo.lock @@ -2122,7 +2122,6 @@ dependencies = [ name = "openshell-spiffe" version = "0.0.0" dependencies = [ - "async-trait", "base64 0.22.1", "serde", "serde_json", diff --git a/examples/isolation-backend-v8/Cargo.lock b/examples/isolation-backend-v8/Cargo.lock index 83e5efad20..da418afdcb 100644 --- a/examples/isolation-backend-v8/Cargo.lock +++ b/examples/isolation-backend-v8/Cargo.lock @@ -2446,7 +2446,6 @@ dependencies = [ name = "openshell-spiffe" version = "0.0.0" dependencies = [ - "async-trait", "base64 0.22.1", "serde", "serde_json", diff --git a/examples/supervisor-middleware-content-guard/Cargo.lock b/examples/supervisor-middleware-content-guard/Cargo.lock index 8e5b9905f3..47a251b789 100644 --- a/examples/supervisor-middleware-content-guard/Cargo.lock +++ b/examples/supervisor-middleware-content-guard/Cargo.lock @@ -2236,7 +2236,6 @@ dependencies = [ name = "openshell-spiffe" version = "0.0.0" dependencies = [ - "async-trait", "base64 0.22.1", "serde", "serde_json", diff --git a/tests/suites/conformance/Cargo.lock b/tests/suites/conformance/Cargo.lock index e5c661cd03..b0f5e61b40 100644 --- a/tests/suites/conformance/Cargo.lock +++ b/tests/suites/conformance/Cargo.lock @@ -2459,7 +2459,6 @@ dependencies = [ name = "openshell-spiffe" version = "0.0.0" dependencies = [ - "async-trait", "base64 0.22.1", "serde", "serde_json", diff --git a/tests/suites/continuity/Cargo.lock b/tests/suites/continuity/Cargo.lock index 247abaf95f..1331a08b6e 100644 --- a/tests/suites/continuity/Cargo.lock +++ b/tests/suites/continuity/Cargo.lock @@ -2438,7 +2438,6 @@ dependencies = [ name = "openshell-spiffe" version = "0.0.0" dependencies = [ - "async-trait", "base64 0.22.1", "serde", "serde_json", diff --git a/tests/suites/drivers/docker/Cargo.lock b/tests/suites/drivers/docker/Cargo.lock index f0c6a25878..85b891a524 100644 --- a/tests/suites/drivers/docker/Cargo.lock +++ b/tests/suites/drivers/docker/Cargo.lock @@ -2447,7 +2447,6 @@ dependencies = [ name = "openshell-spiffe" version = "0.0.0" dependencies = [ - "async-trait", "base64 0.22.1", "serde", "serde_json", diff --git a/tests/suites/drivers/podman/Cargo.lock b/tests/suites/drivers/podman/Cargo.lock index 23ca62b1d0..814a1d1b8f 100644 --- a/tests/suites/drivers/podman/Cargo.lock +++ b/tests/suites/drivers/podman/Cargo.lock @@ -2439,7 +2439,6 @@ dependencies = [ name = "openshell-spiffe" version = "0.0.0" dependencies = [ - "async-trait", "base64 0.22.1", "serde", "serde_json", diff --git a/tests/suites/features/Cargo.lock b/tests/suites/features/Cargo.lock index 643d93dec3..968b0c2fe9 100644 --- a/tests/suites/features/Cargo.lock +++ b/tests/suites/features/Cargo.lock @@ -2906,7 +2906,6 @@ dependencies = [ name = "openshell-spiffe" version = "0.0.0" dependencies = [ - "async-trait", "base64 0.22.1", "serde", "serde_json", diff --git a/tests/support/Cargo.lock b/tests/support/Cargo.lock index f195215961..18118f799f 100644 --- a/tests/support/Cargo.lock +++ b/tests/support/Cargo.lock @@ -2592,7 +2592,6 @@ dependencies = [ name = "openshell-spiffe" version = "0.0.0" dependencies = [ - "async-trait", "base64 0.22.1", "serde", "serde_json", diff --git a/tests/testkit/Cargo.lock b/tests/testkit/Cargo.lock index fb8c7589a8..2a4bb98501 100644 --- a/tests/testkit/Cargo.lock +++ b/tests/testkit/Cargo.lock @@ -2430,7 +2430,6 @@ dependencies = [ name = "openshell-spiffe" version = "0.0.0" dependencies = [ - "async-trait", "base64 0.22.1", "serde", "serde_json",