feat: ship self-hosted KOC LOOP workflows
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { env } from "cloudflare:workers";
|
||||
import { getRuntimeEnv } from "../../../lib/runtime-env";
|
||||
import {
|
||||
createMcpHandler,
|
||||
McpServer,
|
||||
@@ -16,10 +16,11 @@ import {
|
||||
import { registerMcpOperationTools } from "../../../lib/mcp-tools";
|
||||
import type { CollectionMcpBindings } from "../../../lib/mcp-collection-client";
|
||||
|
||||
export const runtime = "edge";
|
||||
const env = getRuntimeEnv();
|
||||
|
||||
type McpBindings = FeishuBindings & CollectionMcpBindings & {
|
||||
KOC_MCP_API_KEY?: string;
|
||||
KOC_LOOP_MCP_API_KEY?: string;
|
||||
KOC_PORTAL_URL?: string;
|
||||
};
|
||||
|
||||
@@ -190,7 +191,10 @@ function originRejected(request: Request) {
|
||||
}
|
||||
|
||||
async function authorize(request: Request) {
|
||||
const expected = String(getBindings().KOC_MCP_API_KEY ?? "").trim();
|
||||
const bindings = getBindings();
|
||||
const expected = String(
|
||||
bindings.KOC_MCP_API_KEY ?? bindings.KOC_LOOP_MCP_API_KEY ?? "",
|
||||
).trim();
|
||||
const authorization = request.headers.get("Authorization") ?? "";
|
||||
const match = authorization.match(/^Bearer\s+(.+)$/i);
|
||||
if (!expected || !match || !(await secretsMatch(match[1].trim(), expected))) {
|
||||
|
||||
Reference in New Issue
Block a user