Restore ngx logging used by fail2ban to detect failed logging attempt

This commit is contained in:
Alexandre Aubin 2020-10-31 13:53:19 +01:00
parent 229939dfbc
commit 6a7a9d668e

View file

@ -381,11 +381,15 @@ function authenticate(user, password)
ensure_user_password_uses_strong_hash(connected, user, password) ensure_user_password_uses_strong_hash(connected, user, password)
end end
cache:add(user.."-password", password, conf["session_timeout"]) cache:add(user.."-password", password, conf["session_timeout"])
ngx.log(ngx.NOTICE, "Connected as: "..user)
logger.info("User "..user.." succesfully authenticated from "..ngx.var.remote_addr) logger.info("User "..user.." succesfully authenticated from "..ngx.var.remote_addr)
return user return user
-- Else, the username/email or the password is wrong -- Else, the username/email or the password is wrong
else else
-- N.B. : the ngx.log is important and is related to the regex used by
-- the fail2ban rule to detect (and ban) failed login attempts
ngx.log(ngx.ERR, "Connection failed for: "..user)
logger.error("Authentication failure for user "..user.." from "..ngx.var.remote_addr) logger.error("Authentication failure for user "..user.." from "..ngx.var.remote_addr)
return false return false
end end