oauth2-server-php icon indicating copy to clipboard operation
oauth2-server-php copied to clipboard

Client credentials can be empty using grant type "ClientCredentials"

Open jversmis opened this issue 12 years ago • 3 comments

When using grant type ClientCredentials, a token is granted even if client_id and client_secret are empty.

A couple of possible situations:

  • when providing correct client_id and client_secret, a token is granted, this is correct behaviour.
  • when providing incorrect client_id and client_secret, no token is granted, this is correct behaviour.
  • when providing no client_id and client_secret, a token is granted, this seems incorrect behaviour to me.

There is no row with empty client_id and client_secret in our oauth_clients table.

jversmis avatar Sep 09 '14 11:09 jversmis

Some further info: we use Pdo as the storage type.

In the function checkClientCredentials, no client is found in the database. This means that $result['client_secret'] will also be empty which leads to the fact that the check return $result['client_secret'] == $client_secret; evaluates to true.

jversmis avatar Sep 09 '14 11:09 jversmis

Hi @jversmis,

Did you install the correct version of the oauth server or make some modifications to the php code of the oauth server ?

Just tried using curl without client credentials :

curl http://someIP/my-oauth2-walkthrough/token.php -d 'grant_type=client_credentials'

and the following error is received in the response:

{"error":"invalid_client","error_description":"Client credentials were not found in the headers or body"}

No token is granted, it is the correct behaviour.

SaniGit avatar Sep 18 '14 14:09 SaniGit

I do not believe this is a valid issue. See these lines:

https://github.com/bshaffer/oauth2-server-php/blob/develop/src/OAuth2/Storage/Pdo.php#L83

https://github.com/bshaffer/oauth2-server-php/blob/develop/src/OAuth2/ClientAssertionType/HttpBasic.php#L46

bshaffer avatar Oct 13 '14 01:10 bshaffer