A simple, secure Python datastore protected by Sops or Age
Project description
CacheGuard
A simple and secure Python datastore protected by Sops or Age.
Comes in two varieties: simple key-value and simple text stores.
Cache Types
KeyCache- Simple key-value storeTextCache- Simple text file store
Backends
Cacheguard utilizes backends for encryption. Default backend is currently set to Sops (as the original cache was Sops only). The following backends are available:
Cacheguard will call the appropriate binary for the backend chosen. As such, the files produced are fully compatible with all tooling that either workflow supports
Requires
This is an integration with either Sops or Age, and will require a functional external setup with either program.
For assistance with Sops, see their documentation. For assistance with Age, see their documentation.
CURRENTLY SUPPORTED SOPS IDENTITIES: Age, OpenPGP (AKA GPG)
Additional Sops identities are coming soon.
Age Integration
All age-encrypted material produced by Cacheguard is armored (ascii) and terminal-safe.
No binary blobs are used anywhere as stdin and stdout are heavily used in the library itself.
Any age-compatible program or tool can interact with the resulting files normally in any compatible workflow.
Sops Integrations
At-rest files can be examined if they are decrypted by sops, without needing an active Python session. The type of file is "binary" from a sops perspective, this fully encrypts the body where keys are also not visible without decryption. Additionally, the binary type does not add newline characters to results, as the other Sops types do.
Threat Models
This modules protects data at rest. It does not protect data at run time. It may be possible for other modules/processes/logging/etc to view it.
Potentially useful for operational caches and other sensitive record keeping that needs to be local and transferred via git.
Examples
Basic Logging with TextCache
from cacheguard import TextCache
from datetime import datetime
# Initialize cache with Sops encryption keys
cache = TextCache(
"logs.sops",
age_pubkeys=["age1..."], # List of Age keys, which can include SSH pubkeys as well now
pgp_fingerprints=["ABC123..."] # Your PGP fingerprints
)
# Log some events
cache.append(f"[{datetime.now()}] Application started")
cache.append(f"[{datetime.now()}] User login: user123")
cache.append(f"[{datetime.now()}] Database connection established")
# Save encrypted logs
cache.save()
Key-Value Storage with KeyCache
from cacheguard import KeyCache
# Store sensitive configuration
config_vars = KeyCache("config.sops", age_pubkeys=["age1..."])
config_vars.add({"api_key": "secret123", "db_password": "secure456"})
config_vars.save()
# Load into environment variables
config_vars.deploy() # Makes api_key and db_password available as env vars
Environment Variables
Besides deploying sensitive environment variables, this library can utilize environment variables for simplifying usage. The Sops backend will natively use any environment variable that Sops uses.
Age does not utilize as many, so Cacheguard introduces one:
CACHEGUARD_AGE_IDENTITY_PATH
Which is the file path location to the an age identity file for use with decryption. The identity path can also be programmatically defined at cache decryption function calls.
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
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 cacheguard-0.3.0.tar.gz.
File metadata
- Download URL: cacheguard-0.3.0.tar.gz
- Upload date:
- Size: 50.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8be5db6e046b6c45c84ef7f8122f8e8f500ed9b16a62e20799c0e4a4470ce85
|
|
| MD5 |
2ea42f2471fc6b4d13846606250efbca
|
|
| BLAKE2b-256 |
2214534e203db0e1885bc36728bd2ea862fff9bab4876df5456e2cbdab2f0a9e
|
File details
Details for the file cacheguard-0.3.0-py3-none-any.whl.
File metadata
- Download URL: cacheguard-0.3.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f06a81d5c887ea0397eca77693f3bec321f37f2306b900d54c8ff7fa45575c4
|
|
| MD5 |
0fcad7c06263e4402c1e3b2610eeb074
|
|
| BLAKE2b-256 |
d03bcd15c42422386265da921d3ca7948a6a2c7a2b83724f1d544f3f77573a4e
|