# 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
```bash
# 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
```python
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
1. Create a new module in `src/dochain_block/auth/`
2. Inherit from `AuthBlock` base class
3. Implement required methods:
- `authenticate()`: Main authentication logic
- Optional: `validate_credentials()`, `refresh_credentials()`
4. Register the block in `__init__.py`
#### Example: New Authentication Module
```python
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
```bash
# 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]
Raw data
{
"_id": null,
"home_page": null,
"name": "dochain-block",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "authentication, blocks, connection-management, nacos, prefect",
"author": null,
"author_email": "Your Name <your.email@example.com>",
"download_url": "https://files.pythonhosted.org/packages/cd/cd/739ed3003e0612232e96662d613bda3e4876572885781f1092bf271dbab3/dochain_block-0.3.2.tar.gz",
"platform": null,
"description": "# dochain-block\n\nPrefect Blocks for authentication and connection management.\n\n## Overview\n\n`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.\n\n## Features\n\n- **Modular Authentication Blocks**: Each service has its own dedicated authentication block\n- **Secure Credential Management**: Built on Prefect's secure block system\n- **Multiple Authentication Methods**: Support for username/password, API keys, tokens, and more\n- **Async-First Design**: Optimized for Prefect's async execution model\n- **Easy Integration**: Seamless integration with Prefect flows and deployments\n\n## Installation\n\n```bash\n# Create virtual environment\nuv venv\nsource .venv/bin/activate # Unix/macOS\n# or\n.\\.venv\\Scripts\\activate # Windows\n\n# Install the package\nuv pip install -e .\n```\n\n## Available Authentication Blocks\n\n### NacosBlock\n\nConnect to Nacos service discovery and configuration management platform.\n\n**Supported Authentication Methods:**\n- Username/Password\n- Access Key/Secret Key\n- Bearer Token\n\n**Features:**\n- Configuration management\n- Service discovery\n- Health checks\n- Namespace support\n\n#### Usage Example\n\n```python\nfrom prefect import flow\nfrom dochain_block import NacosBlock\n\n@flow\ndef nacos_config_flow():\n # Load Nacos block\n nacos = NacosBlock.load(\"my-nacos-connection\")\n\n # Get configuration\n config = asyncio.run(nacos.get_config(\"app-config\", \"DEFAULT_GROUP\"))\n return config\n\n# Save block configuration\nnacos_block = NacosBlock(\n name=\"my-nacos-connection\",\n server_url=\"http://localhost:8848/nacos\",\n username=\"nacos\",\n password=\"nacos\",\n namespace=\"public\"\n)\n\nnacos_block.save(\"my-nacos-connection\")\n```\n\n## Development\n\n### Adding New Authentication Modules\n\n1. Create a new module in `src/dochain_block/auth/`\n2. Inherit from `AuthBlock` base class\n3. Implement required methods:\n - `authenticate()`: Main authentication logic\n - Optional: `validate_credentials()`, `refresh_credentials()`\n4. Register the block in `__init__.py`\n\n#### Example: New Authentication Module\n\n```python\nfrom ..core.base_block import AuthBlock\nfrom pydantic import Field, SecretStr\n\nclass MyServiceBlock(AuthBlock):\n \"\"\"Authentication block for MyService\"\"\"\n\n api_key: SecretStr = Field(..., description=\"API key for MyService\")\n base_url: str = Field(..., description=\"Base URL for MyService\")\n\n _block_type_name = \"MyService Authentication\"\n\n async def authenticate(self, **kwargs):\n # Implement authentication logic\n return {\n \"authenticated\": True,\n \"access_token\": \"your-token\"\n }\n```\n\n### Development Commands\n\n```bash\n# Install development dependencies\nuv add --dev pytest pytest-asyncio pytest-cov\n\n# Run tests\nuv run pytest\n\n# Run tests with coverage\nuv run pytest --cov=dochain_block\n\n# Run example\nuv run python examples/nacos_example.py\n```\n\n## Requirements\n\n- Python 3.11+\n- Prefect >= 3.4.24\n- Pydantic >= 2.12.3\n- httpx >= 0.28.1\n\n## License\n\n[Add your license information here]\n\n## Contributing\n\n[Add contribution guidelines here]",
"bugtrack_url": null,
"license": "MIT",
"summary": "Prefect Blocks for authentication and connection management",
"version": "0.3.2",
"project_urls": null,
"split_keywords": [
"authentication",
" blocks",
" connection-management",
" nacos",
" prefect"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "94f583fa2392bab77267d8999bb242343179856a6592e820e8d2741656f7c712",
"md5": "864e52355c5be48a33de6b5daac4cb13",
"sha256": "24def31a36ecfd92d4133efe1403e4097c926457a5f80f244d304da70f617608"
},
"downloads": -1,
"filename": "dochain_block-0.3.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "864e52355c5be48a33de6b5daac4cb13",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 7122,
"upload_time": "2025-10-24T06:09:25",
"upload_time_iso_8601": "2025-10-24T06:09:25.898771Z",
"url": "https://files.pythonhosted.org/packages/94/f5/83fa2392bab77267d8999bb242343179856a6592e820e8d2741656f7c712/dochain_block-0.3.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "cdcd739ed3003e0612232e96662d613bda3e4876572885781f1092bf271dbab3",
"md5": "9c06e83de6dbb5bd6ae88814087256e6",
"sha256": "95e8f3711bdc680848ebf213fc6c8bf883cf1c8a48130216fceb1bfcf01c6411"
},
"downloads": -1,
"filename": "dochain_block-0.3.2.tar.gz",
"has_sig": false,
"md5_digest": "9c06e83de6dbb5bd6ae88814087256e6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 213217,
"upload_time": "2025-10-24T06:09:26",
"upload_time_iso_8601": "2025-10-24T06:09:26.946262Z",
"url": "https://files.pythonhosted.org/packages/cd/cd/739ed3003e0612232e96662d613bda3e4876572885781f1092bf271dbab3/dochain_block-0.3.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-24 06:09:26",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "dochain-block"
}