Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
samuel committed Apr 3, 2024
1 parent 568632c commit 983ec26
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion apps/vault/src/main.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { RawAesWrappingSuiteIdentifier } from '@aws-crypto/client-node'

export const REQUEST_HEADER_API_KEY = 'x-api-key'
export const REQUEST_HEADER_CLIENT_ID = 'x-client-id'
export const REQUEST_HEADER_CLIENT_SECRET = 'x-client-secret'

export const ENCRYPTION_KEY_NAMESPACE = 'armory.vault'
export const ENCRYPTION_KEY_NAME = 'storage-encryption'
Expand Down
6 changes: 3 additions & 3 deletions apps/vault/src/shared/guard/client-secret.guard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CanActivate, ExecutionContext, HttpStatus, Injectable } from '@nestjs/common'
import { REQUEST_HEADER_CLIENT_ID, REQUEST_HEADER_CLIENT_SECRET } from '../../main.constant'
import { REQUEST_HEADER_API_KEY, REQUEST_HEADER_CLIENT_ID } from '../../main.constant'
import { TenantService } from '../../tenant/core/service/tenant.service'
import { ApplicationException } from '../exception/application.exception'

Expand All @@ -10,11 +10,11 @@ export class ClientSecretGuard implements CanActivate {
async canActivate(context: ExecutionContext): Promise<boolean> {
const req = context.switchToHttp().getRequest()
const clientId = req.headers[REQUEST_HEADER_CLIENT_ID]
const clientSecret = req.headers[REQUEST_HEADER_CLIENT_SECRET]
const clientSecret = req.headers[REQUEST_HEADER_API_KEY]

if (!clientSecret) {
throw new ApplicationException({
message: `Missing or invalid ${REQUEST_HEADER_CLIENT_SECRET} header`,
message: `Missing or invalid ${REQUEST_HEADER_API_KEY} header`,
suggestedHttpStatusCode: HttpStatus.UNAUTHORIZED
})
} else if (!clientId) {
Expand Down

0 comments on commit 983ec26

Please sign in to comment.