This commit is contained in:
2026-07-04 13:19:56 +02:00
parent dc738a9d29
commit 54d1169888
4 changed files with 70 additions and 39 deletions
+3 -3
View File
@@ -8,7 +8,7 @@ use axum::{
use axum_extra::extract::CookieJar;
use std::sync::Arc;
use std::time::Instant;
use tracing::{info, Instrument};
use tracing::{debug, info, Instrument};
use uuid::Uuid;
use super::context::{CurrentUser, RequestContext};
@@ -92,7 +92,7 @@ pub async fn auth_middleware(
mut req: Request<Body>,
next: Next,
) -> Response {
// Extraction du JWT : d'abord via le header Authorization, sinon via la query string "token"
// Extraction du JWT : d'abord via le header Authorization, ou via le cookie, sinon via la query string "token"
let token = req
.headers()
.get(header::AUTHORIZATION)
@@ -132,7 +132,7 @@ pub async fn auth_middleware(
// Mise à jour du RequestContext existant
if let Some(user) = &user {
info!(user_id = %user.id, username = %user.username, "User identified");
debug!(user_id = %user.id, username = %user.username, "User identified");
if let Some(ctx) = req.extensions_mut().get_mut::<RequestContext>() {
ctx.user = Some(user.clone());
}
+2 -1
View File
@@ -9,7 +9,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::fmt()
.with_env_filter(
std::env::var("RUST_LOG")
.unwrap_or_else(|_| "info,sqlx=debug,sea_orm=debug,sea_orm_migration=info".into()),
// .unwrap_or_else(|_| "info,sqlx=debug,sea_orm=debug,sea_orm_migration=info".into()),
.unwrap_or_else(|_| "info,sqlx=info,sea_orm=info,sea_orm_migration=info".into()),
)
.with_target(true)
.with_level(true)