Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,973 changes: 1,499 additions & 474 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ axum-server = { version = "0.8.0", features = ["tls-openssl"] }
chrono = "0.4.44"
clap = { version = "4.6.1", features = ["derive"] }
clevis-pin-trustee-lib = { git = "https://github.com/latchset/clevis-pin-trustee" }
compute-pcrs-lib = { git = "https://github.com/trusted-execution-clusters/compute-pcrs" }
compute-pcrs-lib = { git = "https://github.com/trusted-execution-clusters/compute-pcrs", rev = "1e7b9f74206e436d1426c335e30b2f1a6bd1681e"}
env_logger = { version = "0.11.10", default-features = false }
http = "1.4.1"
ignition-config = "0.6.1"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ OPERATOR_IMAGE=$(REGISTRY)/trusted-cluster-operator:$(TAG)
COMPUTE_PCRS_IMAGE=$(REGISTRY)/compute-pcrs:$(TAG)
REG_SERVER_IMAGE=$(REGISTRY)/registration-server:$(TAG)
ATTESTATION_KEY_REGISTER_IMAGE=$(REGISTRY)/attestation-key-register:$(TAG)
TRUSTEE_IMAGE ?= quay.io/trusted-execution-clusters/key-broker-service:v0.17.0
TRUSTEE_IMAGE ?= quay.io/trusted-execution-clusters/key-broker-service:v0.20.0
TEST_IMAGE ?= quay.io/trusted-execution-clusters/fedora-coreos-kubevirt:20260225
# tagged as 42.20251012.2.0
APPROVED_IMAGE ?= quay.io/trusted-execution-clusters/fedora-coreos@sha256:6997f51fd27d1be1b5fc2e6cc3ebf16c17eb94d819b5d44ea8d6cf5f826ee773
Expand Down
5 changes: 5 additions & 0 deletions operator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ serde_json.workspace = true
thiserror = "2.0.18"
tokio.workspace = true
toml = "1.1.2"
kbs-client = {git = "https://github.com/iroykaufman/trustee.git", branch = "kbs-client-native-tls", default-features = false, features = ["native-tls"] }
jsonwebtoken = { version = "10.4.0", default-features = false, features = [
"aws_lc_rs",
"use_pem",
] }

[dev-dependencies]
http.workspace = true
Expand Down
16 changes: 11 additions & 5 deletions operator/src/kbs-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
sockets = ["0.0.0.0:8080"]

[admin]
type = "DenyAll"
authorization_mode = "AuthenticatedAuthorization"

[admin.authentication.bearer_jwt]
identity_providers = [
{ public_key_uri = "/key/public.pub" }
]

[admin.authorization.regex_acl]
acls = [{ role = "admin", allowed_endpoints = "^/kbs/.+$" }]

[attestation_token]
insecure_key = true
attestation_token_type = "CoCo"
insecure_header_jwk = true

[attestation_service]
type = "coco_as_builtin"
Expand All @@ -30,8 +37,7 @@ policy_engine = "opa"

[[plugins]]
name = "resource"
type = "LocalFs"
dir_path = "/opt/trustee/kbs-repository"
storage_backend_type = "kvstorage"

[policy_engine]
policy_path = "/opt/trustee/policy.rego"
12 changes: 10 additions & 2 deletions operator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ mod register_server;
#[cfg(test)]
mod test_utils;
mod trustee;

use crate::conditions::*;
use jsonwebtoken::crypto::CryptoProvider;
use operator::*;

/// Default version tag for operator-managed component images
Expand Down Expand Up @@ -200,6 +200,12 @@ async fn install_trustee_configuration(
Err(e) => error!("Failed to create the attestation policy configmap: {e}"),
}

match trustee::generate_trustee_auth_keys_secret(client.clone(), owner_reference.clone()).await
{
Ok(_) => info!("Generate auth keys for the KBS API",),
Err(e) => error!("Failed to create the auth keys: {e}"),
}

let kbs_port = cluster.spec.trustee_kbs_port;
match trustee::generate_kbs_service(client.clone(), owner_reference.clone(), kbs_port).await {
Ok(_) => info!("Generate the KBS service"),
Expand Down Expand Up @@ -293,7 +299,8 @@ async fn install_attestation_key_register(
#[tokio::main]
async fn main() -> Result<()> {
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();

// Prevent conflict issues with AWS-LC provider and rust crypto by installing the default provider explicitly
let _ = CryptoProvider::install_default(&jsonwebtoken::crypto::aws_lc::DEFAULT_PROVIDER);
let kube_client = Client::try_default().await?;
info!("trusted execution clusters operator",);
let cl: Api<TrustedExecutionCluster> = Api::default_namespaced(kube_client.clone());
Expand All @@ -303,6 +310,7 @@ async fn main() -> Result<()> {
attestation_key_register::launch_ak_controller(kube_client.clone()).await;
attestation_key_register::launch_machine_ak_controller(kube_client.clone()).await;
attestation_key_register::launch_secret_ak_controller(kube_client.clone()).await;
trustee::launch_trustee_sync_controller(kube_client.clone()).await;

let ctx = Arc::new(ClusterContext {
client: kube_client,
Expand Down
12 changes: 7 additions & 5 deletions operator/src/register_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ async fn keygen_reconcile(
async {
let owner_reference = generate_owner_reference(&Arc::unwrap_or_clone(machine))?;
trustee::generate_secret(kube_client.clone(), id, owner_reference).await?;
trustee::mount_secret(kube_client, id).await
trustee::send_secret(kube_client, id).await
}
.await
.map(|_| Action::await_change())
Expand Down Expand Up @@ -185,10 +185,12 @@ async fn keygen_reconcile(
}
}

trustee::unmount_secret(kube_client, id)
.await
.map(|_| Action::await_change())
.map_err(|e| finalizer::Error::<ControllerError>::CleanupFailed(e.into()))
trustee::delete_secret(kube_client, id).await.map_err(|e| {
finalizer::Error::<ControllerError>::CleanupFailed(
anyhow!("failed to delete secret for machine {id}: {e}").into(),
)
})?;
Ok(Action::await_change())
}
}
})
Expand Down
1 change: 1 addition & 0 deletions operator/src/tpm.rego
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ executables := 3 if {
input.tpm.pcr04 in query_reference_value("tpm_pcr4")
input.tpm.pcr14 in query_reference_value("tpm_pcr14")

input.tpm.ak_public in query_reference_value("trusted_aks")
}
# Azure SNP vTPM validation
executables := 3 if {
Expand Down
Loading
Loading