Add CAPTCHA to FOSSY track proposals form

This commit is contained in:
Ben Sturmfels 2024-11-12 14:15:13 +11:00
parent a6f7cea8cc
commit 5338e43e60
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0
7 changed files with 15 additions and 0 deletions

View file

@ -1,5 +1,6 @@
# To-do # To-do
* rate limiting to prevent abuse - especially on POST requests
* consider removing `events` and `worldmap` modules * consider removing `events` and `worldmap` modules
* ask Denver about why so many license files * ask Denver about why so many license files

View file

@ -1,9 +1,12 @@
from captcha.fields import CaptchaField
from django import forms from django import forms
from .models import CommunityTrackProposal from .models import CommunityTrackProposal
class CommunityTrackProposalForm(forms.ModelForm): class CommunityTrackProposalForm(forms.ModelForm):
captcha = CaptchaField()
class Meta: class Meta:
model = CommunityTrackProposal model = CommunityTrackProposal
exclude = [] exclude = []

View file

@ -93,6 +93,7 @@ INSTALLED_APPS = [
'conservancy.fossy', 'conservancy.fossy',
'conservancy.podjango', 'conservancy.podjango',
'conservancy.usethesource.apps.UseTheSourceConfig', 'conservancy.usethesource.apps.UseTheSourceConfig',
'captcha',
] ]
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

View file

@ -40,3 +40,6 @@ SESSION_COOKIE_SECURE = True
STRIPE_API_KEY = get_secret(secrets, 'STRIPE_API_KEY') STRIPE_API_KEY = get_secret(secrets, 'STRIPE_API_KEY')
STRIPE_ENDPOINT_SECRET = get_secret(secrets, 'STRIPE_ENDPOINT_SECRET') STRIPE_ENDPOINT_SECRET = get_secret(secrets, 'STRIPE_ENDPOINT_SECRET')
CAPTCHA_FLITE_PATH = '/usr/bin/flite'
CAPTCHA_SOX_PATH = '/usr/bin/sox'

View file

@ -61,6 +61,8 @@ urlpatterns = [
re_path(r'^privacy-policy/', views.content), re_path(r'^privacy-policy/', views.content),
re_path(r'^projects/', views.content), re_path(r'^projects/', views.content),
re_path(r'^sustainer/', views.content), re_path(r'^sustainer/', views.content),
path('captcha/', include('captcha.urls')),
] ]
# Serve uploaded media. Works only when DEBUG == True. Using '/media/' # Serve uploaded media. Works only when DEBUG == True. Using '/media/'

View file

@ -130,6 +130,10 @@
apt: apt:
name: build-essential,python3-dev,libffi-dev name: build-essential,python3-dev,libffi-dev
- name: Install flite and sox for CAPTCHA text-to-speech
apt:
name: flite, sox
- name: Security settings - name: Security settings
apt: apt:
name: fail2ban name: fail2ban

View file

@ -6,3 +6,4 @@ stripe
beautifulsoup4==4.11.2 beautifulsoup4==4.11.2
html5lib==1.1 html5lib==1.1
Pillow==9.4.0 Pillow==9.4.0
django-simple-captcha==0.6.0