Skip to content

Commit 127a27c

Browse files
Merge pull request #696 from yasinBursali/fix/gpu-endpoints-auth
fix: add authentication to GPU detail, topology, and history endpoints
2 parents 484cd19 + 4557f38 commit 127a27c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

dream-server/extensions/services/dashboard-api/routers/gpu.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
from datetime import datetime, timezone
99
from typing import Optional
1010

11-
from fastapi import APIRouter, HTTPException
11+
from fastapi import APIRouter, Depends, HTTPException
12+
13+
from security import verify_api_key
1214

1315
from gpu import (
1416
decode_gpu_assignment,
@@ -93,7 +95,7 @@ def _build_aggregate(gpus: list[IndividualGPU], backend: str) -> GPUInfo:
9395
# Endpoints
9496
# ============================================================================
9597

96-
@router.get("/api/gpu/detailed", response_model=MultiGPUStatus)
98+
@router.get("/api/gpu/detailed", response_model=MultiGPUStatus, dependencies=[Depends(verify_api_key)])
9799
async def gpu_detailed():
98100
"""Per-GPU metrics with service assignment info (cached 3 s)."""
99101
now = time.monotonic()
@@ -125,7 +127,7 @@ async def gpu_detailed():
125127
return result
126128

127129

128-
@router.get("/api/gpu/topology")
130+
@router.get("/api/gpu/topology", dependencies=[Depends(verify_api_key)])
129131
async def gpu_topology():
130132
"""GPU topology from config/gpu-topology.json (written by installer / dream-cli). Cached 300 s."""
131133
now = time.monotonic()
@@ -144,7 +146,7 @@ async def gpu_topology():
144146
return topo
145147

146148

147-
@router.get("/api/gpu/history")
149+
@router.get("/api/gpu/history", dependencies=[Depends(verify_api_key)])
148150
async def gpu_history():
149151
"""Rolling 5-minute per-GPU metrics history sampled every 5 s."""
150152
if not _GPU_HISTORY:

dream-server/extensions/services/dashboard/src/hooks/useGPUDetailed.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { useState, useEffect, useRef } from 'react'
22

3+
// Auth: nginx injects Authorization header for all /api/ requests (see nginx.conf).
4+
35
const POLL_INTERVAL = 5000
46

57
export function useGPUDetailed() {

0 commit comments

Comments
 (0)