0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00
ghost/core/server
Katharina Irrgang f22a2784f7 🐛 Fixed error for password authentication with Bearer Token (#9227)
refs #8613, refs #9228

- if you send a request to /authentication/token with `grant_type:password` and a Bearer token, Ghost was not able to handle this combination
- because it skipped the client authentication, see https://github.com/TryGhost/Ghost/blob/1.17.0/core/server/auth/authenticate.js#L13
- and OAuth detects the `grant_type: password` and jumps in the target implementation
- the target implementation for password authentication **again** tried to fetch the client and failed, because it relied on the previous client authentication
- see https://github.com/TryGhost/Ghost/blob/1.17.0/core/server/auth/oauth.js#L40 (client.slug is undefined if client authentication is skipped)
- ^ so this is the bug
- we **can** skip client authentication for requests to the API to fetch data for example e.g. GET /posts (including Bearer)
- so when is a client authentication required?
- RFC (https://tools.ietf.org/html/rfc6749#page-38) differentiates between confidential and public clients, Ghost has no implementation for this at the moment
  - so in theory, public clients don't have to be authenticated, only if the credentials are included
- to not invent a breaking change, i decided to only make the client authentication required for password authentication
- we could change this in Ghost 2.0

I have removed the extra client request to the database for the password authentication, this is not needed. We already do client password authentication [here](https://github.com/TryGhost/Ghost/blob/1.17.0/core/server/auth/auth-strategies.js#L19);
If a Bearer token is present and you have not send a `grant_type` (which signalises OAuth to do authentication), you can skip the client authentication.
2017-11-09 14:11:29 +00:00
..
adapters Moved isLocalFile fn to storage utils (#8985) 2017-11-09 11:11:54 +01:00
admin Switch to Eslint (#9197) 2017-11-01 13:44:54 +00:00
api Switch to Eslint (#9197) 2017-11-01 13:44:54 +00:00
apps Highlighted routes, controllers & renderers 2017-11-08 09:45:12 +00:00
auth 🐛 Fixed error for password authentication with Bearer Token (#9227) 2017-11-09 14:11:29 +00:00
config 🐛 Fixed redirects upload for various browsers/systems (#9042) 2017-09-22 21:57:43 +02:00
controllers Moved Channels module -> services 2017-11-08 15:45:23 +00:00
data Moved RSS module -> services & controllers 2017-11-08 08:09:44 +00:00
events
helpers Feature: {{reading_time}} theme helper (#9217) 2017-11-06 18:40:07 +00:00
mail Improved log output for welcome email error (#9016) 2017-09-19 14:24:20 +01:00
middleware Move admin redirects out of site router 2017-11-08 09:45:34 +00:00
models Changed logic for importPersistUser option (#9203) 2017-11-07 09:09:57 +01:00
permissions Switch to Eslint (#9197) 2017-11-01 13:44:54 +00:00
public 🛠 🙈 Rename ghost-url.js to ghost-sdk.js (#8767) 2017-07-28 18:23:32 +04:00
services Rework route service to prevent circular dependencies (#9229) 2017-11-09 13:58:22 +00:00
settings 🐛 Theme name is point number (#9184) 2017-10-26 13:54:18 +02:00
site Rework route service to prevent circular dependencies (#9229) 2017-11-09 13:58:22 +00:00
themes Switch to Eslint (#9197) 2017-11-01 13:44:54 +00:00
translations Improved password validation rules (#9171) 2017-10-26 11:01:24 +01:00
utils Moved isLocalFile fn to storage utils (#8985) 2017-11-09 11:11:54 +01:00
views 🎨 gscan 1.1.0 & optimisations 2017-06-06 13:07:50 +07:00
analytics-events.js Add segment analytics for blog data (#8912) 2017-08-22 12:23:23 +01:00
app.js Rename blog -> site 2017-10-26 18:09:56 +01:00
errors.js Switch to Eslint (#9197) 2017-11-01 13:44:54 +00:00
filters.js
ghost-server.js Used ghost-ignition.debug, removed debug dep (#8881) 2017-08-15 18:29:27 +07:00
i18n.js Improved the usage of missing translation keys (#9081) 2017-10-03 09:47:48 +02:00
index.js Moved apps to /services/ & moved individual tests (#9187) 2017-10-30 12:31:04 +00:00
logging.js 🐛 forward missing logging config: rotation 2017-02-17 18:24:14 +01:00
overrides.js
update-check.js Switch to Eslint (#9197) 2017-11-01 13:44:54 +00:00