Skip to content

Commit 05b5ae8

Browse files
committed
Merge branch 'release/1.8.0'
2 parents 2ae4dde + 2e9c14a commit 05b5ae8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
### Fixed
1010
* Correction in message formatting when generated by AI as markdown in typebot
11+
* Security fix in fetch instance with client key when not connected to mongodb
1112

1213
# 1.7.5 (2024-05-21 08:50)
1314

src/api/guards/auth.guard.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { NextFunction, Request, Response } from 'express';
33
import jwt from 'jsonwebtoken';
44

55
import { name } from '../../../package.json';
6-
import { Auth, configService } from '../../config/env.config';
6+
import { Auth, configService, Database } from '../../config/env.config';
77
import { Logger } from '../../config/logger.config';
88
import { ForbiddenException, UnauthorizedException } from '../../exceptions';
99
import { InstanceDto } from '../dto/instance.dto';
@@ -58,6 +58,7 @@ async function jwtGuard(req: Request, res: Response, next: NextFunction) {
5858
async function apikey(req: Request, _: Response, next: NextFunction) {
5959
const env = configService.get<Auth>('AUTHENTICATION').API_KEY;
6060
const key = req.get('apikey');
61+
const db = configService.get<Database>('DATABASE');
6162

6263
if (!key) {
6364
throw new UnauthorizedException();
@@ -79,7 +80,7 @@ async function apikey(req: Request, _: Response, next: NextFunction) {
7980
return next();
8081
}
8182
} else {
82-
if (req.originalUrl.includes('/instance/fetchInstances')) {
83+
if (req.originalUrl.includes('/instance/fetchInstances') && db.ENABLED) {
8384
const instanceByKey = await repository.auth.findByKey(key);
8485
if (instanceByKey) {
8586
return next();

0 commit comments

Comments
 (0)