Skip to content

Commit 339034d

Browse files
author
polaon
committed
Authentication check for the DELETE method.
1 parent cffff64 commit 339034d

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/server/streamable_http_server.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,18 @@ bool StreamableHttpServerWrapper::start()
372372
{
373373
apply_additional_response_headers(res);
374374

375+
// Security: Check authentication if configured
376+
if (!auth_token_.empty())
377+
{
378+
auto auth_it = req.headers.find("Authorization");
379+
if (auth_it == req.headers.end() || !check_auth(auth_it->second))
380+
{
381+
res.status = 401;
382+
res.set_content("{\"error\":\"Unauthorized\"}", "application/json");
383+
return;
384+
}
385+
}
386+
375387
auto session_it = req.headers.find("Mcp-Session-Id");
376388
if (session_it == req.headers.end() || session_it->second.empty())
377389
{

0 commit comments

Comments
 (0)