mirror of https://github.com/garrytan/gstack.git
fix: add auth gate to /inspector/events SSE endpoint (C3)
The /inspector/events endpoint had no authentication, unlike /activity/stream which validates tokens. Now requires the same Bearer header or ?token= query param check. Closes C3 from security audit #783. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e046e851eb
commit
73c2bf2c04
|
|
@ -1556,8 +1556,14 @@ async function start() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET /inspector/events — SSE for inspector state changes
|
// GET /inspector/events — SSE for inspector state changes (auth required)
|
||||||
if (url.pathname === '/inspector/events' && req.method === 'GET') {
|
if (url.pathname === '/inspector/events' && req.method === 'GET') {
|
||||||
|
const streamToken = url.searchParams.get('token');
|
||||||
|
if (!validateAuth(req) && streamToken !== AUTH_TOKEN) {
|
||||||
|
return new Response(JSON.stringify({ error: 'Unauthorized' }), {
|
||||||
|
status: 401, headers: { 'Content-Type': 'application/json' },
|
||||||
|
});
|
||||||
|
}
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const stream = new ReadableStream({
|
const stream = new ReadableStream({
|
||||||
start(controller) {
|
start(controller) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue