0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00
ghost/core/test/unit
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
api Support for attribute-based permissions (#9025) 2017-09-26 18:06:14 +02: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 fix(config): cleanup absolute path config function (#8641) 2017-07-06 00:04:18 +02:00
controllers Moved Channels module -> services 2017-11-08 15:45:23 +00:00
data/importer 🎨 Support LTS imports (#8498) 2017-06-04 11:53:00 +02:00
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
metadata 🐛 Fixed author helper not returning the correct url (#9102) 2017-10-05 13:50:55 +02:00
middleware Always use our redirects utility (#9132) 2017-10-12 14:36:50 +02:00
models/base 🎨 change last_login to last_seen (#8259) 2017-04-05 20:45:55 +01:00
models_plugins Support filtering based on primary_tag (#9124) 2017-10-10 14:07:44 +02:00
permissions Permissions: minor refactors (#9104) 2017-10-05 21:01:34 +02: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
sitemap 🙀 Image field naming & new img_url helper (#8364) 2017-04-24 18:21:47 +01:00
themes Custom post templates (#9073) 2017-10-10 13:36:35 +01:00
utils Feature: {{reading_time}} theme helper (#9217) 2017-11-06 18:40:07 +00:00
admin_spec.js 💄 🐷 Test consistency (#8199) 2017-03-21 09:24:11 +01:00
apps_filters_spec.js 💄 🐷 Test consistency (#8199) 2017-03-21 09:24:11 +01:00
errors_spec.js 💄 🐷 Test consistency (#8199) 2017-03-21 09:24:11 +01:00
exporter_spec.js 💄 🐷 Test consistency (#8199) 2017-03-21 09:24:11 +01:00
ghost_sdk_spec.js 🐛 Fixed api url for the ghost sdk (#9013) 2017-09-18 16:28:22 +01:00
migration_fixture_utils_spec.js Custom post templates (#9073) 2017-10-10 13:36:35 +01:00
migration_spec.js Custom post templates (#9073) 2017-10-10 13:36:35 +01:00
server_utils_spec.js Always use our redirects utility (#9132) 2017-10-12 14:36:50 +02:00
social-urls_spec.js improvement: jshint/jscs 2016-06-17 22:59:47 +02:00
utils_pipeline_spec.js 💄 🐷 Test consistency (#8199) 2017-03-21 09:24:11 +01:00
validation_spec.js Improved password validation rules (#9171) 2017-10-26 11:01:24 +01:00