Masonite Security
Secure masonite apps from spamming Bots, IP's and SQL injections.
Features
- Block IP's
- Block Bots
- Throttle Requests
- Block SQL Injections
Installation
pip install masonite-security
Configuration
Add SecurityProvider to your project in config/providers.py:
# config/providers.py
# ...
from security import SecurityProvider
# ...
PROVIDERS = [
# ...
# Third Party Providers
SecurityProvider,
# ...
]
Then you can publish the package resources by doing:
python craft package:publish security
Register Middleware.
You can setup the security middleware globally or per route basis.
Global Setup
Open Kernal.py file and add SecurityMiddleware in "route_middleware" section:
route_middleware = {
"web": [SessionMiddleware, LoadUserMiddleware, VerifyCsrfToken, SecurityMiddleware],
"auth": [AuthenticationMiddleware],
}
Per Route Setup
In your routes add protect middleware like this:
Route.get("/", "WelcomeController@show").middleware("protect")
Configure Security Config
Update your config/security.py file based on your needs:
# config/security.py
# ...
BLOCK_IP = True
BLOCK_BOTS = True
THROTTLE_REQUESTS = True
MAX_REQUESTS = 20 # Max requests per IP (default: 20)
IP_BLOCK_DURATION = 60 # seconds (default: 60)
# list of IP addresses to block (default: [])
BLOCKED_IPS = [
#...
]
# list of Bot Agents to block
BLOCKED_BOTS = [
#...
]
# ...
Contributing
Please read the Contributing Documentation here.
Maintainers
License
security is open-sourced software licensed under the MIT license.
Metadata
Release files for masonite-security 0.0.1
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 |
|---|---|---|---|---|
| masonite-security-0.0.1.tar.gz | 8.8 kB | Without provenance | Details for masonite-security-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| masonite_security-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for masonite_security-0.0.1-py3-none-any.whl |
Total release size: 18.8 kB
Release files / masonite-security-0.0.1.tar.gz
| Download URL | masonite-security-0.0.1.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4e42e9baaeb4b75c97c9389bd81e47ad63b1a08ab7cf7c5079eb2410f903c80e
|
|
BLAKE2b-256 checksum How to use checksums |
f29c7b72e7c1837cbe7f60bbea554fed2d21ff5abb563b23f052bf8f53b5b561
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / masonite_security-0.0.1-py3-none-any.whl
| Download URL | masonite_security-0.0.1-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a90ec13f89359cb7216a1c6e7448d72f9607c27a79860230605c94a2f97d1090
|
|
BLAKE2b-256 checksum How to use checksums |
4b289967d12083844244e5431c08b91f356b32422363591835a5f1da63d53885
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Security for masonite-security 0.0.1
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.