aboutsummaryrefslogtreecommitdiff
path: root/src/auth.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/auth.rs')
-rw-r--r--src/auth.rs30
1 files changed, 0 insertions, 30 deletions
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 @@
1use axum::http::HeaderValue;
2use tracing::{debug, trace};
3use crate::config::Config;
4use crate::error::Error;
5
6pub fn auth(config: &Config, secret: Option<&HeaderValue>) -> Result<Response, Error> {
7 debug!("auth request with secret {:?}", secret);
8 let res = if let Some(value) = secret {
9 trace!("auth value exists");
10 let key = &config.apikey;
11 if value.to_str()? == key.as_str() {
12 debug!("successful auth");
13 Response::Success
14 } else {
15 debug!("unsuccessful auth (wrong secret)");
16 Response::WrongSecret
17 }
18 } else {
19 debug!("unsuccessful auth (no secret)");
20 Response::MissingSecret
21 };
22 Ok(res)
23}
24
25#[derive(Debug)]
26pub enum Response {
27 Success,
28 WrongSecret,
29 MissingSecret
30}