fix: change miner authentication to use separate X-Miner-ID header instead of API key for miner identification
- Add get_miner_id() dependency to extract miner ID from X-Miner-ID header - Update miner register and heartbeat endpoints to require both X-Miner-ID and X-Api-Key headers - Remove miner_id from query parameters in favor of header-based extraction - Fix miner heartbeat CLI to send proper JSON payload with inflight, status, and metadata fields - Fix typo in MinerService: extra_metadata → extra_meta_data
This commit is contained in:
@@ -36,6 +36,17 @@ def require_miner_key() -> Callable[[str | None], str]:
|
||||
return validator
|
||||
|
||||
|
||||
def get_miner_id() -> Callable[[str | None], str]:
|
||||
"""Dependency to get miner ID from X-Miner-ID header."""
|
||||
|
||||
def validator(miner_id: str | None = Header(default=None, alias="X-Miner-ID")) -> str:
|
||||
if not miner_id:
|
||||
raise HTTPException(status_code=400, detail="X-Miner-ID header required")
|
||||
return miner_id
|
||||
|
||||
return validator
|
||||
|
||||
|
||||
def require_admin_key() -> Callable[[str | None], str]:
|
||||
"""Dependency for admin API key authentication (reads live settings)."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user