Obfuscate and package Django/DRF apps securely with PyArmor + Docker
Project description
DRF Protector
Secure your Django REST Framework (DRF) projects with PyArmor and Docker. This tool lets you obfuscate your source code, add licensing with PyArmor, and package everything into a Docker container for deployment.
🧩 Django Web + DRF Support
This tool is designed to work with both Django REST Framework (DRF) APIs and traditional Django web applications. Whether your project includes APIs, templates, or both — you can use drf-protector to obfuscate your backend logic, protect source code, and deploy it securely using Docker.
Just ensure the drf_protector.json is correctly configured for your app structure.
- ✅ Works with
urls.py,views.py, models, and API views - ✅ Compatible with Django templates, static files, and DRF serializers
- ✅ Obfuscation targets Python code only — static and templates are preserved as-is
Features
- 🔐 Obfuscate Python code using PyArmor
- 🧾 License-based execution control
- 🐳 Generate secure Docker containers
- 🛠️ Easy CLI for local development and deployment
Usage
drf-protector init # Generate drf_protector.json config
drf-protector obfuscate # Obfuscate code
drf-protector dockerize # Build secure docker image
⚠️ Handling Django Migrations with PyArmor
When obfuscating your Django app, it's important to handle migrations/ correctly to avoid runtime issues.
✅ Best Practices:
-
Exclude
migrations/from PyArmor obfuscation:- These files must remain in readable Python as Django loads them dynamically.
- Already handled in
drf_protector.jsondefault:"exclude": ["migrations", "__pycache__"]
-
Include
migrations/in your Docker build:- Make sure to copy migration folders into the Docker image for proper deployment.
-
Run
makemigrationsbefore obfuscating:- Prepare all database changes before protecting the code.
-
Run
migrateat container runtime:- Once deployed, run
python manage.py migrateto apply changes.
- Once deployed, run
❌ Don't Obfuscate:
Avoid obfuscating files in migrations/ as it can break introspection, RunPython, or ORM model detection.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file drf_protector-0.1.1.tar.gz.
File metadata
- Download URL: drf_protector-0.1.1.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c843a10bb294edc4f62ffd3e1425032d378ad9e41440d50b06a44bc95506d4a2
|
|
| MD5 |
2280f1507e4e8bed57a004f65ed574bc
|
|
| BLAKE2b-256 |
4c2d5597126f01f71ff357850c75893bc812b06492ea9fd959e5d23a583a416b
|
File details
Details for the file drf_protector-0.1.1-py3-none-any.whl.
File metadata
- Download URL: drf_protector-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
549ad25acde65b69e0694d5c56055eee52bc0cb40b3bca5ee323d6fae0df4e9c
|
|
| MD5 |
447ea4fa60cb8e8e957b2dbb26215e35
|
|
| BLAKE2b-256 |
7f9ffdc3cbec18795f5a5f3239ba40954fe9cb3d04d8e7bb393df6c598974aea
|