Skip to main content

A smart Django security package to auto-block suspicious traffic

Project description

django-secux

django-secux

PyPI version Python Versions Django Versions License Stars Issues Last Commit

django-secux is a simple yet powerful Django security package that protects heavy-load pages by rate-limiting access based on real usage patterns stored in the database.


🚀 Features

  • 🔐 Blocks pages when abnormal request patterns are detected
  • 📊 Logs each view's daily request count in your database
  • 🕝 Automatically blocks overused views for a customizable time window
  • ✅ Super easy to use with just a decorator!

📦 Installation

pip install django-secux

Then add it to your Django project:

# settings.py
INSTALLED_APPS = [
    ...
    'django_secux',
]

Apply migrations:

python manage.py makemigrations django_secux
python manage.py migrate

⚙️ Usage

Just decorate your heavy or sensitive views with @ai_ratelimit():

from django_secux.decorator import ai_ratelimit

@ai_ratelimit()
def my_view(request):
    return HttpResponse("Hello, world!")

This view will now be monitored. If accessed too frequently within a day, it will be blocked for 5 minutes.


✏️ Customization

You can customize the block and warning messages shown to users in your settings.py:

SECUX_MESSAGES = {
    "blocked": "⛔ This page is temporarily blocked. Please try again later.",
    "rate_exceeded": "⚠️ Rate limit exceeded. This page is blocked temporarily.",
}

Feel free to translate or rephrase these messages as needed.


🧠 Ideas or Issues?

Feel free to contribute, fork or submit issues on GitHub.

Let's keep Django apps safe and clean!

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

django_secux-0.1.3.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_secux-0.1.3-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file django_secux-0.1.3.tar.gz.

File metadata

  • Download URL: django_secux-0.1.3.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for django_secux-0.1.3.tar.gz
Algorithm Hash digest
SHA256 28e8e8c840eef79e875daf3d37ec11a4178e930deb03e5830c731a089a4e3cc8
MD5 c85a352a65c8aa1f6d41fca7c16b8e73
BLAKE2b-256 315aa14cf12c3be7c58e091bf2017a6bea40626aded31b948f1d93e1346ba0ae

See more details on using hashes here.

File details

Details for the file django_secux-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: django_secux-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for django_secux-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 078b14ebd0cc1c356e91d5fea1d5800196f6eb4f011815eb2b4b3fb983463d21
MD5 52bdf0b8905192925dd99f61e8cee95f
BLAKE2b-256 de9e836b634f4b9d5a638b0f4d994a3df5ee9a8cf533642c015efc1cd40d5068

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page