mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 03:49:10 +02:00

We use django-axes to lock out IP addresses after a set number of attempts at logging in, and separately we use django-reversion to record change history. As part of the history tracking, the default behaviour of django-reversion is to wrap all POST requests in "with transaction.atomic()", with the result that if an exception is raised any changes get rolled back; unfortunately when authentication fails for the final time, axes updates the database and then raises PermissionDenied - with the result that the database changes are rolled back, and the user's IP is not locked out, in fact it can never be locked out. To work around this, disable the atomic mode on ReversionMiddleware using a subclass. (I don't like having to do this, but this is the quickest solution for now.) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
16 lines
444 B
Python
16 lines
444 B
Python
# layerindex-web - middleware definitions
|
|
#
|
|
# Copyright (C) 2019 Intel Corporation
|
|
#
|
|
# Licensed under the MIT license, see COPYING.MIT for details
|
|
|
|
from django.utils.deprecation import MiddlewareMixin
|
|
from django.http import HttpResponseRedirect
|
|
from django.core.urlresolvers import reverse
|
|
from reversion.middleware import RevisionMiddleware
|
|
import settings
|
|
import re
|
|
|
|
class NonAtomicRevisionMiddleware(RevisionMiddleware):
|
|
atomic = False
|