Secure and extensible credential management SDK for Python applications.
Project description
🔐 infra_core
infra_core é um SDK Python para gerenciamento seguro de credenciais com suporte a criptografia automática, múltiplos ambientes e arquitetura extensível.
🚀 Features
- 🔐 Criptografia automática (Fernet)
- 📦 Suporte a múltiplas credenciais (
name) - ⚙️ Setup e Load desacoplados
- 📁 Gerenciamento automático de paths
- 🧩 Arquitetura modular e extensível
- 🔄 Compatível com
pip install -e(desenvolvimento)
📦 Instalação
🔹 Desenvolvimento (recomendado)
Dentro do projeto que irá usar o SDK:
pip install -e caminho/para/infra_core
Exemplo:
pip install -e C:\Users\rafael.m.cavalcante\PycharmProjects\infra_core
🔹 Produção
pip install infra-core
🧱 Estrutura esperada
Após o uso:
seu_projeto/
├── main.py
├── secret/
│ ├── secret.key
│ ├── aws.json
│ ├── pipefy.json
🧠 Conceitos principais
🔑 Secret Key
- Gerada automaticamente no primeiro uso
- Armazenada em
secret/secret.key - Nunca deve ser criada manualmente
📄 Credenciais
- Cada credencial é armazenada em um arquivo separado
- Nome controlado pelo parâmetro
name
name="aws" → secret/aws.json
🧩 Criando um modelo de credenciais
from dataclasses import dataclass
from infra_core import BaseCredentials
@dataclass(frozen=True)
class MyCreds(BaseCredentials):
api_token: str
💾 Salvando credenciais (Setup)
from infra_core import FernetEncryption
from infra_core.credentials.setup.credentials_setup_service import CredentialsSetupService
setup = CredentialsSetupService(FernetEncryption)
setup.setup(
MyCreds(api_token="123"),
name="pipefy"
)
🔓 Carregando credenciais (Load)
from infra_core import CredentialsLoader, FernetEncryption
creds = CredentialsLoader.load(
MyCreds,
FernetEncryption,
name="pipefy"
)
print(creds.api_token)
🔄 Multi-credenciais
setup.setup(..., name="aws")
setup.setup(..., name="pipefy")
setup.setup(..., name="stripe")
🔐 Encryption
Default
from infra_core import FernetEncryption
Custom (avançado)
class CustomEncryption:
def encrypt(self, value: str) -> str:
...
def decrypt(self, value: str) -> str:
...
⚠️ Regras importantes
❌ Não faça
Fernet.generate_key()
FernetEncryption(key)
✅ Faça
CredentialsSetupService(FernetEncryption)
🧪 Testes
pytest tests
🧠 Arquitetura
infra_core/
├── core/ # Path management
├── credentials/
│ ├── models/ # BaseCredentials
│ ├── services/ # Load / Save
│ ├── setup/ # Setup flow
│ └── exceptions/
├── security/ # Encryption
⚠️ Problemas comuns
ModuleNotFoundError
pip install -e caminho/infra_core
Dependência não encontrada
pip install cryptography
PyCharm não reconhece imports
File → Invalidate Caches → Restart
🎯 Fluxo completo
SETUP:
→ gera key
→ criptografa
→ salva arquivo
LOAD:
→ lê key
→ descriptografa
→ retorna objeto tipado
🚀 Roadmap
- CLI (
infra-core setup) - Registry de credenciais
- Multi-env (dev/prod)
- Publish no PyPI
📄 Licença
MIT
👨💻 Autor
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
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.0.tar.gz.
File metadata
- Download URL: infra_core_sdk-0.1.0.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ca18b2b7631d88adcfc695a1c9528a23496ab0e4b4c02ce85ac1419d84d867e
|
|
| MD5 |
95472642b53e944978e311b4505768d0
|
|
| BLAKE2b-256 |
ccf59bb071d817c5007aadd08affd1ae5770215d2e7f7ed4233294b7203ac412
|
File details
Details for the file infra_core_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: infra_core_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.1 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 |
b02dc8271789c20c757a0d6b6d9f00303ca6273adc754e3a0075ed97c2b640f9
|
|
| MD5 |
fe8239c243d1eaaf839b544b69781c05
|
|
| BLAKE2b-256 |
27ccd82f5be2d191492748de787a47ef04a834ff8a2fe0e506a26ea105d91758
|