Skip to content

Commit

Permalink
send Bitwarden-Client-Name headers with all api requests
Browse files Browse the repository at this point in the history
  • Loading branch information
doy committed Jun 26, 2024
1 parent dbc2244 commit 18ec5a8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,15 @@ impl Client {
}

async fn reqwest_client(&self) -> Result<reqwest::Client> {
let mut default_headers = axum::http::HeaderMap::new();
default_headers.insert(
"Bitwarden-Client-Name",
axum::http::HeaderValue::from_static(env!("CARGO_PKG_NAME")),
);
default_headers.insert(
"Bitwarden-Client-Version",
axum::http::HeaderValue::from_static(env!("CARGO_PKG_VERSION")),
);
if let Some(client_cert_path) = self.client_cert_path.as_ref() {
let mut buf = Vec::new();
let mut f = tokio::fs::File::open(client_cert_path)
Expand All @@ -813,6 +822,7 @@ impl Client {
env!("CARGO_PKG_VERSION")
))
.identity(pem)
.default_headers(default_headers)
.build()
.map_err(|e| Error::CreateReqwestClient { source: e })?)
} else {
Expand All @@ -822,6 +832,7 @@ impl Client {
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION")
))
.default_headers(default_headers)
.build()
.map_err(|e| Error::CreateReqwestClient { source: e })?)
}
Expand Down Expand Up @@ -961,8 +972,6 @@ impl Client {
let res = client
.post(&self.identity_url("/connect/token"))
.form(&connect_req)
.header("Bitwarden-Client-Name", env!("CARGO_PKG_NAME"))
.header("Bitwarden-Client-Version", env!("CARGO_PKG_VERSION"))
.header(
"auth-email",
crate::base64::encode_url_safe_no_pad(email),
Expand Down

0 comments on commit 18ec5a8

Please sign in to comment.