From 9fbf3a5f925388766076ca5f240fe179ff7653a0 Mon Sep 17 00:00:00 2001 From: Ross Patterson Date: Mon, 3 Jan 2022 16:19:02 -0800 Subject: [PATCH] fix(log): Log error conditions in the server logs An error that indicates incorrect configuration, set up, or otherwise something an administrator would probably want to know, should also be logged to the server logs. Those log messages should including enough information for an administrator to find the specific instance of the issue (e.g. which Plone portal in a multi-portal ZODB). --- src/plone/restapi/services/auth/login.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/plone/restapi/services/auth/login.py b/src/plone/restapi/services/auth/login.py index b51962dcb9..21fa9fa6b5 100644 --- a/src/plone/restapi/services/auth/login.py +++ b/src/plone/restapi/services/auth/login.py @@ -7,8 +7,11 @@ from zope.interface import alsoProvides from zope import component +import logging import plone.protect.interfaces +logger = logging.getLogger(__name__) + class Login(Service): """Handles login and returns a JSON web token (JWT).""" @@ -45,10 +48,16 @@ def reply(self): if plugin is None: self.request.response.setStatus(501) + message = "JWT authentication plugin not installed" + logger.error( + "%s: %s", + message, + "/".join(uf.getPhysicalPath()), + ) return dict( error=dict( type="Login failed", - message="JWT authentication plugin not installed.", + message=message, ) )