From 0729d0dea37114641c71ad554f28d2e81e85943d Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Fri, 30 Jun 2023 09:18:32 +0800 Subject: [PATCH 1/3] modify whitelistURLs --- packages/server/src/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index 3e729464b0d..0b39f73b098 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -93,7 +93,13 @@ export class App { const basicAuthMiddleware = basicAuth({ users: { [username]: password } }) - const whitelistURLs = ['/api/v1/prediction/', '/api/v1/node-icon/', '/api/v1/chatflows-streaming'] + const whitelistURLs = [ + '/api/v1/verify/apikey/', + '/api/v1/chatflows/apikey/', + '/api/v1/prediction/', + '/api/v1/node-icon/', + '/api/v1/chatflows-streaming' + ] this.app.use((req, res, next) => { if (req.url.includes('/api/v1/')) { whitelistURLs.some((url) => req.url.includes(url)) ? next() : basicAuthMiddleware(req, res, next) @@ -492,7 +498,7 @@ export class App { }) // Verify api key - this.app.get('/api/v1/apikey/:apiKey', async (req: Request, res: Response) => { + this.app.get('/api/v1/verify/apikey/:apiKey', async (req: Request, res: Response) => { try { const apiKey = await getApiKey(req.params.apiKey) if (!apiKey) return res.status(401).send('Unauthorized') From 4796d84b50f1dfce423d6572cbfcffd4adeaf75e Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Fri, 30 Jun 2023 17:37:33 +0800 Subject: [PATCH 2/3] fix missing public-chatflows in whitelist --- packages/server/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index fba5be5ec05..3c97a2e7ae5 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -96,6 +96,7 @@ export class App { const whitelistURLs = [ '/api/v1/verify/apikey/', '/api/v1/chatflows/apikey/', + '/api/v1/public-chatflows', '/api/v1/prediction/', '/api/v1/node-icon/', '/api/v1/chatflows-streaming' From 55489c1c774294f6f0fd23de487e5419d0a1fc94 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 30 Jun 2023 14:00:57 +0100 Subject: [PATCH 3/3] add blank space --- packages/server/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index 3c97a2e7ae5..15762a23c4f 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -194,6 +194,7 @@ export class App { .createQueryBuilder('cf') .where('cf.apikeyid = :apikeyid', { apikeyid: apiKey.id }) .orWhere('cf.apikeyid IS NULL') + .orWhere('cf.apikeyid = ""') .orderBy('cf.name', 'ASC') .getMany() if (chatflows.length >= 1) return res.status(200).send(chatflows)