dochain-block
Prefect Blocks for authentication and connection management.
Overview
dochain-block is a Prefect Block distribution package that provides reusable authentication and connection blocks for various services. The project is designed with a modular architecture to easily add new authentication modules.
Features
- Modular Authentication Blocks: Each service has its own dedicated authentication block
- Secure Credential Management: Built on Prefect's secure block system
- Multiple Authentication Methods: Support for username/password, API keys, tokens, and more
- Async-First Design: Optimized for Prefect's async execution model
- Easy Integration: Seamless integration with Prefect flows and deployments
Installation
# Create virtual environment
uv venv
source .venv/bin/activate # Unix/macOS
# or
.\.venv\Scripts\activate # Windows
# Install the package
uv pip install -e .
Available Authentication Blocks
NacosBlock
Connect to Nacos service discovery and configuration management platform.
Supported Authentication Methods:
- Username/Password
- Access Key/Secret Key
- Bearer Token
Features:
- Configuration management
- Service discovery
- Health checks
- Namespace support
Usage Example
from prefect import flow
from dochain_block import NacosBlock
@flow
def nacos_config_flow():
# Load Nacos block
nacos = NacosBlock.load("my-nacos-connection")
# Get configuration
config = asyncio.run(nacos.get_config("app-config", "DEFAULT_GROUP"))
return config
# Save block configuration
nacos_block = NacosBlock(
name="my-nacos-connection",
server_url="http://localhost:8848/nacos",
username="nacos",
password="nacos",
namespace="public"
)
nacos_block.save("my-nacos-connection")
Development
Adding New Authentication Modules
- Create a new module in
src/dochain_block/auth/ - Inherit from
AuthBlockbase class - Implement required methods:
authenticate(): Main authentication logic- Optional:
validate_credentials(),refresh_credentials()
- Register the block in
__init__.py
Example: New Authentication Module
from ..core.base_block import AuthBlock
from pydantic import Field, SecretStr
class MyServiceBlock(AuthBlock):
"""Authentication block for MyService"""
api_key: SecretStr = Field(..., description="API key for MyService")
base_url: str = Field(..., description="Base URL for MyService")
_block_type_name = "MyService Authentication"
async def authenticate(self, **kwargs):
# Implement authentication logic
return {
"authenticated": True,
"access_token": "your-token"
}
Development Commands
# Install development dependencies
uv add --dev pytest pytest-asyncio pytest-cov
# Run tests
uv run pytest
# Run tests with coverage
uv run pytest --cov=dochain_block
# Run example
uv run python examples/nacos_example.py
Requirements
- Python 3.11+
- Prefect >= 3.4.24
- Pydantic >= 2.12.3
- httpx >= 0.28.1
License
[Add your license information here]
Contributing
[Add contribution guidelines here]
Metadata
Release files for dochain-block 0.3.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dochain_block-0.3.3.tar.gz | 213.9 kB | Without provenance | Details for dochain_block-0.3.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dochain_block-0.3.3-py3-none-any.whl | Python 3 | none | any | Details for dochain_block-0.3.3-py3-none-any.whl |
Total release size: 222.9 kB
Release files / dochain_block-0.3.3.tar.gz
| Download URL | dochain_block-0.3.3.tar.gz |
|---|---|
| Size | 213.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f78b7ecc1182ae41723f478a46c9931cd3d83e517e4714e74de58e589b4ae7c4
|
|
BLAKE2b-256 checksum How to use checksums |
422ed03ecc9f9074c0aa0c1a8f2c8935158370c10061b9bb275307287d7e548b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / dochain_block-0.3.3-py3-none-any.whl
| Download URL | dochain_block-0.3.3-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a76b846072278685fe18f90b375894249910af8343ca388caddc55d1b6a6064c
|
|
BLAKE2b-256 checksum How to use checksums |
b855b6808ae4fbbd0dbad1cf46274bef726247cf4e738277dfea85c555d79f85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for dochain-block 0.3.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.