Skip to content

Commit

Permalink
BUGIFX: no longer checks for auth in Options request [AI Suggested]
Browse files Browse the repository at this point in the history
  • Loading branch information
suhaybu committed Dec 4, 2024
1 parent 5160fc4 commit 216fe56
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/common/src/services/mw_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ use std::env;

use axum::{
extract::Request,
http::{header, StatusCode},
http::{header, Method, StatusCode},
middleware::Next,
response::Response,
};

const TEST_API_TOKEN: &str = "TEST_API_TOKEN";

pub async fn auth(req: Request, next: Next) -> Result<Response, StatusCode> {
// Skip auth for OPTIONS requests
if req.method() == Method::OPTIONS {
return Ok(next.run(req).await);
}

let valid_token = env::var(TEST_API_TOKEN).map_err(|_| {
tracing::error!("API_AUTH_TOKEN not configuired");
StatusCode::INTERNAL_SERVER_ERROR
Expand Down

0 comments on commit 216fe56

Please sign in to comment.