-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved error message when attempting to use disabled v0.1 Public API (
#10562) no issue - trying to use the v0.1 Public API when it was disabled led to a confusing error message, see https://forum.ghost.org/t/403-forbidden-error-on-postman-api-call/6017 - adds an explicit check for the Public API being enabled in the client authentication step and throws a useful error message if client auth is attempted when it's disabled
- Loading branch information
1 parent
e79fc9a
commit 39edb76
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ const common = require('../../lib/common'); | |
const session = require('./session'); | ||
const apiKeyAuth = require('./api-key'); | ||
const members = require('./members'); | ||
const labs = require('../labs'); | ||
|
||
const authenticate = { | ||
// ### Authenticate Client Middleware | ||
|
@@ -38,6 +39,14 @@ const authenticate = { | |
req.body.client_secret = req.query.client_secret; | ||
} | ||
|
||
if (labs.isSet('publicAPI') !== true) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
kirrg001
Contributor
|
||
return next(new common.errors.NoPermissionError({ | ||
message: common.i18n.t('errors.middleware.auth.publicAPIDisabled.error'), | ||
context: common.i18n.t('errors.middleware.auth.publicAPIDisabled.context'), | ||
help: common.i18n.t('errors.middleware.auth.forInformationRead', {url: 'https://docs.ghost.org/api/content/'}) | ||
})); | ||
} | ||
|
||
if (!req.body.client_id || !req.body.client_secret) { | ||
return next(new common.errors.UnauthorizedError({ | ||
message: common.i18n.t('errors.middleware.auth.accessDenied'), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@kevinansfield Just noticed. Doesn't this break v0.1 user/password authentication completely??