feat(monitor): add API Key authentication for server heartbeat

- Add api_key field to MonitoredServer model
- Add migration to create api_key column with unique index
- Add /admin/servers/{id}/api-key endpoint for key generation
- Add /admin/servers/{id}/api-key DELETE endpoint for revocation
- Add /server/heartbeat-v2 endpoint with X-API-Key header authentication
- Add TelemetryPayload model with extended fields (load_avg, uptime_seconds)
- Add basic unit tests for API key functionality
This commit is contained in:
zhi
2026-03-19 15:32:32 +00:00
parent 929a722c66
commit cf8a43d5b2
4 changed files with 175 additions and 1 deletions

View File

@@ -39,6 +39,7 @@ class MonitoredServer(Base):
identifier = Column(String(128), nullable=False, unique=True)
display_name = Column(String(128), nullable=True)
is_enabled = Column(Boolean, default=True)
api_key = Column(String(64), nullable=True, unique=True, index=True) # API Key for server heartbeat v2
created_by = Column(Integer, nullable=True)
created_at = Column(DateTime(timezone=True), server_default=func.now())