Skip to content

Commit

Permalink
fix(log): Log error conditions in the server logs
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
rpatterson committed Jan 4, 2022
1 parent fe07e9b commit 9fbf3a5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/plone/restapi/services/auth/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)."""
Expand Down Expand Up @@ -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,
)
)

Expand Down

0 comments on commit 9fbf3a5

Please sign in to comment.