From a9340e61f538eccc8f8aaa7ae27eb9e303aaca42 Mon Sep 17 00:00:00 2001 From: Florent Daigniere Date: Thu, 23 Sep 2021 18:48:23 +0200 Subject: [PATCH] Log auth attempts on /admin --- core/admin/mailu/ui/views/base.py | 2 ++ towncrier/newsfragments/1926.feature | 1 + 2 files changed, 3 insertions(+) create mode 100644 towncrier/newsfragments/1926.feature diff --git a/core/admin/mailu/ui/views/base.py b/core/admin/mailu/ui/views/base.py index 30173acf..05211804 100644 --- a/core/admin/mailu/ui/views/base.py +++ b/core/admin/mailu/ui/views/base.py @@ -33,9 +33,11 @@ def login(): response = flask.redirect(flask.url_for(endpoint) or flask.url_for('.index')) 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 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) + flask.current_app.logger.warn(f'Login failed for {username} from {client_ip}.') flask.flash('Wrong e-mail or password', 'error') return flask.render_template('login.html', form=form) diff --git a/towncrier/newsfragments/1926.feature b/towncrier/newsfragments/1926.feature new file mode 100644 index 00000000..fdd4ae87 --- /dev/null +++ b/towncrier/newsfragments/1926.feature @@ -0,0 +1 @@ +Log authentication attempts on the admin portal