summaryrefslogtreecommitdiff
path: root/cli/tools/registry/provenance.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tools/registry/provenance.rs')
-rw-r--r--cli/tools/registry/provenance.rs34
1 files changed, 22 insertions, 12 deletions
diff --git a/cli/tools/registry/provenance.rs b/cli/tools/registry/provenance.rs
index 622e483d6..ce3d6ff8a 100644
--- a/cli/tools/registry/provenance.rs
+++ b/cli/tools/registry/provenance.rs
@@ -1,5 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
+use crate::http_util;
use crate::http_util::HttpClient;
use super::api::OidcTokenResponse;
@@ -12,6 +13,8 @@ use deno_core::anyhow;
use deno_core::anyhow::bail;
use deno_core::error::AnyError;
use deno_core::serde_json;
+use deno_core::url::Url;
+use http_body_util::BodyExt;
use once_cell::sync::Lazy;
use p256::elliptic_curve;
use p256::pkcs8::AssociatedOid;
@@ -504,12 +507,12 @@ impl<'a> FulcioSigner<'a> {
let response = self
.http_client
- .post(url)
- .json(&request_body)
+ .post_json(url.parse()?, &request_body)?
.send()
.await?;
- let body: SigningCertificateResponse = response.json().await?;
+ let body: SigningCertificateResponse =
+ http_util::body_to_json(response).await?;
let key = body
.signed_certificate_embedded_sct
@@ -527,15 +530,23 @@ impl<'a> FulcioSigner<'a> {
bail!("No OIDC token available");
};
- let res = self
+ let mut url = req_url.parse::<Url>()?;
+ url.query_pairs_mut().append_pair("audience", aud);
+ let res_bytes = self
.http_client
- .get(&req_url)
- .bearer_auth(token)
- .query(&[("audience", aud)])
+ .get(url)?
+ .header(
+ http::header::AUTHORIZATION,
+ format!("Bearer {}", token)
+ .parse()
+ .map_err(http::Error::from)?,
+ )
.send()
.await?
- .json::<OidcTokenResponse>()
- .await?;
+ .collect()
+ .await?
+ .to_bytes();
+ let res: OidcTokenResponse = serde_json::from_slice(&res_bytes)?;
Ok(res.value)
}
}
@@ -685,11 +696,10 @@ async fn testify(
let url = format!("{}/api/v1/log/entries", *DEFAULT_REKOR_URL);
let res = http_client
- .post(&url)
- .json(&proposed_intoto_entry)
+ .post_json(url.parse()?, &proposed_intoto_entry)?
.send()
.await?;
- let body: RekorEntry = res.json().await?;
+ let body: RekorEntry = http_util::body_to_json(res).await?;
Ok(body)
}