Compare commits

..

No commits in common. "a53fada7e186b6e9424347e671c744e42496d45c" and "86ef9dc947d6a763c40e09545707a8cb804e8cd8" have entirely different histories.

21 changed files with 2 additions and 7 deletions

0
.gitignore vendored Executable file → Normal file
View File

0
LICENSE Executable file → Normal file
View File

0
MANIFEST.in Executable file → Normal file
View File

1
README.md Executable file → Normal file
View File

@ -203,7 +203,6 @@ hoptchaPost('/endpoint', payload, onSuccess, onError, function renderCustom(url)
| `exempt_if` | Skip protection for trusted users | For staff |
| `methods` | HTTP methods to track (POST, GET, etc.) | POST |
| `shared` | Share same attempts counter among all endpoints | `False` |
| `type` | Type of CAPTCHA do display (sliding, pointing, random) | `random` |
---

0
django_hoptcha/__init__.py Executable file → Normal file
View File

8
django_hoptcha/decorators.py Executable file → Normal file
View File

@ -56,8 +56,7 @@ def hoptcha_protected(
response=None,
exempt_if=lambda request: request.user.is_staff or request.user.is_superuser,
backoff=False,
shared=False,
type=None,
shared=False
):
"""
Enforces CAPTCHA if request exceeds `threshold`.
@ -70,7 +69,6 @@ def hoptcha_protected(
- exempt_if: skip protection for trusted users.
- methods: HTTP methods to track (default: POST).
- shared: Share same attempts counter among all endpoints.
- type: Type of CAPTCHA do display (sliding, pointing, random)
"""
if isinstance(key, str):
@ -82,8 +80,6 @@ def hoptcha_protected(
else:
raise TypeError("key must be a string or callable")
type = type.lower() if type and type.lower() in ['sliding', 'pointing'] else 'random'
def decorator(view_func):
@wraps(view_func)
def _wrapped_view(request, *args, **kwargs):
@ -105,7 +101,7 @@ def hoptcha_protected(
if not token or not verify_token(token):
return response(request) if response else JsonResponse({
"error": "CAPTCHA",
"url": f"{GENERATE_URL}?{urlencode({'client_key': PUBLIC_KEY, 'timestamp': int(time.time() * 1000), 'type': type})}"
"url": f"{GENERATE_URL}?{urlencode({'client_key': PUBLIC_KEY, 'timestamp': int(time.time() * 1000)})}"
}, status=400)
else:
cache.delete(cache_key) # reset counter if passed

0
django_hoptcha/settings.py Executable file → Normal file
View File

0
django_hoptcha/static/django_hoptcha/hoptcha.js Executable file → Normal file
View File

View File

View File

0
django_hoptcha/templatetags/__init__.py Executable file → Normal file
View File

0
django_hoptcha/templatetags/hoptcha_tags.py Executable file → Normal file
View File

0
django_hoptcha/validators.py Executable file → Normal file
View File

0
example/demoapp/demoapp/__init__.py Executable file → Normal file
View File

0
example/demoapp/demoapp/asgi.py Executable file → Normal file
View File

0
example/demoapp/demoapp/settings.py Executable file → Normal file
View File

0
example/demoapp/demoapp/templates/form.html Executable file → Normal file
View File

0
example/demoapp/demoapp/urls.py Executable file → Normal file
View File

0
example/demoapp/demoapp/views.py Executable file → Normal file
View File

0
example/demoapp/demoapp/wsgi.py Executable file → Normal file
View File

0
setup.py Executable file → Normal file
View File