mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
sso: Use new features of axes, log axes messages
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
1 parent
9c8b48ceac
commit
0f807bcd48
7 files changed
+40
-10
No files matched your search
@@ -28,7 +28,7 @@ from django.contrib.auth import REDIRECT_FIELD_NAME
|
||||
from django.contrib.auth.views import LoginView, LogoutView
|
||||
from django.http import HttpResponseRedirect
|
||||
|
||||
from plinth import actions, web_framework
|
||||
from plinth import actions, utils, web_framework
|
||||
|
||||
from .forms import AuthenticationForm
|
||||
|
||||
@@ -69,6 +69,8 @@ class SSOLoginView(LoginView):
|
||||
|
||||
return response
|
||||
|
||||
# XXX: Use axes middleware and authentication backend instead of
|
||||
# axes_form_invalid when axes >= 5.0.0 becomes available in Debian stable.
|
||||
@axes_form_invalid
|
||||
def form_invalid(self, *args, **kwargs):
|
||||
return super(SSOLoginView, self).form_invalid(*args, **kwargs)
|
||||
@@ -89,10 +91,13 @@ class CaptchaLoginView(LoginView):
|
||||
return response
|
||||
|
||||
# Successful authentication
|
||||
ip_address = web_framework.get_ip_address_from_request(request)
|
||||
axes.utils.reset(ip=ip_address)
|
||||
logger.info('Login attempts reset for IP after successful login: %s',
|
||||
ip_address)
|
||||
if utils.is_axes_old():
|
||||
ip_address = web_framework.get_ip_address_from_request(request)
|
||||
axes.utils.reset(ip=ip_address)
|
||||
logger.info(
|
||||
'Login attempts reset for IP after successful login: %s',
|
||||
ip_address)
|
||||
|
||||
return set_ticket_cookie(request.user, response)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user