Skip to content

Commit

Permalink
fix: add additional check to admin token
Browse files Browse the repository at this point in the history
  • Loading branch information
enzomerca committed Apr 19, 2024
1 parent 32c20f8 commit e861b25
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion node/directives/checkUserAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@ export async function checkUserOrAdminTokenAccess(

if (adminUserAuthToken) {
try {
await identity.validateToken({ token: adminUserAuthToken })
const authUser = await identity.validateToken({
token: adminUserAuthToken,
})

if (!authUser?.audience || authUser?.audience !== 'admin') {
logger.warn({
message: `CheckUserAccess: No valid user found by admin token`,
operation,
})
throw new ForbiddenError('Unauthorized Access')
}
} catch (err) {
logger.warn({
error: err,
Expand Down

0 comments on commit e861b25

Please sign in to comment.