diff options
author | FxQnLr <[email protected]> | 2024-04-08 15:14:21 +0200 |
---|---|---|
committer | FxQnLr <[email protected]> | 2024-04-08 15:14:21 +0200 |
commit | 52851787329c48c1e70f98a3610ad52fe1fa4aa4 (patch) | |
tree | af1a1adeff7cf3fd8f3f1aba093aacf2a337e78d /src/extractors.rs | |
parent | d8060da1180545df5d03a76cd2860191ecf87507 (diff) | |
download | webol-52851787329c48c1e70f98a3610ad52fe1fa4aa4.tar webol-52851787329c48c1e70f98a3610ad52fe1fa4aa4.tar.gz webol-52851787329c48c1e70f98a3610ad52fe1fa4aa4.zip |
Closes #25. Apikey not required anymore
Diffstat (limited to 'src/extractors.rs')
-rw-r--r-- | src/extractors.rs | 24 |
1 files changed, 0 insertions, 24 deletions
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 @@ | |||
1 | use axum::{ | ||
2 | extract::{Request, State}, | ||
3 | http::{HeaderMap, StatusCode}, | ||
4 | middleware::Next, | ||
5 | response::Response, | ||
6 | }; | ||
7 | |||
8 | use crate::AppState; | ||
9 | |||
10 | pub async fn auth( | ||
11 | State(state): State<AppState>, | ||
12 | headers: HeaderMap, | ||
13 | request: Request, | ||
14 | next: Next, | ||
15 | ) -> Result<Response, StatusCode> { | ||
16 | let secret = headers.get("authorization"); | ||
17 | match secret { | ||
18 | Some(token) if token == state.config.apikey.as_str() => { | ||
19 | let response = next.run(request).await; | ||
20 | Ok(response) | ||
21 | } | ||
22 | _ => Err(StatusCode::UNAUTHORIZED), | ||
23 | } | ||
24 | } | ||