Skip to content

Commit

Permalink
Fixed api query authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
SamTV12345 committed May 24, 2024
1 parent 63e9b2d commit a2f92f9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/node/handler/APIHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ exports.handle = async function (apiVersion: string, functionName: string, field
throw new createHTTPError.NotFound('no such function');
}

if(!req.headers.authorization) {
throw new createHTTPError.Unauthorized('no or wrong API Key');
}


if (apikey !== null && apikey.trim().length > 0) {
fields.apikey = fields.apikey || fields.api_key || fields.authorization;
Expand All @@ -186,6 +184,9 @@ exports.handle = async function (apiVersion: string, functionName: string, field
throw new createHTTPError.Unauthorized('no or wrong API Key');
}
} else {
if(!req.headers.authorization) {
throw new createHTTPError.Unauthorized('no or wrong API Key');
}
try {
await jwtVerify(req.headers.authorization!.replace("Bearer ", ""), publicKeyExported!, {algorithms: ['RS256'],
requiredClaims: ["admin"]})
Expand Down

0 comments on commit a2f92f9

Please sign in to comment.