Skip to content

Commit 009dc33

Browse files
committed
refactor(supervisor-network): relocate token_grant and spiffe_endpoint
Upstream's SPIFFE-backed token grant feature landed in crates/openshell-sandbox/src/. After the supervisor split, the L7 enforcement code in supervisor-network calls into token_grant, which would require supervisor-network to depend back on sandbox. Move token_grant.rs and spiffe_endpoint.rs into supervisor-network where the only callers live, add the reqwest and spiffe deps to supervisor-network's Cargo.toml, and drop them from sandbox. Also fix two stale `openshell_core::proto::` self-references in openshell-core (a pre-existing breakage that surfaced once the rest of the merge compiled). Signed-off-by: Radoslav Hubenov <rrhubenov@gmail.com>
1 parent 6f06fb4 commit 009dc33

7 files changed

Lines changed: 11 additions & 7 deletions

File tree

crates/openshell-core/src/grpc_client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ pub struct ProviderEnvironmentResult {
717717
pub environment: HashMap<String, String>,
718718
pub provider_env_revision: u64,
719719
pub credential_expires_at_ms: HashMap<String, i64>,
720-
pub dynamic_credentials: HashMap<String, openshell_core::proto::ProviderProfileCredential>,
720+
pub dynamic_credentials: HashMap<String, crate::proto::ProviderProfileCredential>,
721721
}
722722

723723
impl CachedOpenShellClient {

crates/openshell-core/src/provider_credentials.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const MAX_RETAINED_CREDENTIAL_GENERATIONS: usize = 8;
1313
pub struct ProviderCredentialSnapshot {
1414
pub revision: u64,
1515
pub child_env: HashMap<String, String>,
16-
pub dynamic_credentials: HashMap<String, openshell_core::proto::ProviderProfileCredential>,
16+
pub dynamic_credentials: HashMap<String, crate::proto::ProviderProfileCredential>,
1717
}
1818

1919
#[derive(Debug)]
@@ -34,7 +34,7 @@ impl ProviderCredentialState {
3434
revision: u64,
3535
env: HashMap<String, String>,
3636
credential_expires_at_ms: HashMap<String, i64>,
37-
dynamic_credentials: HashMap<String, openshell_core::proto::ProviderProfileCredential>,
37+
dynamic_credentials: HashMap<String, crate::proto::ProviderProfileCredential>,
3838
) -> Self {
3939
let (child_env, generation_resolver, current_resolver) =
4040
SecretResolver::from_provider_env_for_current_revision(
@@ -82,7 +82,7 @@ impl ProviderCredentialState {
8282
revision: u64,
8383
env: HashMap<String, String>,
8484
credential_expires_at_ms: HashMap<String, i64>,
85-
dynamic_credentials: HashMap<String, openshell_core::proto::ProviderProfileCredential>,
85+
dynamic_credentials: HashMap<String, crate::proto::ProviderProfileCredential>,
8686
) -> usize {
8787
let (child_env, generation_resolver, current_resolver) =
8888
SecretResolver::from_provider_env_for_current_revision(

crates/openshell-supervisor-network/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ ipnet = "2"
2626
miette = { workspace = true }
2727
rcgen = { workspace = true }
2828
regorus = { version = "0.9", default-features = false, features = ["std", "arc", "glob", "yaml"] }
29+
reqwest = { workspace = true }
2930
rustls = { workspace = true }
3031
rustls-pemfile = { workspace = true }
3132
serde = { workspace = true }
3233
serde_json = { workspace = true }
3334
serde_yml = { workspace = true }
3435
sha1 = "0.10"
3536
sha2 = { workspace = true }
37+
spiffe = { workspace = true }
3638
thiserror = { workspace = true }
3739
tokio = { workspace = true }
3840
tokio-rustls = { workspace = true }

crates/openshell-supervisor-network/src/l7/token_grant_injection.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use miette::{Result, miette};
1111
use openshell_core::proto::{ProviderCredentialTokenGrant, ProviderProfileCredential};
1212
use openshell_ocsf::{
1313
ActionId, ActivityId, DispositionId, Endpoint, HttpActivityBuilder, HttpRequest, SeverityId,
14-
StatusId, Url as OcsfUrl, ocsf_emit,
14+
StatusId, Url as OcsfUrl, ctx::ctx as ocsf_ctx, ocsf_emit,
1515
};
1616
use tracing::warn;
1717

@@ -97,7 +97,7 @@ pub async fn inject_if_needed(req: L7Request, ctx: &L7EvalContext) -> Result<L7R
9797
inject_token_grant_header(&req.raw_header, &cred, &access_token)?;
9898
let provider_key = ocsf_message_field(&provider_key);
9999
ocsf_emit!(
100-
HttpActivityBuilder::new(crate::ocsf_ctx())
100+
HttpActivityBuilder::new(ocsf_ctx())
101101
.activity(ActivityId::Other)
102102
.action(ActionId::Allowed)
103103
.disposition(DispositionId::Allowed)
@@ -131,7 +131,7 @@ pub async fn inject_if_needed(req: L7Request, ctx: &L7EvalContext) -> Result<L7R
131131
);
132132
let provider_key = ocsf_message_field(&provider_key);
133133
ocsf_emit!(
134-
HttpActivityBuilder::new(crate::ocsf_ctx())
134+
HttpActivityBuilder::new(ocsf_ctx())
135135
.activity(ActivityId::Fail)
136136
.action(ActionId::Denied)
137137
.disposition(DispositionId::Blocked)

crates/openshell-supervisor-network/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ pub mod policy_local;
1616
pub mod procfs;
1717
pub mod proxy;
1818
pub mod run;
19+
mod spiffe_endpoint;
20+
mod token_grant;
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)