Commit 13d8652f authored by Jérome Perrin's avatar Jérome Perrin

ERP5Security: log errors from authentication policy

because PAS only log these errors with level debug (
https://github.com/zopefoundation/Products.PluggableAuthService/blob/0fc22e9c472ba514470a9b205c945eb62df12205/Products/PluggableAuthService/PluggableAuthService.py#L663
) they remained unnoticed in our case
parent e9dd9889
...@@ -128,14 +128,27 @@ class ERP5LoginUserManager(BasePlugin): ...@@ -128,14 +128,27 @@ class ERP5LoginUserManager(BasePlugin):
password, password,
): ):
if is_authentication_policy_enabled: if is_authentication_policy_enabled:
try:
login_value.notifyLoginFailure() login_value.notifyLoginFailure()
except ConflictError:
raise
except Exception, e:
LOG('ERP5Security', PROBLEM,
'Error when processing authentication policy', error=sys.exc_info())
return return
if is_authentication_policy_enabled: if is_authentication_policy_enabled:
try:
if login_value.isPasswordExpired(): if login_value.isPasswordExpired():
login_value.notifyPasswordExpire() login_value.notifyPasswordExpire()
return return
if login_value.isLoginBlocked(): if login_value.isLoginBlocked():
return return
except ConflictError:
raise
except Exception, e:
LOG('ERP5Security', PROBLEM,
'Error when processing authentication policy', error=sys.exc_info())
return None
return (user_value.getUserId(), login_value.getReference()) return (user_value.getUserId(), login_value.getReference())
def _getLoginValueFromLogin(self, login, login_portal_type=None): def _getLoginValueFromLogin(self, login, login_portal_type=None):
......
...@@ -189,6 +189,7 @@ class ERP5UserManager(BasePlugin): ...@@ -189,6 +189,7 @@ class ERP5UserManager(BasePlugin):
return None return None
user = user_list[0] user = user_list[0]
try:
if authentication_result is None: if authentication_result is None:
# file a failed authentication attempt # file a failed authentication attempt
user.notifyLoginFailure() user.notifyLoginFailure()
...@@ -202,6 +203,11 @@ class ERP5UserManager(BasePlugin): ...@@ -202,6 +203,11 @@ class ERP5UserManager(BasePlugin):
# check if user account is blocked # check if user account is blocked
if user.isLoginBlocked(): if user.isLoginBlocked():
return None return None
except ConflictError:
raise
except Exception, e:
LOG('ERP5Security', PROBLEM, 'Error when processing authentication policy', error=sys.exc_info())
return None
return authentication_result return authentication_result
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment