Skip to content

Commit

Permalink
[Middleware] Fix authentication middleware to allow authenticated admins
Browse files Browse the repository at this point in the history
ghstack-source-id: 38e55a48d19d12f9386725b23ed0e926925ee8b3
Pull Request resolved: #22
  • Loading branch information
MohamedBassem committed Jul 31, 2023
1 parent a1100bf commit 17ec962
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cronback-services/src/api/auth_middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ pub async fn ensure_authenticated<B>(
"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),
}
}
Expand Down

0 comments on commit 17ec962

Please sign in to comment.