Name | django-altcha JSON |
Version |
0.3.0
JSON |
| download |
home_page | None |
Summary | Django field and widget for Altcha CAPTCHA. |
upload_time | 2025-07-25 07:26:21 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
captcha
django
widget
form
altcha
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Django Altcha
**Django Altcha** is a Django library that provides easy integration of Altcha CAPTCHA
into your Django forms, enhancing user verification with configurable options.
By default, CAPTCHA validation operates in a **fully self-hosted mode**,
**eliminating the need for external services** while ensuring privacy and control over
the verification process.
**Django Altcha** is **secure by default**, featuring built-in
**protection against replay attacks** to ensure each challenge is validated only once.
This helps safeguard your forms from repeated or spoofed submissions without
requiring additional configuration.
## Installation
1. **Install the package:**
```bash
pip install django-altcha
```
2. **Add to `INSTALLED_APPS`:**
Update your Django project's `settings.py`:
```python
INSTALLED_APPS = [
# Other installed apps
"django_altcha",
]
```
3. **Set your secret HMAC key:**
This key is used to HMAC-sign ALTCHA challenges and **must be kept secret**.
Treat it like a password: use a secure, 64-character hex string.
Update your Django project's `settings.py`:
```python
ALTCHA_HMAC_KEY="your_secret_hmac_key"
```
> [!NOTE]
> You can generate a new secured HMAC key using:
> ``python -c "import secrets; print(secrets.token_hex(64))"``
## Usage
### Adding the CAPTCHA Field to Your Form
To add the Altcha CAPTCHA field to a Django form, import `AltchaField` and add it to
your form definition:
```python
from django import forms
from django_altcha import AltchaField
class MyForm(forms.Form):
captcha = AltchaField()
```
## Configuration Options
You can pass configuration options to `AltchaField` that are supported by Altcha.
These options are documented at
[Altcha's website integration guide](https://altcha.org/docs/website-integration/).
### Example with additional options:
```python
from django import forms
from django_altcha import AltchaField
class MyForm(forms.Form):
captcha = AltchaField(
floating=True, # Enables floating behavior
debug=True, # Enables debug mode (for development)
# Additional options supported by Altcha
)
```
### Register a URL to Provide the Challenge
By default, challenge data is generated by the `AltchaField` and embedded directly
into the rendered HTML using the `challengejson` option.
Alternatively, you can provide a URL that the Altcha widget’s JavaScript will fetch to
retrieve the challenge, using the `challengeurl` option.
This approach is especially useful for enabling features like `refetchonexpire`,
which **only work** when using a `challengeurl` (not `challengejson`).
A ready-to-use `AltchaChallengeView` is available in `django_altcha`.
To enable it, register the view in your `urlpatterns`, for example:
```python
from django.urls import path
from django_altcha import AltchaChallengeView
urlpatterns += [
path("altcha/challenge/", AltchaChallengeView.as_view(), name="altcha_challenge"),
]
```
Once the URL is registered, you can configure your `AltchaField` to use it via the
`challengeurl` option:
```python
from django.urls import reverse_lazy
from django import forms
from django_altcha import AltchaField
class MyForm(forms.Form):
captcha = AltchaField(
challengeurl=reverse_lazy("altcha_challenge"),
)
```
> [!NOTE]
> You can customize the challenge generation by passing options directly when
> registering the view.
> For example: ``AltchaChallengeView.as_view(max_number=2000000)``
## Settings
### ALTCHA_HMAC_KEY
**Required.** This key is used to HMAC-sign ALTCHA challenges and **must be kept secret**.
### ALTCHA_JS_URL
URL location of the Altcha JavaScript file.
Default to the django-altcha embedded file.
### ALTCHA_VERIFICATION_ENABLED
Set to `False` to skip Altcha validation altogether.
### ALTCHA_CHALLENGE_EXPIRE
Challenge expiration duration in milliseconds.
Default to 20 minutes as per Altcha security recommendations.
See https://altcha.org/docs/v2/security-recommendations/
## Contributing
We welcome contributions to improve this library.
Feel free to submit issues or pull requests!
## License
This project is licensed under the **MIT License**.
See the [LICENSE](./LICENSE) file for details.
Raw data
{
"_id": null,
"home_page": null,
"name": "django-altcha",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "captcha, django, widget, form, altcha",
"author": null,
"author_email": "\"nexB Inc.\" <info@nexb.com>",
"download_url": "https://files.pythonhosted.org/packages/b1/39/5fed8927f51feb307ca97a9cb2bea824c32f06d4d20cdbc9285a8e3bcf2b/django_altcha-0.3.0.tar.gz",
"platform": null,
"description": "# Django Altcha\n\n**Django Altcha** is a Django library that provides easy integration of Altcha CAPTCHA\ninto your Django forms, enhancing user verification with configurable options.\n\nBy default, CAPTCHA validation operates in a **fully self-hosted mode**, \n**eliminating the need for external services** while ensuring privacy and control over\nthe verification process.\n\n**Django Altcha** is **secure by default**, featuring built-in \n**protection against replay attacks** to ensure each challenge is validated only once. \nThis helps safeguard your forms from repeated or spoofed submissions without \nrequiring additional configuration.\n\n## Installation\n\n1. **Install the package:**\n\n ```bash\n pip install django-altcha\n ```\n\n2. **Add to `INSTALLED_APPS`:**\n\n Update your Django project's `settings.py`:\n\n ```python\n INSTALLED_APPS = [\n # Other installed apps\n \"django_altcha\",\n ]\n ```\n\n3. **Set your secret HMAC key:**\n \n This key is used to HMAC-sign ALTCHA challenges and **must be kept secret**.\n Treat it like a password: use a secure, 64-character hex string.\n\n Update your Django project's `settings.py`:\n\n ```python\n ALTCHA_HMAC_KEY=\"your_secret_hmac_key\"\n ```\n\n> [!NOTE]\n> You can generate a new secured HMAC key using:\n> ``python -c \"import secrets; print(secrets.token_hex(64))\"``\n\n\n## Usage\n\n### Adding the CAPTCHA Field to Your Form\n\nTo add the Altcha CAPTCHA field to a Django form, import `AltchaField` and add it to\nyour form definition:\n\n```python\nfrom django import forms\nfrom django_altcha import AltchaField\n\nclass MyForm(forms.Form):\n captcha = AltchaField()\n```\n\n## Configuration Options\n\nYou can pass configuration options to `AltchaField` that are supported by Altcha.\nThese options are documented at\n[Altcha's website integration guide](https://altcha.org/docs/website-integration/).\n\n### Example with additional options:\n\n```python\nfrom django import forms\nfrom django_altcha import AltchaField\n\nclass MyForm(forms.Form):\n captcha = AltchaField(\n floating=True, # Enables floating behavior\n debug=True, # Enables debug mode (for development)\n # Additional options supported by Altcha\n )\n```\n\n### Register a URL to Provide the Challenge\n\nBy default, challenge data is generated by the `AltchaField` and embedded directly \ninto the rendered HTML using the `challengejson` option.\n\nAlternatively, you can provide a URL that the Altcha widget\u2019s JavaScript will fetch to \nretrieve the challenge, using the `challengeurl` option.\n\nThis approach is especially useful for enabling features like `refetchonexpire`, \nwhich **only work** when using a `challengeurl` (not `challengejson`).\n\nA ready-to-use `AltchaChallengeView` is available in `django_altcha`. \nTo enable it, register the view in your `urlpatterns`, for example:\n\n```python\nfrom django.urls import path\nfrom django_altcha import AltchaChallengeView\n\nurlpatterns += [\n path(\"altcha/challenge/\", AltchaChallengeView.as_view(), name=\"altcha_challenge\"),\n]\n```\n\nOnce the URL is registered, you can configure your `AltchaField` to use it via the \n`challengeurl` option:\n\n```python\nfrom django.urls import reverse_lazy\nfrom django import forms\nfrom django_altcha import AltchaField\n\nclass MyForm(forms.Form):\n captcha = AltchaField(\n challengeurl=reverse_lazy(\"altcha_challenge\"),\n )\n```\n\n> [!NOTE]\n> You can customize the challenge generation by passing options directly when \n> registering the view.\n> For example: ``AltchaChallengeView.as_view(max_number=2000000)``\n\n## Settings\n\n### ALTCHA_HMAC_KEY\n\n**Required.** This key is used to HMAC-sign ALTCHA challenges and **must be kept secret**.\n\n### ALTCHA_JS_URL\n\nURL location of the Altcha JavaScript file.\nDefault to the django-altcha embedded file.\n\n### ALTCHA_VERIFICATION_ENABLED\n\nSet to `False` to skip Altcha validation altogether.\n\n### ALTCHA_CHALLENGE_EXPIRE\n\nChallenge expiration duration in milliseconds.\nDefault to 20 minutes as per Altcha security recommendations.\nSee https://altcha.org/docs/v2/security-recommendations/\n\n## Contributing\n\nWe welcome contributions to improve this library.\nFeel free to submit issues or pull requests!\n\n## License\n\nThis project is licensed under the **MIT License**.\nSee the [LICENSE](./LICENSE) file for details.\n",
"bugtrack_url": null,
"license": null,
"summary": "Django field and widget for Altcha CAPTCHA.",
"version": "0.3.0",
"project_urls": {
"Changelog": "https://github.com/aboutcode-org/django-altcha/blob/main/CHANGELOG.rst",
"Documentation": "https://django-altcha.readthedocs.io/",
"Homepage": "https://github.com/aboutcode-org/django-altcha",
"Issues": "https://github.com/aboutcode-org/django-altcha/issues",
"Repository": "https://github.com/aboutcode-org/django-altcha.git"
},
"split_keywords": [
"captcha",
" django",
" widget",
" form",
" altcha"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "9e6ead184a95de2652f5834243f5b3403c8949993f5f3de08a5609b15a63b091",
"md5": "8144c699aa87c898862d844341c7adb1",
"sha256": "fc49845176f3a89ccc2cafa9c5b4d7772b20637b1b804a5752b96064488e8f3d"
},
"downloads": -1,
"filename": "django_altcha-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8144c699aa87c898862d844341c7adb1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 28331,
"upload_time": "2025-07-25T07:26:19",
"upload_time_iso_8601": "2025-07-25T07:26:19.731910Z",
"url": "https://files.pythonhosted.org/packages/9e/6e/ad184a95de2652f5834243f5b3403c8949993f5f3de08a5609b15a63b091/django_altcha-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "b1395fed8927f51feb307ca97a9cb2bea824c32f06d4d20cdbc9285a8e3bcf2b",
"md5": "b98f7ebebba044ac006bf29015731fe2",
"sha256": "74ca0a53b5a838351ccf50a3eea29dd717d83a1ba03cf37ccf4281f44f7ff20f"
},
"downloads": -1,
"filename": "django_altcha-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "b98f7ebebba044ac006bf29015731fe2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 35950,
"upload_time": "2025-07-25T07:26:21",
"upload_time_iso_8601": "2025-07-25T07:26:21.027940Z",
"url": "https://files.pythonhosted.org/packages/b1/39/5fed8927f51feb307ca97a9cb2bea824c32f06d4d20cdbc9285a8e3bcf2b/django_altcha-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-25 07:26:21",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "aboutcode-org",
"github_project": "django-altcha",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "django-altcha"
}