Skip to content

Commit

Permalink
include unused bearer for future proofing
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Jan 6, 2024
1 parent 1e19f77 commit 63d7274
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,12 @@ impl ApiActor {
self.endpoint,
self.key.as_ref().map_or("", |k| &k.0)
);
let res = self.client.get(&url).send().await?;
let res = self
.client
.get(&url)
.bearer_auth(self.key.as_ref().map_or("", |k| &k.0))
.send()
.await?;
match res.status() {
StatusCode::NOT_FOUND => callback
.send(Err(KeyError::AccessDenied))
Expand All @@ -601,7 +606,12 @@ impl ApiActor {
}
ApiMessage::Status { callback } => {
let url = format!("{}/status", self.endpoint);
let res = self.client.get(&url).send().await?;
let res = self
.client
.get(&url)
.bearer_auth(self.key.as_ref().map_or("", |k| &k.0))
.send()
.await?;
match res.status() {
StatusCode::OK => callback
.send(res.json::<StatusResponseBody>().await?.analysis)
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use crate::{

#[tokio::main(flavor = "current_thread")]
async fn main() {
let client = http_client();
let client = configure_client();
let opt = configure::parse_and_configure(&client).await;
let logger = Logger::new(opt.verbose, opt.command.map_or(false, Command::is_systemd));

Expand Down Expand Up @@ -430,7 +430,7 @@ fn exec(command: &mut process::Command) -> io::Error {
}
}

fn http_client() -> Client {
fn configure_client() -> Client {
// Build TLS backend that supports SSLKEYLOGFILE.
let mut root_store = rustls::RootCertStore::empty();
root_store.add_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().map(|ta| {
Expand Down

0 comments on commit 63d7274

Please sign in to comment.