From ca0546a5f4f2e79dde15f5c004ab454e5909cb05 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Sun, 5 Nov 2023 13:46:21 -0500 Subject: [PATCH] Add auth log for sessions --- app/classes/web/base_handler.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/classes/web/base_handler.py b/app/classes/web/base_handler.py index 2504bc13..d8181b94 100644 --- a/app/classes/web/base_handler.py +++ b/app/classes/web/base_handler.py @@ -14,6 +14,7 @@ from app.classes.shared.translation import Translation from app.classes.shared.main_models import DatabaseShortcuts logger = logging.getLogger(__name__) +auth_log = logging.getLogger("auth") bearer_pattern = re.compile(r"^Bearer ", flags=re.IGNORECASE) @@ -231,9 +232,16 @@ class BaseHandler(tornado.web.RequestHandler): user, ) logging.debug("Auth unsuccessful") + auth_log.error( + f"Authentication attempted from {self.get_remote_ip()}. Invalid token" + ) self.access_denied(None, "the user provided an invalid token") return None except Exception as auth_exception: + auth_log.error( + f"Authentication attempted from {self.get_remote_ip()}." + f" Error: {auth_exception}" + ) logger.debug( "An error occured while authenticating an API user:", exc_info=auth_exception,