Detects and blocks spam and fraud in Django apps without CAPTCHAs, ensuring seamless user experience.
Project description
Django - Protect Contact form Spam/Malicious Submissions, Accurate Spam Detector, bot Detector, Prevent malicious request
Enhance your Django application's security by automatically detecting and blocking spam and fraudulent requests. This solution operates transparently in the background, eliminating the need for CAPTCHAs and ensuring a seamless user experience. By analyzing request patterns and behaviors, it effectively filters out malicious activities without compromising usability.
Installation
pip install checkpost
✅ Usage
1. Enable Sessions (Required)
Checkpost uses sessions to help with request fingerprinting. Ensure sessions are properly configured in your settings.py:
INSTALLED_APPS = [
'django.contrib.sessions',
...
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
...
]
2. Add Middleware
In your Django settings.py, add the CheckpostMiddleware:
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'checkpost.middleware.CheckpostMiddleware', # 👈 Add checkpost after SessionMiddleware
]
3. Enable Django Caching
The spam detection system requires Django’s cache system to function properly. Make sure your cache backend is configured in settings.py.
Example using in-memory (development):
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.dummy.DummyCache",
},
}
Example using Redis (recommended for production):
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.redis.RedisCache",
"LOCATION": "redis://127.0.0.1:6379/1",
}
}
4. Global Blocking Behavior
By default, suspicious requests are automatically blocked (raises PermissionDenied).
To inspect and handle them manually in your views:
CHECKPOST_BLOCK_GLOBALLY = False
5. Using in Views
You don’t need to import or call anything manually. The middleware sets request.is_sus automatically before views are called.
def email_form(request):
if getattr(request, 'is_sus', False):
# Optionally log or store the suspicious activity here
return HttpResponse("Access Denied", status=403)
return HttpResponse("Welcome!")
⚙️ Configuration (Optional Settings)
All of these settings are optional. Omit them to use the built-in defaults.
| Setting | Default | Description & When to Use |
|---|---|---|
CHECKPOST_MISMATCH_THRESHOLD |
1 |
How many IP‐mismatches allowed before blocking. Increase if users may legitimately switch IPs (mobile networks, VPN). |
CHECKPOST_TRUSTED_IPS |
[] |
List of IPs or CIDR ranges that bypass the IP change check. Useful for internal services, health‐checks, or VPNs. |
CHECKPOST_TRUSTED_USER_AGENTS |
[] |
List of regex patterns matching UAs to bypass the IP check. Use for known crawlers/bots or API clients. |
CHECKPOST_BLOCK_GLOBALLY |
True |
If False, middleware sets request.is_sus but does not raise. You must handle blocking in your views. |
CHECKPOST_CACHE_TIMEOUT |
3600 | (Optional) Seconds until a stored IP or mismatch count expires. Lower for short‐lived sessions, higher to remember users longer |
When to add Trusted IPs / UAs
-
Trusted IPs:
- Internal cron jobs, monitoring, or deploy hooks with fixed IPs.
- Corporate or VPN egress ranges where legitimate users hop across subnets.
-
Trusted User-Agents:
- Official search crawlers (e.g. Googlebot) whose UA you recognize.
- API clients that send a stable UA string.
Tip: Start without any whitelists. Monitor your logs for false positives, and only add IPs or UA patterns when necessary.
⚠️ Notes
- If the cache is not available or misconfigured, spam detection will gracefully skip checks (and allow all requests).
- For best results, use a high-performance cache (Redis, Memcached, or
LocMemCachein‐memory) in production. - Sessions and Caching are mandatory for correct spam detection. If sessions or cache are unavailable, Checkpost will gracefully allow all traffic (fail-safe).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file checkpost-0.3.1.tar.gz.
File metadata
- Download URL: checkpost-0.3.1.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95bdeb46fb0783f11c23d7492eac6a5767efc2c18ff88aad79e738504aa1d747
|
|
| MD5 |
2d19197e069c557f726d0e865c337421
|
|
| BLAKE2b-256 |
74d720701e85e322d8ace0edd243a042e7e3bfc5ec1bfa579cb623e73cc7ca25
|
Provenance
The following attestation bundles were made for checkpost-0.3.1.tar.gz:
Publisher:
python-publish.yml on nezanuha/checkpost
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
checkpost-0.3.1.tar.gz -
Subject digest:
95bdeb46fb0783f11c23d7492eac6a5767efc2c18ff88aad79e738504aa1d747 - Sigstore transparency entry: 507200790
- Sigstore integration time:
-
Permalink:
nezanuha/checkpost@a33683acd3055b839f27be7e201ff74d62854486 -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/nezanuha
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a33683acd3055b839f27be7e201ff74d62854486 -
Trigger Event:
release
-
Statement type:
File details
Details for the file checkpost-0.3.1-py3-none-any.whl.
File metadata
- Download URL: checkpost-0.3.1-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c22e0c566977669bee4f9591a342cd13f39bb350b6f60cbdaf8693c36330b878
|
|
| MD5 |
3d7ce633e1378d97672ff7c4ce70aba9
|
|
| BLAKE2b-256 |
9ea7267efc96bab5f32aba2f0cd5fb0b7014cff21f0ab03509881913f6af25a9
|
Provenance
The following attestation bundles were made for checkpost-0.3.1-py3-none-any.whl:
Publisher:
python-publish.yml on nezanuha/checkpost
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
checkpost-0.3.1-py3-none-any.whl -
Subject digest:
c22e0c566977669bee4f9591a342cd13f39bb350b6f60cbdaf8693c36330b878 - Sigstore transparency entry: 507200795
- Sigstore integration time:
-
Permalink:
nezanuha/checkpost@a33683acd3055b839f27be7e201ff74d62854486 -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/nezanuha
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a33683acd3055b839f27be7e201ff74d62854486 -
Trigger Event:
release
-
Statement type: