Skip to content

Commit 7dc14f4

Browse files
committed
Always require API key
1 parent 2b29d9b commit 7dc14f4

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/api/middlewares/authorization.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ module.exports = function authorization (metadataBackend, forceToBeMaster = fals
1212
req.profiler.done('authorization');
1313

1414
return next(new Error('permission denied'));
15+
} else if (!credentials.apiKeyToken) {
16+
req.profiler.done('authorization');
17+
18+
return next(new Error('unauthorized'));
1519
}
1620

1721
res.locals.api_key = credentials.apiKeyToken;

lib/services/error-handler.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class ErrorHandler extends Error {
3232
getHttpStatus (httpStatus = 400) {
3333
if (this.message.includes('permission denied')) {
3434
return 403;
35+
} else if (this.message.includes('unauthorized')) {
36+
return 401;
3537
}
3638

3739
return httpStatus;

0 commit comments

Comments
 (0)