Add captcha_factor

This commit is contained in:
Jens Langhammer 2018-12-14 13:51:12 +01:00
parent c4cd602fcb
commit 196be4b3b0
8 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,3 @@
"""passbook captcha_factor Header"""
__version__ = '0.0.1-alpha'
default_app_config = 'passbook.captcha_factor.apps.PassbookCaptchaFactorConfig'

View File

@ -0,0 +1,9 @@
"""passbook captcha app"""
from django.apps import AppConfig
class PassbookCaptchaFactorConfig(AppConfig):
"""passbook captcha app"""
name = 'passbook.captcha_factor'
label = 'passbook_captcha_factor'

View File

@ -0,0 +1,15 @@
"""passbook captcha factor"""
from django.views.generic import FormView
from passbook.captcha_factor.forms import CaptchaForm
from passbook.core.auth.factor import AuthenticationFactor
class CaptchaFactor(FormView, AuthenticationFactor):
"""Simple captcha checker, logic is handeled in django-captcha module"""
form_class = CaptchaForm
def form_valid(self, form):
return self.authenticator.user_ok()

View File

@ -0,0 +1,9 @@
"""passbook captcha factor forms"""
from captcha.fields import ReCaptchaField
from django import forms
class CaptchaForm(forms.Form):
"""passbook captcha factor form"""
captcha = ReCaptchaField()

View File

@ -0,0 +1 @@
django-recaptcha

View File

@ -0,0 +1,7 @@
"""passbook captcha_facot settings"""
RECAPTCHA_PUBLIC_KEY = '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'
RECAPTCHA_PRIVATE_KEY = '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'
NOCAPTCHA = True
INSTALLED_APPS = [
'captcha'
]

View File

@ -52,6 +52,7 @@ AUTHENTICATION_BACKENDS = [
AUTHENTICATION_FACTORS = [
'passbook.core.auth.backend_factor.AuthenticationBackendFactor',
'passbook.core.auth.dummy.DummyFactor',
'passbook.captcha_factor.factor.CaptchaFactor',
]
# Application definition
@ -75,6 +76,7 @@ INSTALLED_APPS = [
'passbook.oauth_provider',
'passbook.saml_idp',
'passbook.totp',
'passbook.captcha_factor',
]
# Message Tag fix for bootstrap CSS Classes

View File

@ -5,3 +5,4 @@
-r passbook/totp/requirements.txt
-r passbook/oauth_provider/requirements.txt
-r passbook/audit/requirements.txt
-r passbook/captcha_factor/requirements.txt