This commit is contained in:
Rudra deep Biswas 2025-05-06 16:38:13 +05:30
parent 7e52b6178c
commit 12f09f80d8
2 changed files with 10 additions and 11 deletions

View file

@ -9,18 +9,18 @@ export class ExternalApiSecurityGuard implements CanActivate {
const request = context.switchToHttp().getRequest();
// // Check if external API is enabled
// const isExternalApiEnabled = this.configService.get<string>('ENABLE_EXTERNAL_API') === 'true';
// if (!isExternalApiEnabled) {
// throw new ForbiddenException('External API is disabled');
// }
const isExternalApiEnabled = this.configService.get<string>('ENABLE_EXTERNAL_API') === 'true';
if (!isExternalApiEnabled) {
throw new ForbiddenException('External API is disabled');
}
// // // Check the authorization header
// const authHeader = request.headers['authorization'];
// const externalApiAccessToken = this.configService.get<string>('EXTERNAL_API_ACCESS_TOKEN');
// // Check the authorization header
const authHeader = request.headers['authorization'];
const externalApiAccessToken = this.configService.get<string>('EXTERNAL_API_ACCESS_TOKEN');
// if (!authHeader || authHeader !== `Basic ${externalApiAccessToken}`) {
// throw new ForbiddenException('Unauthorized');
// }
if (!authHeader || authHeader !== `Basic ${externalApiAccessToken}`) {
throw new ForbiddenException('Unauthorized');
}
return true;
}