Skip to content

Commit a20d56a

Browse files
committed
fix(deps): bump cipherstash-client from 0.33.2 to 0.34.0-alpha.2
Migrate ZeroKMS initialization from config-builder chain (ConsoleConfig/CtsConfig/ZeroKMSConfig/EnvSource) to the new ZeroKMSBuilder + AutoStrategy API. - Replace AutoRefresh<ServiceCredentials> with AutoStrategy - Use ClientKey::from_hex_v1 for client key construction - Update error variant: zerokms::Error::Credentials -> Error::Auth - Add ZeroKMSBuilderError variant to Error enum - Remove build_zerokms_config (replaced by init_zerokms_client) - Update cts-common to 0.34.0-alpha.3 - Pin vitaminc to 0.1.0-pre4.1 (pre4.2 broke backward compat)
1 parent 7cab49e commit a20d56a

File tree

10 files changed

+678
-293
lines changed

10 files changed

+678
-293
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ debug = true
4343

4444
[workspace.dependencies]
4545
sqltk = { version = "0.10.0" }
46-
cipherstash-client = { version = "0.33.2" }
47-
cts-common = { version = "0.4.1" }
46+
cipherstash-client = { version = "0.34.0-alpha.2" }
47+
cts-common = { version = "0.34.0-alpha.3" }
4848

4949
thiserror = "2.0.9"
5050
tokio = { version = "1.44.2", features = ["full"] }

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ services:
4343
- CS_PROMETHEUS__ENABLED=${CS_PROMETHEUS__ENABLED:-true}
4444
- CS_DATABASE__INSTALL_EQL=true # install EQL into the PostgreSQL database
4545
- CS_DATABASE__INSTALL_EXAMPLE_SCHEMA=true # install example schema into the PostgreSQL database
46+
- CS_CTS_HOST=${CS_CTS_HOST:-}
47+
- CS_ZEROKMS_HOST=${CS_ZEROKMS_HOST:-}
4648
networks:
4749
- cipherstash
4850

