Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

A simple Django app which implements blacklists

Project Description

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 History

Release History

This version
History Node

0.1.12

History Node

0.1.11

History Node

0.1.10

History Node

0.1.9

History Node

0.1.8

History Node

0.1.7

History Node

0.1.6

History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

History Node

0.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-simple-blacklist-0.1.12.tar.gz (15.6 kB) Copy SHA256 Checksum SHA256 Source Nov 11, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting