Skip to main content

Framework for views in big projects on Django.

Project description

DjBrut logo

DjBrut logo

Build Status PyPI version Status Code size License

DjBrut – simple brutforce protection for Django project.

Default checkers:

  • Max requests for IP.

  • Max requests for user.

  • Max requests for one CSRF-token (stupid but effective).

  • Max requests frequency limitation.

DjBrut use Redis as storage for all counters.

Installation

pip install djbrut

Usage

from django.http import HttpResponse
from djbrut import Attempt

def some_view(request):
    attempt = Attempt('some rule type name', request)
    # check
    if not attempt.check():
        # error
        return HttpResponse(attempt.error)
    # success
    ...

You can see example project for more details.

Configuring

Just set up rules:

BRUTEFORCE_LIMITS = {
    'default': Rule(
        user=100,       # max requests for one user by BRUTEFORCE_TIMELIMIT
        ip=300,         # max requests for one IP by BRUTEFORCE_TIMELIMIT
        csrf=50,        # max requests with one CSRF token by BRUTEFORCE_TIMELIMIT
        freq=0,         # max request frequency for client [seconds]
    ),
    'some rule type name': Rule(
        user=100,       # max requests for one user by BRUTEFORCE_TIMELIMIT
        ip=300,         # max requests for one IP by BRUTEFORCE_TIMELIMIT
        csrf=50,        # max requests with one CSRF token by BRUTEFORCE_TIMELIMIT
        freq=0,         # max request frequency for client [seconds]
    ),
}

Attempt get rule type name as first arg. If rule type name not found in keys of BRUTEFORCE_LIMITS, ‘default’ will be used. If you don’t set default rule then passed rule type must be exists in BRUTEFORCE_LIMITS keys.

BRUTEFORCE_TIMELIMIT – time to live for all attempts counters.

You can see default settings for more params such as custom error message.

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

djbrut-1.0.0.tar.gz (7.7 kB view details)

Uploaded Source

File details

Details for the file djbrut-1.0.0.tar.gz.

File metadata

  • Download URL: djbrut-1.0.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for djbrut-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b9dafe927e75b1718f0794d16212bde49b8e457d81c04adc8b6641218589208b
MD5 da6d8ac05e4c88722e961df324f717da
BLAKE2b-256 76baf910e67250984909d7cc9dd5c501514ba66443d02ab5564e9b9137e8e4e0

See more details on using hashes here.

Supported by

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