mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 19:00:59 +03:00
update fix when no chatflow apikey is set
This commit is contained in:
@@ -811,10 +811,13 @@ export class App {
|
|||||||
*/
|
*/
|
||||||
async validateKey(req: Request, chatflow: ChatFlow) {
|
async validateKey(req: Request, chatflow: ChatFlow) {
|
||||||
const chatFlowApiKeyId = chatflow.apikeyid
|
const chatFlowApiKeyId = chatflow.apikeyid
|
||||||
|
if (!chatFlowApiKeyId) return true
|
||||||
|
|
||||||
const authorizationHeader = (req.headers['Authorization'] as string) ?? (req.headers['authorization'] as string) ?? ''
|
const authorizationHeader = (req.headers['Authorization'] as string) ?? (req.headers['authorization'] as string) ?? ''
|
||||||
if (chatFlowApiKeyId && !authorizationHeader) return false
|
if (chatFlowApiKeyId && !authorizationHeader) return false
|
||||||
|
|
||||||
const suppliedKey = authorizationHeader.split(`Bearer `).pop()
|
const suppliedKey = authorizationHeader.split(`Bearer `).pop()
|
||||||
if (chatFlowApiKeyId && suppliedKey) {
|
if (suppliedKey) {
|
||||||
const keys = await getAPIKeys()
|
const keys = await getAPIKeys()
|
||||||
const apiSecret = keys.find((key) => key.id === chatFlowApiKeyId)?.apiSecret
|
const apiSecret = keys.find((key) => key.id === chatFlowApiKeyId)?.apiSecret
|
||||||
if (!compareKeys(apiSecret, suppliedKey)) return false
|
if (!compareKeys(apiSecret, suppliedKey)) return false
|
||||||
|
|||||||
Reference in New Issue
Block a user