Skip to content

Commit 19bbf51

Browse files
committed
fix(config): restore development endpoint overrides for zerokms_host
The cipherstash-client 0.34 migration removed development.zerokms_host and development.cts_host from DevelopmentConfig. Existing configs with these keys were silently ignored, regressing local and non-prod setups. - Restore zerokms_host and wire through to ZeroKMSBuilder::with_base_url() - Restore cts_host field but warn at startup since the new client library resolves CTS endpoint from credentials automatically - Add url crate dependency for Url::parse
1 parent 32a15c6 commit 19bbf51

File tree

4 files changed

+51
-9
lines changed

4 files changed

+51
-9
lines changed

Cargo.lock

Lines changed: 10 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cipherstash-proxy/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ tracing-subscriber = { workspace = true }
5757
uuid = { version = "1.11.0", features = ["serde", "v4"] }
5858
vitaminc-protected = "0.1.0-pre4.2"
5959
x509-parser = "0.17.0"
60+
url = "2.5.8"
6061

6162

6263
[dev-dependencies]

packages/cipherstash-proxy/src/config/tandem.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ pub struct DevelopmentConfig {
6767

6868
#[serde(default)]
6969
pub enable_mapping_errors: bool,
70+
71+
#[serde(default)]
72+
pub zerokms_host: Option<String>,
73+
74+
#[serde(default)]
75+
pub cts_host: Option<String>,
7076
}
7177

7278
/// Config defaults to a file called `tandem` in the current directory.
@@ -252,6 +258,18 @@ impl TandemConfig {
252258
}
253259
}
254260

261+
pub fn zerokms_host(&self) -> Option<String> {
262+
self.development
263+
.as_ref()
264+
.and_then(|dev| dev.zerokms_host.clone())
265+
}
266+
267+
pub fn cts_host(&self) -> Option<String> {
268+
self.development
269+
.as_ref()
270+
.and_then(|dev| dev.cts_host.clone())
271+
}
272+
255273
pub fn use_structured_logging(&self) -> bool {
256274
matches!(self.log.format, LogFormat::Structured)
257275
}

packages/cipherstash-proxy/src/proxy/zerokms/mod.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,22 @@ use cipherstash_client::{
99
zerokms::{ClientKey, ZeroKMSBuilder},
1010
AutoStrategy, ZeroKMS,
1111
};
12+
use url::Url;
1213

1314
pub type ScopedCipher = cipherstash_client::encryption::ScopedCipher<AutoStrategy>;
1415

1516
pub type ZerokmsClient = ZeroKMS<AutoStrategy, ClientKey>;
1617

1718
pub(crate) fn init_zerokms_client(config: &TandemConfig) -> Result<ZerokmsClient, Error> {
19+
if config.cts_host().is_some() {
20+
tracing::warn!(
21+
target: "config",
22+
"development.cts_host is configured but no longer supported. \
23+
CTS endpoint is now resolved automatically from credentials. \
24+
Remove development.cts_host from your configuration."
25+
);
26+
}
27+
1828
let strategy = AutoStrategy::builder()
1929
.with_access_key(&config.auth.client_access_key)
2030
.with_workspace_crn(config.auth.workspace_crn.clone())
@@ -26,6 +36,17 @@ pub(crate) fn init_zerokms_client(config: &TandemConfig) -> Result<ZerokmsClient
2636

2737
let client_key = config.encrypt.build_client_key()?;
2838

29-
let builder = ZeroKMSBuilder::new(strategy);
39+
let mut builder = ZeroKMSBuilder::new(strategy);
40+
41+
if let Some(zerokms_host) = config.zerokms_host() {
42+
let url = Url::parse(&zerokms_host).map_err(|_| {
43+
Error::from(crate::error::ConfigError::InvalidParameter {
44+
name: "development.zerokms_host".to_string(),
45+
value: zerokms_host,
46+
})
47+
})?;
48+
builder = builder.with_base_url(url);
49+
}
50+
3051
Ok(builder.with_client_key(client_key).build()?)
3152
}

0 commit comments

Comments
 (0)