packages/cipherstash-proxy-integration/src/generate.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
#[cfg(test)]
22
mod tests {
33
use crate::common::trace;
4-
use cipherstash_client::config::EnvSource;
5-
use cipherstash_client::credentials::auto_refresh::AutoRefresh;
64
use cipherstash_client::encryption::{
75
Encrypted, EncryptedSteVecTerm, JsonIndexer, JsonIndexerOptions, OreTerm, Plaintext,
86
PlaintextTarget, ReferencedPendingPipeline,
97
};
8+
use cipherstash_client::zerokms::{ClientKey, ZeroKMSBuilder};
109
use cipherstash_client::{encryption::ScopedCipher, zerokms::EncryptedRecord};
11-
use cipherstash_client::{ConsoleConfig, CtsConfig, ZeroKMSConfig};
1210
use cipherstash_config::column::{ArrayIndexMode, Index, IndexType};
1311
use cipherstash_config::{ColumnConfig, ColumnType};
1412
use cipherstash_proxy::Identifier;
@@ -129,16 +127,19 @@ mod tests {
129127
// clear().await;
130128
// let client = connect_with_tls(PROXY).await;
131129

132-
let console_config = ConsoleConfig::builder().with_env().build().unwrap();
133-
let cts_config = CtsConfig::builder().with_env().build().unwrap();
134-
let zerokms_config = ZeroKMSConfig::builder()
135-
.add_source(EnvSource::default())
136-
.console_config(&console_config)
137-
.cts_config(&cts_config)
138-
.build_with_client_key()
130+
let client_id: uuid::Uuid = std::env::var("CS_CLIENT_ID")
131+
.expect("CS_CLIENT_ID must be set")
132+
.parse()
133+
.expect("CS_CLIENT_ID must be a valid UUID");
134+
let client_key_hex =
135+
std::env::var("CS_CLIENT_KEY").expect("CS_CLIENT_KEY must be set");
136+
let client_key = ClientKey::from_hex_v1(client_id, &client_key_hex)
137+
.expect("CS_CLIENT_KEY must be valid hex");
138+
let zerokms_client = ZeroKMSBuilder::auto()
139+
.unwrap()
140+
.with_client_key(client_key)
141+
.build()
139142
.unwrap();
140-
let zerokms_client = zerokms_config
141-
.create_client_with_credentials(AutoRefresh::new(zerokms_config.credentials()));
142143

143144
let dataset_id = Uuid::parse_str("295504329cb045c398dc464c52a287a1").unwrap();
144145

packages/cipherstash-proxy/Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,15 @@ tokio-rustls = "0.26.0"
5454
tokio-util = { version = "0.7.13", features = ["rt"] }
5555
tracing = { workspace = true }
5656
tracing-subscriber = { workspace = true }
57+
url = "2"
58+
# Pin vitaminc to 0.1.0-pre4.1 — pre4.2 removed root-level re-exports breaking cts-common
59+
vitaminc = { version = "= 0.1.0-pre4.1", features = ["random", "protected", "encrypt"] }
60+
vitaminc-random = { version = "= 0.1.0-pre4.1" }
61+
vitaminc-protected = { version = "= 0.1.0-pre4.1" }
62+
vitaminc-encrypt = { version = "= 0.1.0-pre4.1" }
63+
vitaminc-traits = { version = "= 0.1.0-pre4.1" }
5764
uuid = { version = "1.11.0", features = ["serde", "v4"] }
5865
x509-parser = "0.17.0"
59-
vitaminc-protected = "0.1.0-pre2"
6066

6167

6268
[dev-dependencies]

packages/cipherstash-proxy/src/error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ pub enum Error {
5454
#[error(transparent)]
5555
ZeroKMS(#[from] ZeroKMSError),
5656

57+
#[error(transparent)]
58+
ZeroKMSBuilder(#[from] cipherstash_client::zerokms::ZeroKMSBuilderError),
59+
5760
#[error("Unknown error")]
5861
Unknown,
5962

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ pub trait EncryptionService: Send + Sync {
168168

169169
#[cfg(test)]
170170
mod tests {
171-
use super::*;
172171
use crate::config::TandemConfig;
173172
use crate::test_helpers::with_no_cs_vars;
174-
use cts_common::WorkspaceId;
173+
174+
use super::zerokms;
175175

176176
fn build_tandem_config(env: Vec<(&str, Option<&str>)>) -> TandemConfig {
177177
with_no_cs_vars(|| {
@@ -195,28 +195,23 @@ mod tests {
195195
}
196196

197197
#[test]
198-
fn build_zerokms_config_with_crn() {
198+
fn init_zerokms_client_with_crn() {
199199
with_no_cs_vars(|| {
200200
let mut env = default_env_vars();
201-
env.push(("CS_CLIENT_ACCESS_KEY", Some("client-access-key")));
201+
env.push(("CS_CLIENT_ACCESS_KEY", Some("CSAKtestKeyId.testKeySecret")));
202202
env.push((
203203
"CS_WORKSPACE_CRN",
204204
Some("crn:ap-southeast-2.aws:3KISDURL3ZCWYZ2O"),
205205
));
206206

207207
let tandem_config = build_tandem_config(env);
208208

209-
let zerokms_config = zerokms::build_zerokms_config(&tandem_config).unwrap();
210-
211-
assert_eq!(
212-
WorkspaceId::try_from("3KISDURL3ZCWYZ2O").unwrap(),
213-
zerokms_config.workspace_id()
209+
let result = zerokms::init_zerokms_client(&tandem_config);
210+
assert!(
211+
result.is_ok(),
212+
"init_zerokms_client failed: {:?}",
213+
result.err()
214214
);
215-
216-
assert!(zerokms_config
217-
.base_url()
218-
.to_string()
219-
.contains("ap-southeast-2.aws"));
220215
});
221216
}
222217
}

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

Lines changed: 32 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,43 @@ mod zerokms;
44
pub use zerokms::ZeroKms;
55

66
use crate::config::TandemConfig;
7-
use cipherstash_client::config::{ConfigError, ZeroKMSConfigWithClientKey};
87
use cipherstash_client::{
9-
config::EnvSource,
10-
credentials::{auto_refresh::AutoRefresh, ServiceCredentials},
11-
zerokms::ClientKey,
12-
ConsoleConfig, CtsConfig, ZeroKMS, ZeroKMSConfig,
8+
zerokms::{ClientKey, ZeroKMSBuilder, ZeroKMSBuilderError},
9+
AutoStrategy, ZeroKMS,
1310
};
1411

15-
pub type ScopedCipher =
16-
cipherstash_client::encryption::ScopedCipher<AutoRefresh<ServiceCredentials>>;
12+
pub type ScopedCipher = cipherstash_client::encryption::ScopedCipher<AutoStrategy>;
1713

18-
pub type ZerokmsClient = ZeroKMS<AutoRefresh<ServiceCredentials>, ClientKey>;
14+
pub type ZerokmsClient = ZeroKMS<AutoStrategy, ClientKey>;
1915

2016
pub(crate) fn init_zerokms_client(
2117
config: &TandemConfig,
22-
) -> Result<ZeroKMS<AutoRefresh<ServiceCredentials>, ClientKey>, ConfigError> {
23-
let zerokms_config = build_zerokms_config(config)?;
24-
25-
Ok(zerokms_config
26-
.create_client_with_credentials(AutoRefresh::new(zerokms_config.credentials())))
27-
}
28-
29-
pub fn build_zerokms_config(
30-
config: &TandemConfig,
31-
) -> Result<ZeroKMSConfigWithClientKey, ConfigError> {
32-
let console_config = ConsoleConfig::builder().with_env().build()?;
33-
34-
let builder = CtsConfig::builder().with_env();
35-
let builder = if let Some(cts_host) = config.cts_host() {
36-
builder.base_url(&cts_host)
37-
} else {
38-
builder
39-
};
40-
let cts_config = builder.build()?;
41-
42-
// Not using with_env because the proxy config should take precedence
43-
let builder = ZeroKMSConfig::builder()
44-
.add_source(EnvSource::default())
45-
.workspace_crn(config.auth.workspace_crn.clone())
46-
.access_key(&config.auth.client_access_key)
47-
.try_with_client_id(&config.encrypt.client_id)?
48-
.try_with_client_key(&config.encrypt.client_key)?
49-
.console_config(&console_config)
50-
.cts_config(&cts_config);
51-
52-
let builder = if let Some(zerokms_host) = config.zerokms_host() {
53-
builder.base_url(zerokms_host)
54-
} else {
55-
builder
56-
};
57-
58-
builder.build_with_client_key()
18+
) -> Result<ZerokmsClient, ZeroKMSBuilderError> {
19+
// 1. Build auth strategy from proxy config
20+
let strategy = AutoStrategy::builder()
21+
.with_access_key(&config.auth.client_access_key)
22+
.with_workspace_crn(config.auth.workspace_crn.clone())
23+
.detect()?;
24+
25+
// 2. Parse client key
26+
let client_id: uuid::Uuid = config
27+
.encrypt
28+
.client_id
29+
.parse()
30+
.expect("client_id must be a valid UUID");
31+
let client_key = ClientKey::from_hex_v1(client_id, &config.encrypt.client_key)
32+
.expect("client_key must be valid hex");
33+
34+
// 3. Build ZeroKMS client (with_base_url must be called before with_client_key)
35+
let mut builder = ZeroKMSBuilder::new(strategy);
36+
37+
// Optional: override ZeroKMS endpoint for development
38+
if let Some(zerokms_host) = config.zerokms_host() {
39+
let url: url::Url = zerokms_host
40+
.parse()
41+
.expect("zerokms_host must be a valid URL");
42+
builder = builder.with_base_url(url);
43+
}
44+
45+
builder.with_client_key(client_key).build()
5946
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl ZeroKms {
137137
}
138138
.into())
139139
}
140-
cipherstash_client::zerokms::Error::Credentials(_) => {
140+
cipherstash_client::zerokms::Error::Auth(_) => {
141141
Err(ZeroKMSError::AuthenticationFailed.into())
142142
}
143143
_ => Err(Error::ZeroKMS(err.into())),

tests/docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ services:
6565
- CS_PROMETHEUS__ENABLED=${CS_PROMETHEUS__ENABLED:-true}
6666
- CS_SERVER__WORKER_THREADS=${CS_SERVER__WORKER_THREADS:-4}
6767
- CS_WORKSPACE_CRN=${CS_WORKSPACE_CRN}
68+
- CS_CTS_HOST=${CS_CTS_HOST:-}
69+
- CS_ZEROKMS_HOST=${CS_ZEROKMS_HOST:-}
6870
- CS_LOG__FORMAT=${CS_LOG__FORMAT:-pretty}
6971
- CS_LOG__LEVEL=${CS_LOG__LEVEL:-debug}
7072
- CS_LOG__PROTOCOL_LEVEL=${CS_LOG__PROTOCOL_LEVEL:-debug}
@@ -109,6 +111,8 @@ services:
109111
- CS_SERVER__REQUIRE_TLS=true
110112
- CS_PROMETHEUS__ENABLED=${CS_PROMETHEUS__ENABLED:-true}
111113
- CS_WORKSPACE_CRN=${CS_WORKSPACE_CRN}
114+
- CS_CTS_HOST=${CS_CTS_HOST:-}
115+
- CS_ZEROKMS_HOST=${CS_ZEROKMS_HOST:-}
112116
- CS_LOG__FORMAT=${CS_LOG__FORMAT:-pretty}
113117
- CS_LOG__LEVEL=${CS_LOG__LEVEL:-debug}
114118
- CS_LOG__PROTOCOL_LEVEL=${CS_LOG__PROTOCOL_LEVEL:-debug}

0 commit comments

Comments
 (0)