Skip to main content

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:

  1. Exclude migrations/ from PyArmor obfuscation:

    • These files must remain in readable Python as Django loads them dynamically.
    • Already handled in drf_protector.json default: "exclude": ["migrations", "__pycache__"]
  2. Include migrations/ in your Docker build:

    • Make sure to copy migration folders into the Docker image for proper deployment.
  3. Run makemigrations before obfuscating:

    • Prepare all database changes before protecting the code.
  4. Run migrate at container runtime:

    • Once deployed, run python manage.py migrate to apply changes.

❌ Don't Obfuscate:

Avoid obfuscating files in migrations/ as it can break introspection, RunPython, or ORM model detection.

License

MIT


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

drf_protector-0.1.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drf_protector-0.1.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

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

Hashes for drf_protector-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c843a10bb294edc4f62ffd3e1425032d378ad9e41440d50b06a44bc95506d4a2
MD5 2280f1507e4e8bed57a004f65ed574bc
BLAKE2b-256 4c2d5597126f01f71ff357850c75893bc812b06492ea9fd959e5d23a583a416b

See more details on using hashes here.

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

Hashes for drf_protector-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 549ad25acde65b69e0694d5c56055eee52bc0cb40b3bca5ee323d6fae0df4e9c
MD5 447ea4fa60cb8e8e957b2dbb26215e35
BLAKE2b-256 7f9ffdc3cbec18795f5a5f3239ba40954fe9cb3d04d8e7bb393df6c598974aea

See more details on using hashes here.

Supported by

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