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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user