chore: standardize configuration, logging, and error handling across blockchain node and coordinator API

- Add infrastructure.md and workflow files to .gitignore to prevent sensitive info leaks
- Change blockchain node mempool backend default from memory to database for persistence
- Refactor blockchain node logger with StructuredLogFormatter and AuditLogger (consistent with coordinator)
- Add structured logging fields: service, module, function, line number
- Unify coordinator config with Database
This commit is contained in:
oib
2026-02-13 22:39:43 +01:00
parent 0cbd2b507c
commit 06e48ef34b
196 changed files with 4660 additions and 20090 deletions

View File

@@ -1,10 +1,19 @@
from typing import Callable, Annotated
"""
Dependency injection module for AITBC Coordinator API
Provides unified dependency injection using storage.SessionDep.
"""
from typing import Callable
from fastapi import Depends, Header, HTTPException
from .config import settings
from .storage import SessionDep
class APIKeyValidator:
"""Validator for API key authentication."""
def __init__(self, allowed_keys: list[str]):
self.allowed_keys = {key.strip() for key in allowed_keys if key}
@@ -15,12 +24,22 @@ class APIKeyValidator:
def require_client_key() -> Callable[[str | None], str]:
"""Dependency for client API key authentication."""
return APIKeyValidator(settings.client_api_keys)
def require_miner_key() -> Callable[[str | None], str]:
"""Dependency for miner API key authentication."""
return APIKeyValidator(settings.miner_api_keys)
def require_admin_key() -> Callable[[str | None], str]:
"""Dependency for admin API key authentication."""
return APIKeyValidator(settings.admin_api_keys)
# Legacy aliases for backward compatibility
def get_session():
"""Legacy alias - use SessionDep instead."""
from .storage import get_session
return get_session()