mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-13 22:40:16 +02:00
Added Google reCaptcha (#738)
This commit is contained in:
parent
693016e171
commit
e6e1339d71
@ -67,6 +67,7 @@ INSTALLED_APPS = [
|
||||
'permissions_tool',
|
||||
'geelweb.django.navhelper',
|
||||
'bootstrap_pagination',
|
||||
'captcha',
|
||||
|
||||
# Services
|
||||
'services.modules.mumble',
|
||||
@ -221,6 +222,15 @@ CACHES = {
|
||||
}
|
||||
}
|
||||
|
||||
# Google Recaptcha
|
||||
|
||||
CAPTCHA_ENABLED = False
|
||||
|
||||
RECAPTCHA_PUBLIC_KEY = 'MyRecaptchaKey'
|
||||
RECAPTCHA_PRIVATE_KEY = 'MyRecaptchaPrivateKey'
|
||||
|
||||
NOCAPTCHA = True
|
||||
|
||||
#####################################################
|
||||
##
|
||||
## Auth configuration starts here
|
||||
|
@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.contrib.auth.models import User
|
||||
from django.conf import settings
|
||||
import re
|
||||
|
||||
|
||||
@ -9,6 +10,10 @@ class LoginForm(forms.Form):
|
||||
username = forms.CharField(label=_('Username'), max_length=32, required=True)
|
||||
password = forms.CharField(label=_('Password'), widget=forms.PasswordInput())
|
||||
|
||||
if getattr(settings, 'CAPTCHA_ENABLED', False):
|
||||
from captcha.fields import ReCaptchaField
|
||||
captcha = ReCaptchaField()
|
||||
|
||||
|
||||
class RegistrationForm(forms.Form):
|
||||
username = forms.CharField(label=_('Username'), max_length=30, required=True)
|
||||
@ -17,6 +22,10 @@ class RegistrationForm(forms.Form):
|
||||
email = forms.CharField(label=_('Email'), max_length=254, required=True)
|
||||
email_again = forms.CharField(label=_('Email Again'), max_length=254, required=True)
|
||||
|
||||
if getattr(settings, 'CAPTCHA_ENABLED', False):
|
||||
from captcha.fields import ReCaptchaField
|
||||
captcha = ReCaptchaField()
|
||||
|
||||
def clean(self):
|
||||
if ' ' in self.cleaned_data['username']:
|
||||
raise forms.ValidationError('Username cannot contain a space')
|
||||
|
@ -136,6 +136,13 @@ Fittings and operations can be imported from Fleet-Up. Define the following to d
|
||||
- [FLEETUP_API_ID](#fleetup-api-id)
|
||||
- [FLEETUP_GROUP_ID](#fleetup-group-id)
|
||||
|
||||
### Captcha
|
||||
To help prevent bots from registering and brute forcing the login. Get the reCaptcha keys from (here)[https://www.google.com/recaptcha/intro/index.html]
|
||||
- [CAPTCHA_ENABLED](#captcha_enabled)
|
||||
- [RECAPTCHA_PUBLIC_KEY](#recaptcha_public_key)
|
||||
- [RECAPTCHA_PRIVATE_KEY](#recaptcha_private_key)
|
||||
- [NOCAPTCHA](#nocaptcha)
|
||||
|
||||
# Description of Settings
|
||||
## Django
|
||||
### SECRET_KEY
|
||||
@ -150,6 +157,14 @@ List of databases available. Contains the Django database, and may include servi
|
||||
Friendly name of the local language.
|
||||
### TIME_ZONE
|
||||
Friendly name of the local timezone.
|
||||
### CAPTCHA_ENABLED
|
||||
Enable Google reCaptcha
|
||||
### RECAPTCHA_PUBLIC_KEY
|
||||
Google reCaptcha public key
|
||||
### RECAPTCHA_PRIVATE_KEY
|
||||
Google reCaptcha private key
|
||||
### NOCAPTCHA
|
||||
Enable New No Captcha reCaptcha
|
||||
### STATIC_URL
|
||||
Absolute URL to serve static files from.
|
||||
### STATIC_ROOT
|
||||
|
@ -16,6 +16,7 @@ django-bootstrap-form
|
||||
django-navhelper
|
||||
django-bootstrap-pagination
|
||||
django-redis>=4.4
|
||||
django-recaptcha
|
||||
|
||||
# awating release for fix to celery/django-celery#447
|
||||
# django-celery
|
||||
|
Loading…
x
Reference in New Issue
Block a user