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:
login_value.notifyLoginFailure() try:
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:
if login_value.isPasswordExpired(): try:
login_value.notifyPasswordExpire() if login_value.isPasswordExpired():
return login_value.notifyPasswordExpire()
if login_value.isLoginBlocked(): return
return if login_value.isLoginBlocked():
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,18 +189,24 @@ class ERP5UserManager(BasePlugin): ...@@ -189,18 +189,24 @@ class ERP5UserManager(BasePlugin):
return None return None
user = user_list[0] user = user_list[0]
if authentication_result is None: try:
# file a failed authentication attempt if authentication_result is None:
user.notifyLoginFailure() # file a failed authentication attempt
return None user.notifyLoginFailure()
return None
# check if password is expired # check if password is expired
if user.isPasswordExpired(): if user.isPasswordExpired():
user.notifyPasswordExpire() user.notifyPasswordExpire()
return None return None
# check if user account is blocked # check if user account is blocked
if user.isLoginBlocked(): if user.isLoginBlocked():
return None
except ConflictError:
raise
except Exception, e:
LOG('ERP5Security', PROBLEM, 'Error when processing authentication policy', error=sys.exc_info())
return None 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