Skip to content

Commit

Permalink
Merge branch 'release/1.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidsonGomes committed May 27, 2024
2 parents 2ae4dde + 2e9c14a commit 05b5ae8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

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

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

Expand Down
5 changes: 3 additions & 2 deletions src/api/guards/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { NextFunction, Request, Response } from 'express';
import jwt from 'jsonwebtoken';

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

if (!key) {
throw new UnauthorizedException();
Expand All @@ -79,7 +80,7 @@ async function apikey(req: Request, _: Response, next: NextFunction) {
return next();
}
} else {
if (req.originalUrl.includes('/instance/fetchInstances')) {
if (req.originalUrl.includes('/instance/fetchInstances') && db.ENABLED) {
const instanceByKey = await repository.auth.findByKey(key);
if (instanceByKey) {
return next();
Expand Down

0 comments on commit 05b5ae8

Please sign in to comment.