# SecretumVault
**Post-quantum cryptographic secrets vault for modern infrastructure**
SecretumVault is a Rust-native secrets vault combining post-quantum cryptography (ML-KEM-768, ML-DSA-65) with classical crypto, multiple secrets engines, cedar-based policy authorization, and flexible storage backends.
## Features
### π Post-Quantum Cryptography
- **ML-KEM-768**: Key encapsulation mechanism for key exchange
- **ML-DSA-65**: Digital signatures with post-quantum resistance
- **Hybrid mode**: Classical + PQC algorithms for future-proof security
- **Multiple backends**: OpenSSL, AWS-LC, RustCrypto (feature-gated)
### π Secrets Engines
- **KV Engine**: Versioned key-value storage with encryption at rest
- **Transit Engine**: Encryption/decryption without storing plaintext
- **PKI Engine**: Certificate authority with X.509 support
- **Database Engine**: Dynamic credentials for PostgreSQL, MySQL, others
- **Extensible**: Add custom engines via trait implementation
### π‘οΈ Authorization & Policies
- **Cedar Integration**: Attribute-based access control (ABAC)
- **Fine-grained policies**: Context-aware decisions (IP, time, environment)
- **Token management**: Lease-based credentials with automatic revocation
- **Audit logging**: Full request/response audit trail
### πΎ Flexible Storage
- **etcd**: Distributed KV store with high availability
- **SurrealDB**: Document database with queries
- **PostgreSQL**: Proven relational database
- **Filesystem**: Development/testing
- **Extensible**: Implement `StorageBackend` trait for any backend
### π Cloud Native
- **Kubernetes-ready**: Native K8s deployments with RBAC
- **Helm charts**: Production-ready templated deployments
- **Docker**: Multi-stage builds for minimal images
- **Prometheus metrics**: Built-in observability
- **Structured logging**: JSON or human-readable format
### π Enterprise Ready
- **TLS/mTLS**: Encrypted client communication
- **Shamir Secret Sharing**: Multi-factor unsealing (2-of-3, 3-of-5, etc.)
- **Auto-unseal**: AWS KMS, GCP Cloud KMS, Azure Key Vault (planned)
- **High availability**: Multi-node clustering (planned)
- **Replication**: Active-passive disaster recovery (planned)
---
## Quick Start
### Local Development with Docker Compose
```bash
# Clone repository
git clone https://github.com/secretumvault/secretumvault.git
cd secretumvault
# Build and start
docker build -t secretumvault:latest -f deploy/docker/Dockerfile .
docker-compose -f deploy/docker/docker-compose.yml up -d
# Verify
curl http://localhost:8200/v1/sys/health
# View logs
docker-compose -f deploy/docker/docker-compose.yml logs -f vault
```
### Kubernetes Deployment
```bash
# Deploy to cluster
kubectl apply -f deploy/k8s/01-namespace.yaml
kubectl apply -f deploy/k8s/02-configmap.yaml
kubectl apply -f deploy/k8s/03-deployment.yaml
kubectl apply -f deploy/k8s/04-service.yaml
kubectl apply -f deploy/k8s/05-etcd.yaml
# Port-forward and access
kubectl -n secretumvault port-forward svc/vault 8200:8200
curl http://localhost:8200/v1/sys/health
```
### Helm Installation
```bash
# Install with default configuration
helm install vault deploy/helm/ \
--namespace secretumvault \
--create-namespace
# Customize backends and engines
helm install vault deploy/helm/ \
--namespace secretumvault \
--create-namespace \
--set vault.config.storageBackend=postgresql \
--set postgresql.enabled=true \
--set vault.replicas=3
```
---
## Core Concepts
### Config-Driven Architecture
All components are selected via `svault.toml` configuration:
```toml
[vault]
crypto_backend = "openssl" # or "aws-lc", "rustcrypto"
[storage]
backend = "etcd" # or "surrealdb", "postgresql"
[seal]
seal_type = "shamir"
threshold = 2
shares = 3
[engines.kv]
path = "secret/"
versioned = true
[engines.transit]
path = "transit/"
```
No recompilation needed for backend changesβjust update config.
### Registry Pattern
Type-safe backend selection using registry pattern:
```rust
// CryptoRegistry dispatches config string to backend
let crypto = CryptoRegistry::create(&config.vault.crypto_backend)?;
// StorageRegistry creates backend from config
let storage = StorageRegistry::create(&config.storage)?;
// EngineRegistry mounts engines from [engines] section
let engines = EngineRegistry::mount_engines(&config.engines)?;
```
### Async/Await
Built on Tokio for high concurrency:
- Non-blocking I/O for all storage operations
- Efficient resource utilization
- Scales to thousands of concurrent connections
### Token-Based Authentication
All API requests require `X-Vault-Token` header:
```bash
curl -H "X-Vault-Token: $VAULT_TOKEN" \
http://localhost:8200/v1/secret/data/myapp
```
Tokens have:
- TTL (time-to-live) with automatic expiration
- Renewable for extended access
- Revocable for immediate invalidation
- Audit-logged for compliance
---
## Architecture Overview
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β API Layer (Axum) β
β /v1/secret/* | /v1/transit/* | /v1/pki/* | /v1/database/* β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββΌβββββββββββββββββββ
β β β
βΌ βΌ βΌ
ββββββββββ ββββββββββ ββββββββββββ
β Auth β β Cedar β β Metrics β
βManager β β Policy β βCollectionβ
ββββββββββ β Engine β ββββββββββββ
ββββββββββ
β
βββββββββββββββββββββββΌβββββββββββββββββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββ ββββββββββββββββββββ βββββββββββββββββ
β KV Engineβ β Transit Engine β β PKI Engine β
β (Crypto)β β (Encrypt/Desc) β β (Certificates)β
ββββββββββββ ββββββββββββββββββββ βββββββββββββββββ
β β β
β βΌ β
β βββββββββββββββββββββββββ β
β β Database Engine β β
β β (Dynamic Secrets) β β
β βββββββββββββββββββββββββ β
β β β
βββββββββββββββββββββββΌβββββββββββββββββββββββ
β
βββββββββββββββββββΌβββββββββββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββ ββββββββββββ βββββββββββββ
β Crypto β β Storage β β Seal β
β Registry β β Registry β β Manager β
ββββββββββββ ββββββββββββ βββββββββββββ
β β β
β βββββββββΌβββββββββ β
β β β β β
βΌ βΌ βΌ βΌ βΌ
ββββββββββ βββββββ βββββββ βββββββ ββββββββββββββ
βOpenSSL β βetcd β β DB β β FS β β Shamir SSS β
ββββββββββ βββββββ βββββββ βββββββ ββββββββββββββ
β
βΌ
βββββββββββββββββββ
β β
βΌ βΌ
βββββββββββ ββββββββββ
βSurrealDBβ βPostgresβ
βββββββββββ ββββββββββ
```
For detailed architecture: `docs/architecture.md`
---
## Configuration
### Minimal Setup
```toml
[vault]
crypto_backend = "openssl"
[server]
address = "0.0.0.0"
port = 8200
[storage]
backend = "etcd"
[storage.etcd]
endpoints = ["http://localhost:2379"]
[seal]
seal_type = "shamir"
threshold = 2
shares = 3
[engines.kv]
path = "secret/"
versioned = true
```
### Production Setup
```toml
[vault]
crypto_backend = "aws-lc" # Post-quantum support
[server]
address = "0.0.0.0"
port = 8200
tls_cert = "/etc/secretumvault/tls.crt"
tls_key = "/etc/secretumvault/tls.key"
tls_client_ca = "/etc/secretumvault/client-ca.crt"
[storage]
backend = "postgresql"
[storage.postgresql]
connection_string = "postgres://vault:${DB_PASSWORD}@db.example.com:5432/secretumvault"
[seal]
seal_type = "shamir"
threshold = 3
shares = 5
[engines.kv]
path = "secret/"
versioned = true
[engines.transit]
path = "transit/"
[engines.pki]
path = "pki/"
[engines.database]
path = "database/"
[logging]
level = "info"
format = "json"
output = "stdout"
[telemetry]
prometheus_port = 9090
enable_trace = true
[auth]
default_ttl = 24
cedar_policies_dir = "/etc/secretumvault/policies"
```
Full reference: `docs/configuration.md`
---
## API Examples
### Initialize Vault
```bash
curl -X POST http://localhost:8200/v1/sys/init \
-H "Content-Type: application/json" \
-d '{
"shares": 3,
"threshold": 2
}'
```
Response:
```json
{
"keys": ["key1", "key2", "key3"],
"root_token": "root_token_abc123"
}
```
### Store Secret (KV Engine)
```bash
curl -X POST http://localhost:8200/v1/secret/data/myapp \
-H "X-Vault-Token: $VAULT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"data": {
"username": "admin",
"password": "supersecret"
}
}'
```
### Read Secret
```bash
curl http://localhost:8200/v1/secret/data/myapp \
-H "X-Vault-Token: $VAULT_TOKEN"
```
### Encrypt with Transit Engine
```bash
curl -X POST http://localhost:8200/v1/transit/encrypt/my-key \
-H "X-Vault-Token: $VAULT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"plaintext": "dGhlIHF1aWNrIGJyb3duIGZveA=="}'
```
Full API reference: `docs/API.md`
---
## Deployment
### Docker
```bash
docker build -t secretumvault:latest -f deploy/docker/Dockerfile .
docker run -p 8200:8200 \
-v /etc/secretumvault:/etc/secretumvault:ro \
secretumvault:latest
```
### Docker Compose
```bash
docker-compose -f deploy/docker/docker-compose.yml up -d
```
Includes: vault, etcd, surrealdb, postgres, prometheus, grafana
### Kubernetes
```bash
kubectl apply -f k8s/
# Or: helm install vault helm/
```
### Complete Deployment Guide
See `DEPLOYMENT.md` for:
- Docker build and run
- Docker Compose multi-environment setup
- Kubernetes manifests and scaling
- Helm installation and customization
- TLS/mTLS configuration
- Prometheus monitoring
- Troubleshooting
---
## How-To Guides
Quick task guides for common operations:
- **[Getting Started](docs/HOWOTO.md#getting-started)** - Initial setup and first secrets
- **[Initialize Vault](docs/HOWOTO.md#initialize-vault)** - Create unseal keys and root token
- **[Unseal Vault](docs/HOWOTO.md#unseal-vault)** - Recover after restart
- **[Manage Secrets](docs/HOWOTO.md#manage-secrets)** - Create, read, update, delete
- **[Configure Engines](docs/HOWOTO.md#configure-engines)** - Mount and customize engines
- **[Setup Authorization](docs/HOWOTO.md#setup-authorization)** - Cedar policies and tokens
- **[Configure TLS](docs/HOWOTO.md#configure-tls)** - Enable encryption
- **[Integrate with Kubernetes](docs/HOWOTO.md#integrate-with-kubernetes)** - Pod secret injection
- **[Backup & Restore](docs/HOWOTO.md#backup--restore)** - Data protection
- **[Monitor & Troubleshoot](docs/HOWOTO.md#monitor--troubleshoot)** - Observability
Full guide: `docs/HOWOTO.md`
---
## Project Structure
```
secretumvault/
βββ src/
β βββ main.rs # Server binary entry point
β βββ config.rs # TOML config parsing and validation
β βββ error.rs # Error types and conversions
β βββ api/ # HTTP API layer (Axum)
β β βββ server.rs # Server setup and routing
β β βββ handlers/ # Endpoint handlers
β β βββ middleware/ # Auth and Cedar middleware
β βββ auth/ # Authentication and authorization
β β βββ token.rs # Token generation and validation
β β βββ cedar.rs # Cedar policy evaluation
β βββ crypto/ # Cryptographic backends
β β βββ backend.rs # CryptoBackend trait and registry
β β βββ openssl.rs # OpenSSL implementation
β β βββ aws_lc.rs # AWS-LC post-quantum backend
β βββ storage/ # Storage backends
β β βββ mod.rs # StorageBackend trait and registry
β β βββ filesystem.rs # Filesystem implementation
β β βββ etcd.rs # etcd implementation
β β βββ surrealdb.rs # SurrealDB implementation
β β βββ postgresql.rs # PostgreSQL implementation
β βββ engines/ # Secrets engines
β β βββ mod.rs # Engine trait and registry
β β βββ kv.rs # KV versioned store
β β βββ transit.rs # Encryption as a service
β β βββ pki.rs # Certificate authority
β β βββ database.rs # Dynamic database credentials
β βββ core/ # Core vault logic
β β βββ vault.rs # VaultCore and initialization
β β βββ seal.rs # Shamir SSS seal/unseal
β β βββ router.rs # Request routing to engines
β βββ telemetry.rs # Metrics, logging, audit
β βββ lib.rs # Library exports
βββ deploy/ # Deployment configurations
β βββ docker/ # Docker deployment
β β βββ Dockerfile # Multi-stage container build
β β βββ docker-compose.yml # Complete dev environment
β β βββ config/ # Docker-specific config
β βββ helm/ # Helm charts for Kubernetes
β βββ k8s/ # Raw Kubernetes manifests
β βββ 01-namespace.yaml
β βββ 02-configmap.yaml
β βββ 03-deployment.yaml
β βββ 04-service.yaml
β βββ 05-etcd.yaml
β βββ 06-surrealdb.yaml
β βββ 07-postgresql.yaml
βββ helm/ # Helm chart
β βββ Chart.yaml
β βββ values.yaml
β βββ templates/
βββ docs/ # Product documentation
β βββ README.md # Documentation index
β βββ ARCHITECTURE.md # System architecture
β βββ CONFIGURATION.md # Configuration reference
β βββ API.md # API reference
β βββ HOWOTO.md # How-to guides
β βββ SECURITY.md # Security guidelines
βββ DEPLOYMENT.md # Deployment guide
βββ README.md # This file
βββ Cargo.toml # Rust manifest
```
---
## Development
### Build
```bash
cargo build --all-features
```
### Test
```bash
cargo test --all-features
```
### Lint
```bash
cargo clippy -- -D warnings
```
### Format
```bash
cargo fmt
```
### Run
```bash
cargo run --all-features -- server --config svault.toml
```
### Documentation
```bash
cargo doc --all-features --open
```
---
## Feature Flags
Enable optional features via Cargo:
```bash
cargo build --features aws-lc,pqc,surrealdb-storage,etcd-storage,postgresql-storage
```
Available features:
- `aws-lc` - AWS-LC cryptographic backend with post-quantum support
- `pqc` - Post-quantum cryptography (ML-KEM-768, ML-DSA-65)
- `surrealdb-storage` - SurrealDB storage backend
- `etcd-storage` - etcd storage backend
- `postgresql-storage` - PostgreSQL storage backend
- `server` - Server binary
- `cli` - Command-line tools
- `cedar` - Cedar policy evaluation
---
## Security
### Design Principles
- **Encryption at rest**: All secrets encrypted with master key
- **Least privilege**: Cedar policies enforce fine-grained access
- **Audit logging**: All operations logged and auditable
- **Secure defaults**: Non-root execution, read-only filesystem, dropped capabilities
- **Post-quantum ready**: Support for ML-KEM and ML-DSA
### Security Guidelines
See `docs/SECURITY.md` for:
- Key management best practices
- Unsealing strategy
- Token security
- TLS/mTLS setup
- Audit log review
- Vulnerability reporting
---
## Roadmap
### Near-term (Next)
- [ ] Additional secrets engines (SSH, Kubernetes Auth)
- [ ] Auto-unseal mechanisms (AWS KMS, GCP Cloud KMS, Azure)
- [ ] Secret rotation policies
- [ ] Backup/restore utilities
- [ ] Client SDKs (Go, Python, Node.js)
### Medium-term
- [ ] Active-passive replication
- [ ] Multi-node clustering with Raft consensus
- [ ] OAuth2/OIDC integration
- [ ] Cloud IAM integration (AWS, GCP, Azure)
- [ ] External Secrets Operator for K8s
### Long-term
- [ ] Active-active multi-region replication
- [ ] Custom plugin system
- [ ] FIPS 140-2 certification
- [ ] HSM/TPM integration
- [ ] Chaos engineering test suite
---
## Contributing
Contributions welcome! Please:
1. Fork repository
2. Create feature branch: `git checkout -b feature/name`
3. Make changes following `CLAUDE.md` guidelines
4. Test: `cargo test --all-features`
5. Lint: `cargo clippy -- -D warnings`
6. Submit pull request
---
## License
[License specification - add appropriate license]
---
## Support
- **Documentation**: Full guides in `docs/`
- **Issues**: GitHub issue tracker
- **Security**: Report vulnerabilities via security contact
- **Community**: Discussions and Q&A
---
## Acknowledgments
SecretumVault combines proven patterns from:
- HashiCorp Vault (inspiration for API and engine design)
- NIST PQC standardization (ML-KEM-768, ML-DSA-65)
- AWS Cedar (policy language and authorization)
- Kubernetes ecosystem (native cloud deployment)
---
**Built with β€οΈ in Rust for modern cryptographic secrets management**