feat: add auth middleware chain with ctx resolver and cookie parsing
This commit is contained in:
@@ -3,9 +3,12 @@ use std::fmt;
|
||||
use axum::{http::StatusCode, response::IntoResponse};
|
||||
use tracing::info;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum LoftError {
|
||||
LoginFail,
|
||||
AuthFailNoAuthTokenCookie,
|
||||
AuthFailTokenWrongFormat,
|
||||
AuthFailCtxNotInRequestExt,
|
||||
FileIdNotFound,
|
||||
}
|
||||
|
||||
@@ -20,7 +23,10 @@ impl std::error::Error for LoftError {}
|
||||
impl IntoResponse for LoftError {
|
||||
fn into_response(self) -> axum::response::Response {
|
||||
match self {
|
||||
Self::LoginFail => {
|
||||
Self::LoginFail
|
||||
| Self::AuthFailNoAuthTokenCookie
|
||||
| Self::AuthFailTokenWrongFormat
|
||||
| Self::AuthFailCtxNotInRequestExt => {
|
||||
info!("UNAUTHORIZED");
|
||||
StatusCode::UNAUTHORIZED.into_response()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user