mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-26 22:11:20 -07:00
Fix: enforce MCP token length too
This commit is contained in:
@@ -2,7 +2,8 @@ import { getServerSession } from "next-auth/next";
|
||||
|
||||
import { authOptions } from "pages/api/auth/[...nextauth]";
|
||||
import { isAuthEnabled } from "utils/env";
|
||||
import { handleMcpRequest, mcpEnabled, mcpTokenAuthorized } from "utils/mcp/homepage-mcp";
|
||||
import createLogger from "utils/logger";
|
||||
import { handleMcpRequest, mcpEnabled, mcpTokenAuthorized, mcpTokenConfigError } from "utils/mcp/homepage-mcp";
|
||||
|
||||
async function hasHomepageSession(req, res) {
|
||||
if (!isAuthEnabled()) return false;
|
||||
@@ -14,6 +15,12 @@ export default async function handler(req, res) {
|
||||
return res.status(404).end("Not Found");
|
||||
}
|
||||
|
||||
const tokenError = mcpTokenConfigError();
|
||||
if (tokenError) {
|
||||
createLogger("mcp").error(tokenError);
|
||||
return res.status(500).json({ error: "MCP token is misconfigured. See logs for details." });
|
||||
}
|
||||
|
||||
if (!mcpTokenAuthorized(req) && !(await hasHomepageSession(req, res))) {
|
||||
return res.status(401).json({ error: "Unauthorized" });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user