From b67f93e76c5125d06ac37af5e7878451ccae495c Mon Sep 17 00:00:00 2001 From: Luke Hollis Date: Thu, 15 Apr 2021 08:27:31 -0700 Subject: [PATCH 1/2] add recaptcha to user creation form --- giza/forms.py | 3 +++ giza/secure.py.example | 4 +++- giza/settings.py | 6 ++++++ requirements.txt | 15 ++++++++++++--- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/giza/forms.py b/giza/forms.py index 284f25a..4c24d35 100644 --- a/giza/forms.py +++ b/giza/forms.py @@ -1,10 +1,13 @@ from django import forms from django.contrib.auth.forms import UserCreationForm, UserChangeForm from tinymce.widgets import TinyMCE +from captcha.fields import ReCaptchaField +from captcha.widgets import ReCaptchaV3 from .models import CustomUser class CustomUserCreationForm(UserCreationForm): + captcha = ReCaptchaField(widget=ReCaptchaV3) class Meta: model = CustomUser fields = ('full_name', 'username', 'email',) diff --git a/giza/secure.py.example b/giza/secure.py.example index 2252133..4a7a797 100644 --- a/giza/secure.py.example +++ b/giza/secure.py.example @@ -4,5 +4,7 @@ SECURE_SETTINGS = { "DB_USER": "", "DB_PASSWORD": "", "DB_PORT": "", - "DJANGO_SECRET_KEY": "" + "DJANGO_SECRET_KEY": "", + "RECAPTCHA_PUBLIC_KEY": "", + "RECAPTCHA_PRIVATE_KEY": "" } diff --git a/giza/settings.py b/giza/settings.py index 91875fa..7d21220 100644 --- a/giza/settings.py +++ b/giza/settings.py @@ -32,6 +32,7 @@ # Application definition INSTALLED_APPS = [ + 'captcha', 'search', 'tms', 'giza', @@ -170,3 +171,8 @@ STATIC_ROOT = os.path.join(BASE_DIR, 'http_static') STATIC_URL = '/static/' + +RECAPTCHA_PUBLIC_KEY = SECURE_SETTINGS.get("RECAPTCHA_PUBLIC_KEY") +RECAPTCHA_PRIVATE_KEY = SECURE_SETTINGS.get("RECAPTCHA_PRIVATE_KEY") +RECAPTCHA_REQUIRED_SCORE = 1 +SILENCED_SYSTEM_CHECKS = ['captcha.recaptcha_test_key_error'] diff --git a/requirements.txt b/requirements.txt index dffc10c..cde293f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,19 @@ -Django~=2.2.0 +certifi==2020.12.5 +chardet==3.0.4 +Django==2.2.12 +django-autocomplete-light==3.8.2 +django-composite-field==1.1.0 +django-recaptcha==2.0.6 +django-revproxy==0.10.0 django-tinymce==2.8.0 +django-webpack-loader==0.7.0 elasticsearch==5.5.3 +idna==2.8 Pillow==7.1.1 +psycopg2==2.8.5 pyodbc==4.0.30 pytz==2019.1 +requests==2.22.0 +six==1.15.0 sqlparse==0.3.0 urllib3==1.25.8 -requests==2.22.0 -django-webpack-loader==0.7.0 From f2df6da8a694f23972285e879314180d8a34a9aa Mon Sep 17 00:00:00 2001 From: Luke Hollis Date: Wed, 21 Apr 2021 08:16:38 -0500 Subject: [PATCH 2/2] Django versioning uses the latest version of 2.2, not restricts it to a single version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index cde293f..8681684 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ certifi==2020.12.5 chardet==3.0.4 -Django==2.2.12 +Django~=2.2.0 django-autocomplete-light==3.8.2 django-composite-field==1.1.0 django-recaptcha==2.0.6