mirror of
https://github.com/etnguyen03/tjdests.git
synced 2025-04-20 17:50:16 -04:00
add django-axes (#177)
* build(deps): add django-axes * test: modify for axes See jazzband/django-axes#998
This commit is contained in:
parent
a7aa9a7bc3
commit
5799abb2bf
1
Pipfile
1
Pipfile
|
@ -16,6 +16,7 @@ psycopg2 = "~=2.9.5"
|
||||||
pygments = "~=2.14.0"
|
pygments = "~=2.14.0"
|
||||||
social-auth-app-django = "~=5.0.0"
|
social-auth-app-django = "~=5.0.0"
|
||||||
whitenoise = "~=6.4.0"
|
whitenoise = "~=6.4.0"
|
||||||
|
django-axes = "~=5.41.0"
|
||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
autopep8 = "~=2.0.2"
|
autopep8 = "~=2.0.2"
|
||||||
|
|
24
Pipfile.lock
generated
24
Pipfile.lock
generated
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "19bc5651835946f1e4fe7e7834590b4a0f861cbd6d820ade3e92a8bb929eb002"
|
"sha256": "3f3be7067d7f370e0286f22340b6f4cba7774cf28f894b70b0e181d3cc3b36f0"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
@ -253,6 +253,14 @@
|
||||||
"index": "pypi",
|
"index": "pypi",
|
||||||
"version": "==3.2.18"
|
"version": "==3.2.18"
|
||||||
},
|
},
|
||||||
|
"django-axes": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:7e73c6cfe8e2390e60e5a189976833838206ab7fc04dc9b5c3f27fe589364eb3",
|
||||||
|
"sha256:cd2b6350d47168b4fc8d37cd159855bc0d55e7b1e6469d76708bc456bc377212"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==5.41.0"
|
||||||
|
},
|
||||||
"django-bootstrap-pagination": {
|
"django-bootstrap-pagination": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:47e742679cf109e12f10ae09d5263433f94440818cf7b023e90a3f5252849639",
|
"sha256:47e742679cf109e12f10ae09d5263433f94440818cf7b023e90a3f5252849639",
|
||||||
|
@ -277,6 +285,14 @@
|
||||||
"index": "pypi",
|
"index": "pypi",
|
||||||
"version": "==3.2.1"
|
"version": "==3.2.1"
|
||||||
},
|
},
|
||||||
|
"django-ipware": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:4fa5607ee85e12ee5e158bc7569ff1e134fb1579681aa1ff3f0ed04be21be153",
|
||||||
|
"sha256:80b52a3f571a371519cc552798f1015b934dd5dd7738bfad87e101e861bd21b8"
|
||||||
|
],
|
||||||
|
"markers": "python_version >= '3.7'",
|
||||||
|
"version": "==5.0.0"
|
||||||
|
},
|
||||||
"executing": {
|
"executing": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:0314a69e37426e3608aada02473b4161d4caf5a4b244d1d0c48072b8fee7bacc",
|
"sha256:0314a69e37426e3608aada02473b4161d4caf5a4b244d1d0c48072b8fee7bacc",
|
||||||
|
@ -805,11 +821,11 @@
|
||||||
},
|
},
|
||||||
"packaging": {
|
"packaging": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:714ac14496c3e68c99c29b00845f7a2b85f3bb6f1078fd9f72fd20f0570002b2",
|
"sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61",
|
||||||
"sha256:b6ad297f8907de0fa2fe1ccbd26fdaf387f5f47c7275fedf8cce89f99446cf97"
|
"sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3.7'",
|
"markers": "python_version >= '3.7'",
|
||||||
"version": "==23.0"
|
"version": "==23.1"
|
||||||
},
|
},
|
||||||
"pathspec": {
|
"pathspec": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
|
|
|
@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/3.2/ref/settings/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ INSTALLED_APPS = [
|
||||||
"social_django",
|
"social_django",
|
||||||
"django_extensions",
|
"django_extensions",
|
||||||
"bootstrap_pagination",
|
"bootstrap_pagination",
|
||||||
|
"axes",
|
||||||
"tjdests.apps.authentication",
|
"tjdests.apps.authentication",
|
||||||
"tjdests.apps.destinations",
|
"tjdests.apps.destinations",
|
||||||
"tjdests.apps.profile",
|
"tjdests.apps.profile",
|
||||||
|
@ -60,6 +62,7 @@ MIDDLEWARE = [
|
||||||
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
||||||
"django.contrib.messages.middleware.MessageMiddleware",
|
"django.contrib.messages.middleware.MessageMiddleware",
|
||||||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||||
|
"axes.middleware.AxesMiddleware",
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = "tjdests.urls"
|
ROOT_URLCONF = "tjdests.urls"
|
||||||
|
@ -116,6 +119,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||||
AUTH_USER_MODEL = "authentication.User"
|
AUTH_USER_MODEL = "authentication.User"
|
||||||
|
|
||||||
AUTHENTICATION_BACKENDS = (
|
AUTHENTICATION_BACKENDS = (
|
||||||
|
"axes.backends.AxesStandaloneBackend",
|
||||||
"tjdests.apps.authentication.oauth.IonOauth2",
|
"tjdests.apps.authentication.oauth.IonOauth2",
|
||||||
"django.contrib.auth.backends.ModelBackend",
|
"django.contrib.auth.backends.ModelBackend",
|
||||||
)
|
)
|
||||||
|
@ -163,6 +167,10 @@ MESSAGE_TAGS = {
|
||||||
messages.ERROR: "danger",
|
messages.ERROR: "danger",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TESTING = any("test" in arg for arg in sys.argv)
|
||||||
|
if TESTING:
|
||||||
|
AXES_ENABLED = False
|
||||||
|
|
||||||
# Override the following in secret.py
|
# Override the following in secret.py
|
||||||
SENIOR_GRAD_YEAR: int = -1
|
SENIOR_GRAD_YEAR: int = -1
|
||||||
BRANDING_NAME: str = "UNDEFINED"
|
BRANDING_NAME: str = "UNDEFINED"
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from django.http import HttpRequest
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from tjdests.apps.authentication.models import User
|
from tjdests.apps.authentication.models import User
|
||||||
|
@ -40,5 +41,7 @@ class TJDestsTestCase(TestCase):
|
||||||
"publish_data": publish_data,
|
"publish_data": publish_data,
|
||||||
},
|
},
|
||||||
)[0]
|
)[0]
|
||||||
self.client.force_login(user)
|
user.set_password("hello123")
|
||||||
|
user.save()
|
||||||
|
self.client.login(username=username, password="hello123", request=HttpRequest())
|
||||||
return user
|
return user
|
||||||
|
|
Loading…
Reference in New Issue
Block a user