Skip to content

Commit 35d2923

Browse files
lcianclaude
andcommitted
feat(snapshots): Support dedicated objectstore auth token
Bump objectstore-client to 0.1.6 and use the dedicated auth token from ObjectstoreUploadOptions when available, instead of always reusing the Sentry auth token. The Sentry token is now passed as a Bearer authorization header via configure_reqwest for request verification. This resolves the TODO in the previous implementation and decouples objectstore authentication from Sentry authentication. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1854c4e commit 35d2923

4 files changed

Lines changed: 25 additions & 36 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ java-properties = "2.0.0"
4444
lazy_static = "1.4.0"
4545
libc = "0.2.139"
4646
log = { version = "0.4.17", features = ["std"] }
47-
objectstore-client = { version = "0.1.2" , default-features = false, features = ["native-tls"] }
47+
objectstore-client = { version = "0.1.6" , default-features = false, features = ["native-tls"] }
4848
open = "3.2.0"
4949
parking_lot = "0.12.1"
5050
percent-encoding = "2.2.0"

src/api/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,5 +2065,6 @@ pub struct SnapshotsUploadOptions {
20652065
pub struct ObjectstoreUploadOptions {
20662066
pub url: String,
20672067
pub scopes: Vec<(String, String)>,
2068+
pub auth_token: Option<String>,
20682069
pub expiration_policy: String,
20692070
}

src/commands/build/snapshots.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,25 @@ fn upload_images(
295295
let expiration = ExpirationPolicy::from_str(&options.objectstore.expiration_policy)
296296
.context("Failed to parse expiration policy from upload options")?;
297297

298-
let client = ClientBuilder::new(options.objectstore.url)
299-
.token({
300-
// TODO: replace with auth from `ObjectstoreUploadOptions` when appropriate
301-
let auth = match authenticated_api.auth() {
302-
Auth::Token(token) => token.raw().expose_secret().to_owned(),
303-
};
304-
auth
298+
let mut builder = ClientBuilder::new(options.objectstore.url);
299+
if let Some(token) = options.objectstore.auth_token {
300+
builder = builder.token(token);
301+
}
302+
303+
let sentry_token = match authenticated_api.auth() {
304+
Auth::Token(token) => token.raw().expose_secret().to_owned(),
305+
};
306+
let sentry_token = format!("Bearer {sentry_token}")
307+
.parse()
308+
// Ignore original error to avoid leaking the token (even though it's invalid)
309+
.map_err(|_| anyhow::anyhow!("Invalid auth token"))?;
310+
let client = builder
311+
.configure_reqwest(|r| {
312+
let mut headers = http::HeaderMap::new();
313+
headers.insert(http::header::AUTHORIZATION, sentry_token);
314+
r.connect_timeout(Duration::from_secs(10))
315+
.default_headers(headers)
305316
})
306-
.configure_reqwest(|r| r.connect_timeout(Duration::from_secs(10)))
307317
.build()?;
308318

309319
let mut scope = Usecase::new("preprod").scope();

0 commit comments

Comments
 (0)