From 17ec9623f781c306e04e041c3ad3e3538698a980 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Mon, 31 Jul 2023 13:32:19 +0300 Subject: [PATCH] [Middleware] Fix authentication middleware to allow authenticated admins ghstack-source-id: 38e55a48d19d12f9386725b23ed0e926925ee8b3 Pull Request resolved: https://github.com/devtari-io/cronback/pull/22 --- cronback-services/src/api/auth_middleware.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cronback-services/src/api/auth_middleware.rs b/cronback-services/src/api/auth_middleware.rs index 3d00ae3..a18cd9d 100644 --- a/cronback-services/src/api/auth_middleware.rs +++ b/cronback-services/src/api/auth_middleware.rs @@ -120,13 +120,13 @@ pub async fn ensure_authenticated( "All endpoints should have passed by the authentication middleware", ); match auth { - | AuthenticationStatus::Admin(Some(_)) | AuthenticationStatus::Admin(None) => { Err(ApiError::BadRequest( "Super privilege header(s) missing!".to_owned(), )) } - | AuthenticationStatus::Authenticated(_) => Ok(next.run(req).await), + | AuthenticationStatus::Authenticated(_) + | AuthenticationStatus::Admin(Some(_)) => Ok(next.run(req).await), | AuthenticationStatus::Unauthenticated => Err(ApiError::Unauthorized), } }