From 981e5c548e7098f4a391384d316ec7a52c1fa979 Mon Sep 17 00:00:00 2001 From: fx Date: Sun, 15 Oct 2023 13:02:28 +0200 Subject: auth logging changes --- src/auth.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/auth.rs b/src/auth.rs index b7693a0..81e798f 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -1,21 +1,26 @@ use std::error::Error; use axum::headers::HeaderValue; use axum::http::StatusCode; -use tracing::error; +use tracing::{debug, error, trace}; use crate::auth::AuthError::{MissingSecret, ServerError, WrongSecret}; use crate::config::SETTINGS; pub fn auth(secret: Option<&HeaderValue>) -> Result { + debug!("auth request with secret {:?}", secret); if let Some(value) = secret { + trace!("value exists"); let key = SETTINGS .get_string("apikey") .map_err(|err| ServerError(Box::new(err)))?; if value.to_str().map_err(|err| ServerError(Box::new(err)))? == key.as_str() { + debug!("successful auth"); Ok(true) } else { + debug!("unsuccessful auth (wrong secret)"); Err(WrongSecret) } } else { + debug!("unsuccessful auth (no secret)"); Err(MissingSecret) } } -- cgit v1.2.3