Skip to main content

This application provide simple blacklist logic for django projects. You can block specific IP-addresses and User Agents for accessing specific page or view-name per HTTP-method. Also, you can configure rules to block users automatically after N requests per datetime.timedelta() and notify site managers about clients which have been blocked!

Quick start

  1. Add “blacklist” to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = (
        ...
        'blacklist',
    )
  2. Run python manage.py migrate to create the blacklists models.

  3. Use blacklisting decorator for views which needs blacklisting logic like this:

    from blacklist.utils import blacklisting
    
    urlpatterns = (
        url(r'^view/$', blacklisting(log_requests=True)(my_view), name='log'),
    )
  4. Configure AUTO_BLOCKING_RULES setting in your settings.py for auto-blocking logic:

    AUTO_BLOCKING_RULES = (
        {
            'RULE': {
                'ip': '.*',
            },
            'PERIOD': datetime.timedelta(days=1),
            'BLOCK_AFTER': 10,
            'ENABLED': True,
            'PROPOSAL': True,
            'NOTIFY': (
                ('Mikhail Nacharov', 'mnach@ya.ru'),
            )
        },
    )

And call blacklist.models.RequestLog.objects.create_blocking_rules() periodically to create BlockRules. Please use cron via django-cronjobs or setup django-celery for this purpose.

5. If you need email notification configure django email settings as described in https://docs.djangoproject.com/en/1.8/topics/email/. If you want to send users site where blocking rules have been created you also need to enable and configure django site framework: https://docs.djangoproject.com/en/1.8/ref/contrib/sites/

Requirements

This package is compatible with Django 1.7 and 1.8 and can be ran on python 2.7 and higher.

Release files for django-simple-blacklist 0.1.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-simple-blacklist 0.1.12
File Size Uploaded
django-simple-blacklist-0.1.12.tar.gz 15.6 kB Details

Release files / django-simple-blacklist-0.1.12.tar.gz

Download URL django-simple-blacklist-0.1.12.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b9e337089a3daf699a253c7bfc4d386909807d3f10d9da08e2e062adbcccfee1
BLAKE2b-256 checksum
How to use checksums
72bb896252ae6dcf1e3f742bfa2868a2204dcbaa1f043e6baf0f66a0644f9b2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.12 This release

1 release file

0.1.11

1 release file

0.1.10

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page