Skip to content

Commit 3c2adee

Browse files
remove hardcoded backend name, fixes key rotation with fastly
1 parent b6d0057 commit 3c2adee

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

crates/common/src/fastly_storage.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ impl FastlySecretStore {
7676
pub struct FastlyApiClient {
7777
api_key: Vec<u8>,
7878
base_url: String,
79+
backend_name: String,
7980
}
8081

8182
impl FastlyApiClient {
@@ -84,7 +85,7 @@ impl FastlyApiClient {
8485
}
8586

8687
pub fn from_secret_store(store_name: &str, key_name: &str) -> Result<Self, TrustedServerError> {
87-
ensure_backend_from_url("https://api.fastly.com").map_err(|e| {
88+
let backend_name = ensure_backend_from_url("https://api.fastly.com").map_err(|e| {
8889
TrustedServerError::Configuration {
8990
message: format!("Failed to ensure API backend: {}", e),
9091
}
@@ -93,9 +94,15 @@ impl FastlyApiClient {
9394
let secret_store = FastlySecretStore::new(store_name);
9495
let api_key = secret_store.get(key_name)?;
9596

97+
log::info!(
98+
"FastlyApiClient initialized with backend: {}",
99+
backend_name
100+
);
101+
96102
Ok(Self {
97103
api_key,
98104
base_url: "https://api.fastly.com".to_string(),
105+
backend_name,
99106
})
100107
}
101108

@@ -132,7 +139,7 @@ impl FastlyApiClient {
132139
.with_body(body_content);
133140
}
134141

135-
request.send("backend_https_api_fastly_com").map_err(|e| {
142+
request.send(&self.backend_name).map_err(|e| {
136143
TrustedServerError::Configuration {
137144
message: format!("Failed to send API request: {}", e),
138145
}

0 commit comments

Comments
 (0)