Skip to content

Commit 8d549be

Browse files
committed
Add extra_info field to GetAppKey for auth API pass-through
Add an extra_info string field to GetAppKeyRequest that gets threaded through to BootInfo and forwarded to the auth webhook, allowing custom information to be passed for authorization decisions.
1 parent dda9173 commit 8d549be

4 files changed

Lines changed: 18 additions & 6 deletions

File tree

dstack-util/src/system_setup.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ impl<'a> Stage0<'a> {
851851
.get_app_key(rpc::GetAppKeyRequest {
852852
api_version: 1,
853853
vm_config: self.shared.sys_config.vm_config.clone(),
854+
extra_info: String::new(),
854855
})
855856
.await
856857
.context("Failed to get app key")?;

kms/rpc/proto/kms_rpc.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ package kms;
1111
message GetAppKeyRequest {
1212
uint32 api_version = 1;
1313
string vm_config = 2;
14+
// Custom info to be passed through to the auth API for decision-making.
15+
string extra_info = 3;
1416
}
1517

1618
message AppId {

kms/src/main_service.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,18 @@ impl RpcHandler {
127127

128128
async fn ensure_kms_allowed(&self, vm_config: &str) -> Result<BootInfo> {
129129
let att = self.ensure_attested()?;
130-
self.ensure_app_attestation_allowed(att, true, false, vm_config)
130+
self.ensure_app_attestation_allowed(att, true, false, vm_config, "")
131131
.await
132132
.map(|c| c.boot_info)
133133
}
134134

135-
async fn ensure_app_boot_allowed(&self, vm_config: &str) -> Result<BootConfig> {
135+
async fn ensure_app_boot_allowed(
136+
&self,
137+
vm_config: &str,
138+
extra_info: &str,
139+
) -> Result<BootConfig> {
136140
let att = self.ensure_attested()?;
137-
self.ensure_app_attestation_allowed(att, false, false, vm_config)
141+
self.ensure_app_attestation_allowed(att, false, false, vm_config, extra_info)
138142
.await
139143
}
140144

@@ -191,8 +195,10 @@ impl RpcHandler {
191195
is_kms: bool,
192196
use_boottime_mr: bool,
193197
vm_config_str: &str,
198+
extra_info: &str,
194199
) -> Result<BootConfig> {
195-
let boot_info = build_boot_info(att, use_boottime_mr, vm_config_str)?;
200+
let mut boot_info = build_boot_info(att, use_boottime_mr, vm_config_str)?;
201+
boot_info.extra_info = extra_info.to_string();
196202
let response = self
197203
.state
198204
.config
@@ -244,7 +250,7 @@ impl KmsRpc for RpcHandler {
244250
boot_info,
245251
gateway_app_id,
246252
} = self
247-
.ensure_app_boot_allowed(&request.vm_config)
253+
.ensure_app_boot_allowed(&request.vm_config, &request.extra_info)
248254
.await
249255
.context("App not allowed")?;
250256
let app_id = boot_info.app_id;
@@ -402,7 +408,7 @@ impl KmsRpc for RpcHandler {
402408
.await
403409
.context("Quote verification failed")?;
404410
let app_info = self
405-
.ensure_app_attestation_allowed(&attestation, false, true, &request.vm_config)
411+
.ensure_app_attestation_allowed(&attestation, false, true, &request.vm_config, "")
406412
.await?;
407413
let app_ca = self.derive_app_ca(&app_info.boot_info.app_id)?;
408414
let cert = app_ca

kms/src/main_service/upgrade_authority.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ pub(crate) struct BootInfo {
3737
pub key_provider_info: Vec<u8>,
3838
pub tcb_status: String,
3939
pub advisory_ids: Vec<String>,
40+
#[serde(default, skip_serializing_if = "String::is_empty")]
41+
pub extra_info: String,
4042
}
4143

4244
pub(crate) fn build_boot_info(
@@ -69,6 +71,7 @@ pub(crate) fn build_boot_info(
6971
key_provider_info: app_info.key_provider_info,
7072
tcb_status,
7173
advisory_ids,
74+
extra_info: String::new(),
7275
})
7376
}
7477

0 commit comments

Comments
 (0)