@@ -3,7 +3,7 @@ import { NextFunction, Request, Response } from 'express';
3
3
import jwt from 'jsonwebtoken' ;
4
4
5
5
import { name } from '../../../package.json' ;
6
- import { Auth , configService } from '../../config/env.config' ;
6
+ import { Auth , configService , Database } from '../../config/env.config' ;
7
7
import { Logger } from '../../config/logger.config' ;
8
8
import { ForbiddenException , UnauthorizedException } from '../../exceptions' ;
9
9
import { InstanceDto } from '../dto/instance.dto' ;
@@ -58,6 +58,7 @@ async function jwtGuard(req: Request, res: Response, next: NextFunction) {
58
58
async function apikey ( req : Request , _ : Response , next : NextFunction ) {
59
59
const env = configService . get < Auth > ( 'AUTHENTICATION' ) . API_KEY ;
60
60
const key = req . get ( 'apikey' ) ;
61
+ const db = configService . get < Database > ( 'DATABASE' ) ;
61
62
62
63
if ( ! key ) {
63
64
throw new UnauthorizedException ( ) ;
@@ -79,7 +80,7 @@ async function apikey(req: Request, _: Response, next: NextFunction) {
79
80
return next ( ) ;
80
81
}
81
82
} else {
82
- if ( req . originalUrl . includes ( '/instance/fetchInstances' ) ) {
83
+ if ( req . originalUrl . includes ( '/instance/fetchInstances' ) && db . ENABLED ) {
83
84
const instanceByKey = await repository . auth . findByKey ( key ) ;
84
85
if ( instanceByKey ) {
85
86
return next ( ) ;
0 commit comments