Add support for custom headers and migrate from legacy auth
- Introduced CustomHeaders component for managing custom headers. - Updated Sidebar to include CustomHeaders component. - Enhanced useConnection hook to handle custom headers and legacy auth migration. - Added tests for custom headers functionality. - Updated package.json and package-lock.json for new dependencies.
This commit is contained in:
parent
b476ece67e
commit
c5acc63129
2 changed files with 606 additions and 48 deletions
|
|
@ -22,6 +22,7 @@
|
|||
"devDependencies": {
|
||||
"@types/cors": "^2.8.19",
|
||||
"@types/express": "^4.17.23",
|
||||
"@types/shell-quote": "^1.7.5",
|
||||
"@types/ws": "^8.5.12",
|
||||
"tsx": "^4.19.0",
|
||||
"typescript": "^5.6.2"
|
||||
|
|
@ -30,6 +31,8 @@
|
|||
"@modelcontextprotocol/sdk": "^1.17.5",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^5.1.0",
|
||||
"shell-quote": "^1.8.3",
|
||||
"spawn-rx": "^5.1.2",
|
||||
"ws": "^8.18.0",
|
||||
"zod": "^3.25.76"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,6 +90,23 @@ const getHttpHeaders = (req: express.Request): Record<string, string> => {
|
|||
}
|
||||
}
|
||||
|
||||
// Handle multiple custom headers (new approach)
|
||||
if (req.headers["x-custom-auth-headers"] !== undefined) {
|
||||
try {
|
||||
const customHeaderNames = JSON.parse(req.headers["x-custom-auth-headers"] as string) as string[];
|
||||
if (Array.isArray(customHeaderNames)) {
|
||||
customHeaderNames.forEach((headerName) => {
|
||||
const lowerCaseHeaderName = headerName.toLowerCase();
|
||||
if (req.headers[lowerCaseHeaderName] !== undefined) {
|
||||
const value = req.headers[lowerCaseHeaderName];
|
||||
headers[headerName] = Array.isArray(value) ? value[value.length - 1] : value;
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn("Failed to parse x-custom-auth-headers:", error);
|
||||
}
|
||||
}
|
||||
return headers;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue