From 69d3e0e6564b416637978a69f0a035066aea4759 Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Wed, 10 Apr 2024 20:15:39 +0200 Subject: Closes #30 and #27. At least a little --- src/auth.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/auth.rs') diff --git a/src/auth.rs b/src/auth.rs index 74008b5..c662e36 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -6,6 +6,7 @@ use axum::{ response::Response, }; use serde::Deserialize; +use tracing::trace; #[derive(Debug, Clone, Deserialize)] pub enum Methods { @@ -20,15 +21,19 @@ pub async fn auth( next: Next, ) -> Result { let auth = state.config.auth; + trace!(?auth.method, "auth request"); match auth.method { Methods::Key => { if let Some(secret) = headers.get("authorization") { if auth.secret.as_str() != secret { + trace!("auth failed, unknown secret"); return Err(StatusCode::UNAUTHORIZED); }; + trace!("auth successfull"); let response = next.run(request).await; Ok(response) } else { + trace!("auth failed, no secret"); Err(StatusCode::UNAUTHORIZED) } } -- cgit v1.2.3