Skip to content

Commit

Permalink
Remove axes dependency to use only allauth's rate limiter
Browse files Browse the repository at this point in the history
  • Loading branch information
gounux committed Jan 8, 2025
1 parent 9ae5d46 commit 2f01e5b
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 31 deletions.
3 changes: 0 additions & 3 deletions docker-app/qfieldcloud/core/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@

class CoreConfig(AppConfig):
name = "qfieldcloud.core"

def ready(self):
from qfieldcloud.core import signals # noqa
8 changes: 0 additions & 8 deletions docker-app/qfieldcloud/core/signals.py

This file was deleted.

20 changes: 4 additions & 16 deletions docker-app/qfieldcloud/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"""

import os
from datetime import timedelta

import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
Expand Down Expand Up @@ -58,7 +57,6 @@
WEB_HTTPS_PORT = os.environ.get("WEB_HTTPS_PORT")

AUTHENTICATION_BACKENDS = [
"axes.backends.AxesBackend",
# custom QFC backend that extends the `allauth` specific authentication methods
# such as login by email, but restricting who can login to only regular users
"qfieldcloud.authentication.auth_backends.AuthenticationBackend",
Expand Down Expand Up @@ -112,7 +110,6 @@
"qfieldcloud.authentication",
# 3rd party - keep at bottom to allow overrides
"notifications",
"axes",
"migrate_sql",
"constance",
"constance.backends.database",
Expand All @@ -135,7 +132,6 @@
"auditlog.middleware.AuditlogMiddleware",
"qfieldcloud.core.middleware.timezone.TimezoneMiddleware",
"qfieldcloud.core.middleware.test.TestMiddleware",
"axes.middleware.AxesMiddleware",
"allauth.account.middleware.AccountMiddleware",
]

Expand Down Expand Up @@ -360,6 +356,10 @@ def before_send(event, hint):
ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS = 3
ACCOUNT_EMAIL_SUBJECT_PREFIX = ""

# Django allauth's RateLimiter configuration
# https://docs.allauth.org/en/latest/account/rate_limits.html
ACCOUNT_RATE_LIMITS = {"login_failed": "10/m/ip,5/m/key"}

# Choose one of "mandatory", "optional", or "none".
# For local development and test use "optional" or "none"
ACCOUNT_EMAIL_VERIFICATION = os.environ.get("ACCOUNT_EMAIL_VERIFICATION")
Expand All @@ -368,18 +368,6 @@ def before_send(event, hint):
ACCOUNT_ADAPTER = "qfieldcloud.core.adapters.AccountAdapter"
ACCOUNT_LOGOUT_ON_GET = True

# Django axes configuration
# https://django-axes.readthedocs.io/en/latest/4_configuration.html
###########################
# The integer number of login attempts allowed before a record is created for the failed logins. Default: 3
AXES_FAILURE_LIMIT = 5
# If True, only lock based on username, and never lock based on IP if attempts exceed the limit. Otherwise utilize the existing IP and user locking logic. Default: False
AXES_ONLY_USER_FAILURES = True
# If set, defines a period of inactivity after which old failed login attempts will be cleared. If an integer, will be interpreted as a number of hours. Default: None
AXES_COOLOFF_TIME = timedelta(minutes=30)
# If True, a successful login will reset the number of failed logins. Default: False
AXES_RESET_ON_SUCCESS = True

# Django email configuration
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = os.environ.get("EMAIL_HOST")
Expand Down
1 change: 0 additions & 1 deletion docker-app/requirements/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ deprecated==1.2.14
django==4.2.16
django-allauth==65.3.0
django-auditlog==3.0.0
django-axes==5.40.1
django-bootstrap4==24.3
django-classy-tags==4.1.0
django-common-helpers==0.9.2
Expand Down
3 changes: 0 additions & 3 deletions docker-app/requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ django==4.2.16
# django-allauth
# django-appconf
# django-auditlog
# django-axes
# django-bootstrap4
# django-classy-tags
# django-common-helpers
Expand Down Expand Up @@ -77,8 +76,6 @@ django-appconf==1.0.6
# via django-cryptography
django-auditlog==3.0.0
# via -r /requirements/requirements.in
django-axes==5.40.1
# via -r /requirements/requirements.in
django-bootstrap4==24.3
# via -r /requirements/requirements.in
django-classy-tags==4.1.0
Expand Down

0 comments on commit 2f01e5b

Please sign in to comment.