From 2f0b4e18f478d3c9c2d8019e199344290016658b Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 23 Oct 2023 15:52:28 +0100 Subject: [PATCH] update fix when no chatflow apikey is set --- packages/server/src/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index 8d4592b5..89b36ad1 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -811,10 +811,13 @@ export class App { */ async validateKey(req: Request, chatflow: ChatFlow) { const chatFlowApiKeyId = chatflow.apikeyid + if (!chatFlowApiKeyId) return true + const authorizationHeader = (req.headers['Authorization'] as string) ?? (req.headers['authorization'] as string) ?? '' if (chatFlowApiKeyId && !authorizationHeader) return false + const suppliedKey = authorizationHeader.split(`Bearer `).pop() - if (chatFlowApiKeyId && suppliedKey) { + if (suppliedKey) { const keys = await getAPIKeys() const apiSecret = keys.find((key) => key.id === chatFlowApiKeyId)?.apiSecret if (!compareKeys(apiSecret, suppliedKey)) return false