Django REST hCAPTCHA
Django REST hCAPTCHA v2 and v3 field serializer
Requirements
- Python: 3.7, 3.8, 3.9, 3.10, 3.11
- Django: 3.2, 4.0, 4.1, 4.2
- DRF: 3.11, 3.12, 3.13, 3.14
Installation
- Install with
pip install drf-hcaptcha - Add
"drf_hcaptcha"to yourINSTALLED_APPSsettings. - Set in settings
DRF_HCAPTCHA_SECRET_KEY
INSTALLED_APPS = [
...,
"drf_hcaptcha",
...,
]
...
DRF_HCAPTCHA_SECRET_KEY = "YOUR SECRET KEY"
Usage
from rest_framework.serializers import Serializer
from drf_hcaptcha.fields import HCaptchaV2Field
class V2Serializer(Serializer):
hcaptcha = HCaptchaV2Field()
...
Settings
DRF_HCAPTCHA_SECRET_KEY - set your hCAPTCHA secret key. Type: str.
DRF_HCAPTCHA_DEFAULT_V3_SCORE - by default: 0.5. Type: float.
DRF_HCAPTCHA_ACTION_V3_SCORES - by default: {}. Type: dict. You can define specific score for each action e.g. {"login": 0.6, "feedback": 0.3}
DRF_HCAPTCHA_DOMAIN - by default: api.hcaptcha.com. Type: str.
DRF_HCAPTCHA_PROXY - by default: {}. Type: dict. e.g. {'http': 'http://127.0.0.1:8000', 'https': 'https://127.0.0.1:8000'}
DRF_HCAPTCHA_VERIFY_REQUEST_TIMEOUT - by default: 10. Type: int.
Priority of secret_key value
- settings
DRF_HCAPTCHA_SECRET_KEY - the argument
secret_keyof field - request.context["hcaptcha_secret_key"]
hCAPTCHA v3
Validation is passed if the score value returned by Google is greater than or equal to required score.
Required score value: 0.0 - 1.0
Priority of score value
If not defined or zero in current item then value from next item.
- Value for action in settings
DRF_HCAPTCHA_ACTION_V3_SCORES - Value in argument
required_scoreof field - Default value in settings
DRF_HCAPTCHA_DEFAULT_V3_SCORE - Default value
0.5
Metadata
Release files for drf-hcaptcha 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| drf-hcaptcha-1.0.1.tar.gz | 8.4 kB | Without provenance | Details for drf-hcaptcha-1.0.1.tar.gz |
Release files / drf-hcaptcha-1.0.1.tar.gz
| Download URL | drf-hcaptcha-1.0.1.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
039748c3f31d19f4a9be4c23ef07aebf02cc7a305a80fe8e9973bf260333ad12
|
|
BLAKE2b-256 checksum How to use checksums |
3432151023195c0dae83a5c747779fca528583694f9ad199cead61cf0e22f702
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.13
|
Security for drf-hcaptcha 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.