DjBrut
DjBrut logo
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.
Metadata
Release files for djbrut 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| djbrut-1.0.0.tar.gz | 7.7 kB | Without provenance | Details for djbrut-1.0.0.tar.gz |
Release files / djbrut-1.0.0.tar.gz
| Download URL | djbrut-1.0.0.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b9dafe927e75b1718f0794d16212bde49b8e457d81c04adc8b6641218589208b
|
|
BLAKE2b-256 checksum How to use checksums |
76baf910e67250984909d7cc9dd5c501514ba66443d02ab5564e9b9137e8e4e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for djbrut 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.