From 9058f191b69ecafc8fdeace227ac113412d03888 Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Sun, 25 Feb 2024 15:15:19 +0100 Subject: Closes #16. Impl auth as extractor --- src/auth.rs | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 src/auth.rs (limited to 'src/auth.rs') diff --git a/src/auth.rs b/src/auth.rs deleted file mode 100644 index 22f87e7..0000000 --- a/src/auth.rs +++ /dev/null @@ -1,30 +0,0 @@ -use axum::http::HeaderValue; -use tracing::{debug, trace}; -use crate::config::Config; -use crate::error::Error; - -pub fn auth(config: &Config, secret: Option<&HeaderValue>) -> Result { - debug!("auth request with secret {:?}", secret); - let res = if let Some(value) = secret { - trace!("auth value exists"); - let key = &config.apikey; - if value.to_str()? == key.as_str() { - debug!("successful auth"); - Response::Success - } else { - debug!("unsuccessful auth (wrong secret)"); - Response::WrongSecret - } - } else { - debug!("unsuccessful auth (no secret)"); - Response::MissingSecret - }; - Ok(res) -} - -#[derive(Debug)] -pub enum Response { - Success, - WrongSecret, - MissingSecret -} -- cgit v1.2.3