From c0b619b58f19a7dd88fdd365731eae987b8f0ad5 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Mon, 16 Mar 2026 22:04:59 -0300 Subject: [PATCH] Fix: add FromRequestParts impl for security AuthenticatedUser extractor --- src/security/auth_api/types.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/security/auth_api/types.rs b/src/security/auth_api/types.rs index 15187be9..e59c173e 100644 --- a/src/security/auth_api/types.rs +++ b/src/security/auth_api/types.rs @@ -489,3 +489,25 @@ impl AuthenticatedUser { .collect() } } + +#[axum::async_trait] +impl axum::extract::FromRequestParts for AuthenticatedUser +where + S: Send + Sync, +{ + type Rejection = (axum::http::StatusCode, axum::Json); + + async fn from_request_parts( + parts: &mut axum::http::request::Parts, + _state: &S, + ) -> Result { + parts + .extensions + .get::() + .cloned() + .ok_or(( + axum::http::StatusCode::UNAUTHORIZED, + axum::Json(serde_json::json!({"error": "Authentication required"})), + )) + } +}