A comprehensive system implementing Hybrid CP-ABE with Cloud Database integration
1.5K
A comprehensive enterprise-grade file storage system implementing Hybrid Ciphertext-Policy Attribute-Based Encryption (CP-ABE) integrated with Supabase, providing highly secure file management, multi-layer Attribute-Based Access Control (ABAC), and high-performance caching.
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.
(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.libhybrid-cp-abe (v3.1.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 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-Crypto-Access.git
cd Cloud-Policy-Crypto-Access
Note: The required C++ cryptography library (libhybrid-cp-abe v3.1.0) is already included in the src/lib/ directory of this repository by default. You only need to visit the Hybrid-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 ./keys to securely mount your encryption master keys outside the source code.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, and Nginx. A start.py script is provided to simplify commands.
# Build the Docker images
python start.py build
# Start all containers in detached mode
python start.py up
Once the containers are successfully running (python start.py status), initialize the system. The initdata command will automatically migrate the database, seed ABAC policies, and create a default super admin account.
# Initialize DB, seed policies, and auto-create super admin (admin/admin123)
python start.py initdata
(Optional) If you wish to create a custom super admin manually:
python start.py createsuperuser
http://localhost:8000/auth/login/Detailed 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:2bb9fc939…
Size
286.9 MB
Last updated
6 days ago
docker pull wanthinnn/cloud-policy-crypto-access:pqc-latest