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):
password,
):
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
if is_authentication_policy_enabled:
if login_value.isPasswordExpired():
login_value.notifyPasswordExpire()
return
if login_value.isLoginBlocked():
return
try:
if login_value.isPasswordExpired():
login_value.notifyPasswordExpire()
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())
def _getLoginValueFromLogin(self, login, login_portal_type=None):
......
......@@ -189,18 +189,24 @@ class ERP5UserManager(BasePlugin):
return None
user = user_list[0]
if authentication_result is None:
# file a failed authentication attempt
user.notifyLoginFailure()
return None
try:
if authentication_result is None:
# file a failed authentication attempt
user.notifyLoginFailure()
return None
# check if password is expired
if user.isPasswordExpired():
user.notifyPasswordExpire()
return None
# check if password is expired
if user.isPasswordExpired():
user.notifyPasswordExpire()
return None
# check if user account is blocked
if user.isLoginBlocked():
# check if user account is blocked
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 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