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:
oib
2026-03-05 12:28:17 +01:00
parent 80b9ea4b25
commit efd85060db
5 changed files with 38 additions and 15 deletions

View File

@@ -49,10 +49,11 @@ def register(ctx, gpu: Optional[str], memory: Optional[int],
try:
with httpx.Client() as client:
response = client.post(
f"{config.coordinator_url}/api/v1/miners/register?miner_id={miner_id}",
f"{config.coordinator_url}/api/v1/miners/register",
headers={
"Content-Type": "application/json",
"X-Api-Key": config.api_key or ""
"X-Api-Key": config.api_key or "",
"X-Miner-ID": miner_id
},
json={"capabilities": capabilities}
)
@@ -191,11 +192,16 @@ def heartbeat(ctx, miner_id: str):
try:
with httpx.Client() as client:
response = client.post(
f"{config.coordinator_url}/api/v1/miners/heartbeat?miner_id={miner_id}",
f"{config.coordinator_url}/api/v1/miners/heartbeat",
headers={
"X-Api-Key": config.api_key or ""
"X-Api-Key": config.api_key or "",
"X-Miner-ID": miner_id
},
json={}
json={
"inflight": 0,
"status": "ONLINE",
"metadata": {}
}
)
if response.status_code in (200, 204):