Secure and extensible credential management SDK for Python applications.
Project description
🔐 infra-core-sdk
🚀 Features
- 🔐 Automatic encryption (Fernet)
- 📦 Multiple credential support (
name) - ⚙️ Decoupled setup and load flows
- 📁 Automatic path management
- 🧠 Dynamic path configuration (PathConfig)
- 🧩 Modular and extensible architecture
📦 Installation
pip install infra-core-sdk
🧩 Usage
🔹 Define your credentials model
from dataclasses import dataclass
from infra_core import BaseCredentials
@dataclass(frozen=True)
class MyCreds(BaseCredentials):
api_token: str
🔹 Save credentials (setup)
from infra_core import FernetEncryption
from infra_core.credentials.setup.credentials_setup_service import CredentialsSetupService
setup = CredentialsSetupService(FernetEncryption)
setup.setup(
MyCreds(api_token="1234"),
name="system1"
)
🔹 Load credentials
from infra_core import CredentialsLoader, FernetEncryption
creds = CredentialsLoader.load(
MyCreds,
FernetEncryption,
name="pipefy"
)
print(creds.api_token)
📁 Generated structure
your_project/
├── secret/
│ ├── secret.key
│ ├── pipefy.json
🔄 Multiple credentials
setup.setup(..., name="aws")
setup.setup(..., name="stripe")
⚙️ Path Configuration (Advanced)
The SDK provides a powerful and dynamic configuration system via PathConfig.
🔧 Basic usage
from infra_core import PathConfig
config = PathConfig.getDefault()
print(config.root_markers)
print(config.directories)
➕ Add custom directory
config = config.addDirectory("logs", "logs")
print(config.directories)
🔄 Update directories
config = config.updateDirectory(config.downloadKey, "new_downloads")
print(config.directories)
🔁 Dependency update (secret_dir)
config = config.updateDirectory(config.secretDirKey, "new_secret")
print(config.directories)
Derived directories are automatically updated:
- secret_key
- credentials
🌱 Root marker management
config = config.addRootMarker(".custom")
print(config.root_markers)
config = config.removeRootMarker(".custom")
print(config.root_markers)
🧪 Full example
from infra_core import PathConfig
if __name__ == "__main__":
config = PathConfig.getDefault()
print(f"{config.root_markers=}")
print(f"{config.directories=}")
config = config.addDirectory("logs", "logs")
print("After add dir:", config.directories)
config = config.updateDirectory(config.downloadKey, "new_downloads")
print("After update dir:", config.directories)
config = config.updateDirectory(config.secretDirKey, "new_secret")
print("After update dir:", config.directories)
config = config.addRootMarker(".custom")
print("After add root:", config.root_markers)
config = config.removeRootMarker(".custom")
print("After remove root:", config.root_markers)
🔐 Encryption
Default
from infra_core import FernetEncryption
Custom implementation
class CustomEncryption:
def encrypt(self, value: str) -> str:
...
def decrypt(self, value: str) -> str:
...
⚠️ Important rules
❌ Do NOT manually create keys
Fernet.generate_key()
FernetEncryption(key)
✅ Let the SDK manage it
CredentialsSetupService(FernetEncryption)
🧠 How it works
SETUP:
→ generates key
→ encrypts data
→ saves file
LOAD:
→ reads key
→ decrypts data
→ returns typed object
🧪 Development
pip install -e .[dev]
pytest
mypy src/
📄 License
MIT
👨💻 Author
Rafael Cavalcante
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
infra_core_sdk-0.1.3.tar.gz
(26.7 kB
view details)
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 infra_core_sdk-0.1.3.tar.gz.
File metadata
- Download URL: infra_core_sdk-0.1.3.tar.gz
- Upload date:
- Size: 26.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
846bee86003e723b54d2d9ae12c96b1ad38f02ab57a3ee019bdb1afd7e178121
|
|
| MD5 |
189289bb28704ed86262d69f09b1cca5
|
|
| BLAKE2b-256 |
3fa215b64d717748ce753d0dfb871741ba2ef810c3b8dc8f1c2a2859d912a761
|
File details
Details for the file infra_core_sdk-0.1.3-py3-none-any.whl.
File metadata
- Download URL: infra_core_sdk-0.1.3-py3-none-any.whl
- Upload date:
- Size: 24.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21a3fc495681a9c465a7b1c08be1df575eaea7a3100147f7112624dfb0e7812f
|
|
| MD5 |
939e1179fab5bdc215f0051d7caa523c
|
|
| BLAKE2b-256 |
30dbc59ca588e9a6e74cfa7927a42607081969a7176e120dcebdfa596e261015
|