Log auth attempts on /admin

master
Florent Daigniere 3 years ago
parent 89ea51d570
commit a9340e61f5

@ -33,9 +33,11 @@ def login():
response = flask.redirect(flask.url_for(endpoint) response = flask.redirect(flask.url_for(endpoint)
or flask.url_for('.index')) or flask.url_for('.index'))
response.set_cookie('rate_limit', utils.limiter.device_cookie(username), max_age=31536000, path=flask.url_for('ui.login')) response.set_cookie('rate_limit', utils.limiter.device_cookie(username), max_age=31536000, path=flask.url_for('ui.login'))
flask.current_app.logger.info(f'Login succeeded for {username} from {client_ip}.')
return response return response
else: else:
utils.limiter.rate_limit_user(username, client_ip, device_cookie, device_cookie_username) if models.User.get(username) else utils.limiter.rate_limit_ip(client_ip) utils.limiter.rate_limit_user(username, client_ip, device_cookie, device_cookie_username) if models.User.get(username) else utils.limiter.rate_limit_ip(client_ip)
flask.current_app.logger.warn(f'Login failed for {username} from {client_ip}.')
flask.flash('Wrong e-mail or password', 'error') flask.flash('Wrong e-mail or password', 'error')
return flask.render_template('login.html', form=form) return flask.render_template('login.html', form=form)

@ -0,0 +1 @@
Log authentication attempts on the admin portal
Loading…
Cancel
Save