Django Cerber¶
Documentation: https://django-cerber.readthedocs.io
Source Code: https://github.com/iddqd1/django-cerber
Login anomaly detection for Django: country changes, Tor and session revocation.
Installation¶
Install this via pip (or your favourite package manager):
pip install django-cerber
Add the app to your INSTALLED_APPS:
INSTALLED_APPS = [
# ...
"django_cerber",
]
MIDDLEWARE = [
# ...
"django.contrib.sessions.middleware.SessionMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
# ...
"django_cerber.middleware.CerberMiddleware",
]
Then run python manage.py migrate. For the GeoIP country source install the
extra: pip install "django-cerber[geoip]".
Configuration¶
All settings are optional. Add them to your Django settings module to override the defaults, for example:
from datetime import timedelta
CERBER_WINDOW = timedelta(minutes=30)
CERBER_COUNTRY_SOURCES = ("cloudflare", "geoip")
CERBER_GEOIP_DATABASE = "/var/lib/geoip/GeoLite2-Country.mmdb"
CERBER_BLOCKED_COUNTRIES = ("KP",)
Setting |
Default |
Description |
|---|---|---|
|
|
Whether login checks are performed at all. |
|
|
A country change faster than this is treated as impossible travel. |
|
|
Where the client’s country comes from, tried in order until one knows it. |
|
|
Path to a MaxMind GeoIP2/GeoLite2 (or DB-IP) Country or City |
|
|
Header set by your reverse proxy with the address it received the request from, e.g. |
|
|
Number of your own proxies that append to |
|
|
Trust Cloudflare’s headers only when the peer address is a Cloudflare IP. |
|
|
ISO-3166 alpha-2 codes whose logins are always blocked, e.g. |
|
|
Block logins from Tor exit nodes (Cloudflare reports them as |
|
|
On a blocked login, also end every other session of that user. |
|
|
Where blocked browser logins are redirected. Defaults to |
Contributors ✨¶
Thanks goes to these wonderful people (emoji key):
Tomasz Drobiszewski 💻 📖 🤔 🚧 ⚠️ |
This project follows the all-contributors specification. Contributions of any kind welcome!
Credits¶
This package was created with Copier and the browniebroke/pypackage-template project template.
Installation & Usage
Project Info