Skip to content

Commit

Permalink
Merge pull request #44 from Infisical/daniel/unsupported-media-type
Browse files Browse the repository at this point in the history
fix: Potential fix for rare unsupported media bug
  • Loading branch information
DanielHougaard authored Jul 31, 2024
2 parents a95b3f8 + 56968bd commit c5291fb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 27 deletions.
24 changes: 4 additions & 20 deletions crates/infisical/src/api/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ pub(self) async fn auth_infisical_google(
jwt: Option<String>,
) -> Result<reqwest::Response> {
let url = format!("{}/api/v1/auth/gcp-auth/login", client.site_url.clone());
let request_client = build_base_request(client, &url, reqwest::Method::POST).await?;

let request = request_client
.header(reqwest::header::ACCEPT, "application/json")
.header(reqwest::header::USER_AGENT, client.user_agent.clone());
let request = build_base_request(client, &url, reqwest::Method::POST).await?;

let mut body = HashMap::new();
body.insert("identityId", identity_id);
Expand All @@ -69,11 +65,7 @@ pub(self) async fn auth_infisical_azure(
jwt: Option<String>,
) -> Result<reqwest::Response> {
let url = format!("{}/api/v1/auth/azure-auth/login", client.site_url.clone());
let request_client = build_base_request(client, &url, reqwest::Method::POST).await?;

let request = request_client
.header(reqwest::header::ACCEPT, "application/json")
.header(reqwest::header::USER_AGENT, client.user_agent.clone());
let request = build_base_request(client, &url, reqwest::Method::POST).await?;

let mut body = HashMap::new();
body.insert("identityId", identity_id);
Expand All @@ -93,11 +85,7 @@ pub(self) async fn auth_infisical_kubernetes(
"{}/api/v1/auth/kubernetes-auth/login",
client.site_url.clone()
);
let request_client = build_base_request(client, &url, reqwest::Method::POST).await?;

let request = request_client
.header(reqwest::header::ACCEPT, "application/json")
.header(reqwest::header::USER_AGENT, client.user_agent.clone());
let request = build_base_request(client, &url, reqwest::Method::POST).await?;

let mut body = HashMap::new();
body.insert("identityId", identity_id);
Expand All @@ -123,7 +111,7 @@ pub(self) async fn auth_infisical_aws(
let request_body = base64_encode(iam_data.iam_request_body.clone());

let url = format!("{}/api/v1/auth/aws-auth/login", client.site_url.clone());
let request_client = build_base_request(client, &url, reqwest::Method::POST).await?;
let request = build_base_request(client, &url, reqwest::Method::POST).await?;

let mut form_data = HashMap::new();

Expand All @@ -132,10 +120,6 @@ pub(self) async fn auth_infisical_aws(
form_data.insert("iamRequestBody", Some(request_body));
form_data.insert("iamRequestHeaders", Some(iam_headers));

let request = request_client
.header(reqwest::header::ACCEPT, "application/json")
.header(reqwest::header::USER_AGENT, client.user_agent.clone());

let response = request.form(&form_data).send().await?;

return Ok(response);
Expand Down
7 changes: 1 addition & 6 deletions crates/infisical/src/api/auth/universal_auth_login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ pub async fn universal_auth_login(
client.site_url.clone()
);

let request_client = build_base_request(client, &url, reqwest::Method::POST).await?;

let request = request_client
.header(reqwest::header::CONTENT_TYPE, "application/json")
.header(reqwest::header::ACCEPT, "application/json")
.header(reqwest::header::USER_AGENT, client.user_agent.clone());
let request = build_base_request(client, &url, reqwest::Method::POST).await?;

let response = request.body(request_body).send().await?;

Expand Down
2 changes: 1 addition & 1 deletion crates/infisical/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ pub async fn build_base_request(
// Setting JSON as the content type is OK since we only work with JSON.
.header(reqwest::header::CONTENT_TYPE, "application/json")
.header(reqwest::header::ACCEPT, "application/json")
.header("Authorization", token)
.header(reqwest::header::AUTHORIZATION, token)
.header(reqwest::header::USER_AGENT, client.user_agent.clone());

Ok(base_request)
Expand Down

0 comments on commit c5291fb

Please sign in to comment.