From dfdf6d960a3333ec86e2ed07f6df564ef5ad37b7 Mon Sep 17 00:00:00 2001 From: Josh Borrow Date: Tue, 17 Dec 2024 16:08:20 -0500 Subject: [PATCH] Add additional authentication check step --- librarian_server/api/corrupt.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/librarian_server/api/corrupt.py b/librarian_server/api/corrupt.py index 46dd188..0b34dc1 100644 --- a/librarian_server/api/corrupt.py +++ b/librarian_server/api/corrupt.py @@ -41,6 +41,19 @@ def user_and_librarian_validation_flow( librarian_exists = librarian is not None + if not librarian_exists: + logger.warning( + "Librarian {} does not exist, cannot authenticate remedy request", + librarian_name, + ) + raise HTTPException( + status_code=status.HTTP_401_UNAUTHORIZED, + detail=dict( + reason="Unauthorized", + suggested_remedy="", + ), + ) + stmt = select(RemoteInstance).filter_by( file_name=file_name, librarian_id=librarian.id )