Skip to content

Commit

Permalink
Merge pull request #432 from energywebfoundation/fix/whitelist-login-…
Browse files Browse the repository at this point in the history
…endpoint

fix(dsb-client-gateway-api): whitelist endpoints
  • Loading branch information
nik-ewf authored Mar 25, 2024
2 parents dae2e05 + 285810d commit 167057b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion libs/ddhub-client-gateway-guard/src/lib/guard/api-key.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ import {
import { ConfigService } from '@nestjs/config';
import { UserGuard } from '@dsb-client-gateway/ddhub-client-gateway-user-roles';

const WHITELISTED_ENDPOINTS = [
'/api/v2/health',
'/api/v2/login',
'/api/v2/login/refresh-token',
'/api/v2/login/config',
'/api/v2/gateway',
];

@Injectable()
export class ApiKeyGuard implements CanActivate {
protected readonly logger = new Logger(ApiKeyGuard.name);
Expand Down Expand Up @@ -60,7 +68,7 @@ export class ApiKeyGuard implements CanActivate {

const { headers } = request;

if (request.url === '/api/v2/health') {
if (WHITELISTED_ENDPOINTS.includes(request.url)) {
return true;
}

Expand Down

0 comments on commit 167057b

Please sign in to comment.