a.k.a wanthinnn/cloud-policy-crypto-access
175
A comprehensive enterprise-grade file storage system implementing Hybrid Ciphertext-Policy Attribute-Based Encryption (CP-ABE) integrated with Supabase, AWS S3, Google Cloud Storage, and Local Storage, providing highly secure file management, multi-layer Attribute-Based Access Control (ABAC), and high-performance caching.
Note
**PQC Only Repository:** This `main` branch exclusively supports Post-Quantum Cryptography (PQC) features. The legacy CP-ABE only version is maintained in the `legacy` branch.
Warning
**Post-Quantum TLS Requirement:** This system strictly enforces **Hybrid ML-KEM-768 (Kyber)** key exchange and **ML-DSA-87** certificates. You **MUST use Chrome or Edge version 150+** to successfully complete the TLS handshake. Older browsers or browsers without ML-DSA support will fail to connect.
This repository contains a robust Django-based implementation of a secure file sharing system. The system shifts away from traditional role-based security by enabling fine-grained access control mathematically bound to user attributes, providing zero-trust security for sensitive data.
See more demo images in img/.
(A and B) or C) with visual UI builder integration.OR logic when new access rights are granted to existing files.auth, storage, policy, user, attributes, audit, system), enriching events with contextual user_id and user_name for immediate ingestion by SIEM systems (e.g., Wazuh, Splunk, ELK).O(1) time, with a deep verification fallback.ML-DSA-87 signatures) and a Standard VPN (prime256v1 ECC), alongside internal dnsmasq for dynamic subdomain routing (e.g., cloudsafe.cyberfortress.local, vault.cyberfortress.local).latest (stable branches) and pqc-latest (experimental branches) to Docker Hub via our integrated release shell script.libhybrid-pq-cp-abe (v4.0.0) bridged via Python ctypesflowchart LR
classDef client fill:#f9f9f9,stroke:#333,stroke-width:2px;
classDef gateway fill:#e1f5fe,stroke:#0288d1,stroke-width:2px;
classDef datalayer fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px;
classDef core fill:#fff3e0,stroke:#f57c00,stroke-width:2px,stroke-dasharray: 5 5;
subgraph Clients ["📱 Clients"]
direction TB
Web("🌐 Web Frontend"):::client
Mob("📱 Mobile / CLI"):::client
end
subgraph Gateway ["🛡️ Django API Server"]
direction TB
Auth("🔑 JWT Auth"):::gateway
Casbin("🛂 Casbin ABAC"):::gateway
Ctrl("📦 File Controller"):::gateway
CPABE("🔐 CP-ABE & PQC C++ Lib"):::core
Auth --> Casbin
Casbin --> Ctrl
Ctrl <-->|In-Memory Buffer| CPABE
end
subgraph DataLayer ["🗄️ Infrastructure"]
direction TB
Vault[("🛡️ HashiCorp Vault<br/>(Master Keys)")]:::datalayer
Redis[("⚡ Redis Cache<br/>(User Keys & Policies)")]:::datalayer
DB[("🐘 Supabase DB<br/>(Metadata)")]:::datalayer
Storage[("☁️ Supabase Storage<br/>(Ciphertexts)")]:::datalayer
end
Web -->|HTTPS / REST| Auth
Mob -->|HTTPS / REST| Auth
Casbin -.->|Cache| Redis
Casbin -.->|Verify| DB
Ctrl <-->|Fetch DEK/CP-ABE Key| Vault
Ctrl <-->|Cache User Key| Redis
Ctrl <-->|CRUD Metadata| DB
Ctrl <-->|Upload/Download| Storage
HttpOnly Cookie (for JWT) and an X-CSRFToken header. The Auth Middleware verifies the identity, and the Casbin ABAC Engine evaluates the user's attributes against the stored policies (cached in Redis) to determine access rights.Follow these instructions to deploy the system from scratch on a brand new machine.
# Clone this main repository
git clone https://github.com/WanThinnn/Cloud-Policy-Quantum-Access.git
cd Cloud-Policy-Quantum-Access
Note: The required C++ cryptography library (libhybrid-cp-abe v4.0.0) is already included in the src/lib/ directory of this repository by default. You only need to visit the Hybrid-PQ-CP-ABE-Library repository if you wish to compile or update to a newer version.
Create the .env file from the example template:
cp .env.example .env
Open .env in your text editor and fill in the missing critical values:
DJANGO_SECRET_KEY: Generate a long random string.DATABASE_URL: Get this from your Supabase Dashboard -> Settings -> Database -> Connection string (URI). Make sure it ends with ?sslmode=require if using Supabase.SUPABASE_URL: Your Supabase project URL (e.g., https://xxxx.supabase.co).SUPABASE_SERVICE_KEY: Your Supabase Service Role Key (Dashboard -> Settings -> API). Do not use the public anon key!KEYS_DIR: Keep as ./config/keys to securely mount your encryption master keys outside the source code.MASTER_FIELD_ENCRYPTION_KEY: If using HashiCorp Vault, leave this blank and the system will auto-generate a secure 256-bit AES key and push it to Vault during initdata. If NOT using Vault, you must provide a URL-safe Base64 32-byte key.ENABLE_PQC_FEATURES: Set to True (default) to enable ML-DSA dual-layer signatures during file uploads. Set to False to fallback to standard CP-ABE encryption.USE_EXTERNAL_TLS: Set to True (default) to enable Nginx HTTPS and Post-Quantum TLS. Set to False to disable the external reverse proxy and test locally via HTTP (port 8080). Note: Internal services will still use zero-trust TLS.SSL_CERT_FILE & SSL_KEY_FILE: (Optional) By default, the system uses self-signed CyberFortress certs. To use your own certificates in production, place your .crt and .key files in the ./certs folder and specify their filenames here.Before running the system, configure your storage:
secure-storage).The system uses Docker Compose to orchestrate Django, Redis, Nginx, Vault, and OpenVPN. A start.py script is provided to simplify commands.
# Build the Docker images (including VPN layers)
python start.py --vpn build
# Start all containers in detached mode (including VPN)
python start.py --vpn up
Once the containers are successfully running (python start.py --vpn status), initialize the system. The initdata command will automatically migrate the database, seed ABAC policies, configure HashiCorp Vault, and create a default super admin account.
# Initialize DB, seed policies, and auto-create super admin (super_admin/super_admin123)
python start.py --vpn initdata
(Optional) If you wish to create a custom super admin manually:
python start.py createsuperuser
If you wish to access the internal network securely via OpenVPN, you can generate client profiles automatically. Ensure VPN_PUBLIC_IP and DOMAIN_NAME are correctly set in your .env.
# Generate both PQC and Standard client profiles for a user (e.g., 'johndoe')
python start.py --vpn vpn_client johndoe
This command outputs two .ovpn files to your host machine (johndoe_pqc.ovpn and johndoe_classic.ovpn), complete with embedded keys and TLS-Crypt-V2 metadata.
(Advanced) You can also generate your own PQC Root CA and Server certificates to a specific directory:
python start.py gencerts ./my_custom_certs
USE_EXTERNAL_TLS=True (default), open your web browser and navigate to: https://localhost or https://cloudsafe.cyberfortress.local (if connected via VPN or configured in hosts).USE_EXTERNAL_TLS=False, navigate to: http://localhost:8080Detailed Swagger/OpenAPI documentation is available at /api/docs/ when the server is running.
keys directory is properly secured in production. The cpabe_msk.key (Master Key) must never be exposed. Development keys in src/keys/ are automatically git-ignored../keys folder. However, if you migrate your server or move to a completely new machine, you MUST manually copy the cpabe_pub.key and cpabe_msk.key from your old machine to the new ./keys directory. If you lose the old Master Key, all previously encrypted files in your storage will become permanently inaccessible.HTTPS in production to prevent Man-in-the-Middle (MITM) attacks during token transmission.This project is licensed under the MIT License - see the LICENSE file for details.
Content type
Image
Digest
sha256:d07e331e3…
Size
395 MB
Last updated
about 2 months ago
docker pull wanthinnn/cloud-policy-quantum-access