gdmty_django_recaptcha_enterprise
Library for Django that implements Google's reCaptcha Enterprise
This library is a draft but it works. Was made because there is no library for Django that implements Google's reCaptcha Enterprise. But now this library provides a way to verify tokens from reCaptcha Enterprise.
Installation:
pip install gdmty-django-recaptcha-enterprise
Usage:
In settings.py:
from google.oauth2 import service_account
INSTALLED_APPS = [
...,
'gdmty_django_recaptcha_enterprise',
...
]
RECAPTCHA_ENTERPRISE_PROJECT_ID = 'your-project-id'
RECAPTCHA_ENTERPRISE_SITE_KEY_VERIFY = 'your-site-key'
RECAPTCHA_ENTERPRISE_SITE_KEY_CHALLENGE = 'your-site-key'
RECAPTCHA_ENTERPRISE_BYPASS_TOKEN = 'your-bypass-token'
RECAPTCHA_CREDENTIALS_SERVICE_ACCOUNT = your-service-account
credentials = service_account.Credentials.from_service_account_info(RECAPTCHA_CREDENTIALS_SERVICE_ACCOUNT)
RECAPTCHA_ENTERPRISE_SERVICE_ACCOUNT_CREDENTIALS = credentials
In your code:
from gdmty_django_recaptcha_enterprise.recaptcha import RecaptchaEnterprise
from gdmty_django_recaptcha_enterprise.decorators import requires_recaptcha
from django.conf import settings
recaptcha = RecaptchaEnterprise(
settings.RECAPTCHA_ENTERPRISE_PROJECT_ID,
settings.RECAPTCHA_ENTERPRISE_SITE_KEY_VERIFY,
settings.RECAPTCHA_ENTERPRISE_SERVICE_ACCOUNT_CREDENTIALS)
@requires_recaptcha(action='action-to-verify')
def my_view(request):
...
pass
...