From 52851787329c48c1e70f98a3610ad52fe1fa4aa4 Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Mon, 8 Apr 2024 15:14:21 +0200 Subject: Closes #25. Apikey not required anymore --- src/extractors.rs | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 src/extractors.rs (limited to 'src/extractors.rs') diff --git a/src/extractors.rs b/src/extractors.rs deleted file mode 100644 index 4d441e9..0000000 --- a/src/extractors.rs +++ /dev/null @@ -1,24 +0,0 @@ -use axum::{ - extract::{Request, State}, - http::{HeaderMap, StatusCode}, - middleware::Next, - response::Response, -}; - -use crate::AppState; - -pub async fn auth( - State(state): State, - headers: HeaderMap, - request: Request, - next: Next, -) -> Result { - let secret = headers.get("authorization"); - match secret { - Some(token) if token == state.config.apikey.as_str() => { - let response = next.run(request).await; - Ok(response) - } - _ => Err(StatusCode::UNAUTHORIZED), - } -} -- cgit v1.2.3