@@ -6,6 +6,7 @@ import express from "express";
66import { WebSocketServer , WebSocket } from "ws" ;
77
88import { newTask , type CompanyServices , type TaskState } from "../core" ;
9+ import { installDashboardAuth } from "./auth" ;
910
1011const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
1112const PUBLIC_DIR = resolve ( __dirname , "../dashboard/public" ) ;
@@ -19,6 +20,7 @@ export interface HttpServerHandles {
1920export function createHttpServer ( services : CompanyServices ) : HttpServerHandles {
2021 const app = express ( ) ;
2122 app . use ( express . json ( ) ) ;
23+ installDashboardAuth ( app ) ;
2224
2325 // Suppress the browser's default favicon request (no asset shipped).
2426 app . get ( "/favicon.ico" , ( _req , res ) => {
@@ -83,11 +85,14 @@ export function createHttpServer(services: CompanyServices): HttpServerHandles {
8385 const id = req . params . id ;
8486 const body = req . body ?? { } ;
8587 const decision = body . decision ;
86- const by = typeof body . by === "string" ? body . by : "human" ;
88+ let by = typeof body . by === "string" ? body . by : "human" ;
8789 if ( decision !== "approved" && decision !== "rejected" ) {
8890 res . status ( 400 ) . json ( { error : "decision must be 'approved' or 'rejected'" } ) ;
8991 return ;
9092 }
93+ if ( process . env . DASHBOARD_API_TOKEN ?. trim ( ) ) {
94+ by = "dashboard-operator" ;
95+ }
9196 const approval = services . policy . decide ( id , decision , by ) ;
9297 if ( ! approval ) {
9398 res . status ( 404 ) . json ( { error : "approval not found" } ) ;
0 commit comments