From 83c7dea1cc42d3595a3835f1982e3cef95258059 Mon Sep 17 00:00:00 2001 From: Fahmi Ardi Date: Thu, 3 Jul 2014 14:58:13 +0700 Subject: [PATCH] allowing client crendentials to be sent as Basic authentication --- src/Grant/AuthCodeGrant.php | 10 ++++++++-- src/Grant/ClientCredentialsGrant.php | 10 ++++++++-- src/Grant/PasswordGrant.php | 10 ++++++++-- src/Grant/RefreshTokenGrant.php | 10 ++++++++-- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/Grant/AuthCodeGrant.php b/src/Grant/AuthCodeGrant.php index fc8fec53..e3e10363 100644 --- a/src/Grant/AuthCodeGrant.php +++ b/src/Grant/AuthCodeGrant.php @@ -165,12 +165,18 @@ class AuthCodeGrant extends AbstractGrant // Get the required params $clientId = $this->server->getRequest()->request->get('client_id', null); if (is_null($clientId)) { - throw new Exception\InvalidRequestException('client_id'); + $clientId = $this->server->getRequest()->getUser(); + if (is_null($clientId)) { + throw new Exception\InvalidRequestException('client_id'); + } } $clientSecret = $this->server->getRequest()->request->get('client_secret', null); if (is_null($clientSecret)) { - throw new Exception\InvalidRequestException('client_secret'); + $clientId = $this->server->getRequest()->getPassword(); + if (is_null($clientSecret)) { + throw new Exception\InvalidRequestException('client_secret'); + } } $redirectUri = $this->server->getRequest()->request->get('redirect_uri', null); diff --git a/src/Grant/ClientCredentialsGrant.php b/src/Grant/ClientCredentialsGrant.php index 786d5d2c..3541d546 100644 --- a/src/Grant/ClientCredentialsGrant.php +++ b/src/Grant/ClientCredentialsGrant.php @@ -56,12 +56,18 @@ class ClientCredentialsGrant extends AbstractGrant // Get the required params $clientId = $this->server->getRequest()->request->get('client_id', null); if (is_null($clientId)) { - throw new Exception\InvalidRequestException('client_id'); + $clientId = $this->server->getRequest()->getUser(); + if (is_null($clientId)) { + throw new Exception\InvalidRequestException('client_id'); + } } $clientSecret = $this->server->getRequest()->request->get('client_secret', null); if (is_null($clientSecret)) { - throw new Exception\InvalidRequestException('client_secret'); + $clientId = $this->server->getRequest()->getPassword(); + if (is_null($clientSecret)) { + throw new Exception\InvalidRequestException('client_secret'); + } } // Validate client ID and client secret diff --git a/src/Grant/PasswordGrant.php b/src/Grant/PasswordGrant.php index 9c2b27e3..21f89cb3 100644 --- a/src/Grant/PasswordGrant.php +++ b/src/Grant/PasswordGrant.php @@ -80,12 +80,18 @@ class PasswordGrant extends AbstractGrant // Get the required params $clientId = $this->server->getRequest()->request->get('client_id', null); if (is_null($clientId)) { - throw new Exception\InvalidRequestException('client_id'); + $clientId = $this->server->getRequest()->getUser(); + if (is_null($clientId)) { + throw new Exception\InvalidRequestException('client_id'); + } } $clientSecret = $this->server->getRequest()->request->get('client_secret', null); if (is_null($clientSecret)) { - throw new Exception\InvalidRequestException('client_secret'); + $clientId = $this->server->getRequest()->getPassword(); + if (is_null($clientSecret)) { + throw new Exception\InvalidRequestException('client_secret'); + } } // Validate client ID and client secret diff --git a/src/Grant/RefreshTokenGrant.php b/src/Grant/RefreshTokenGrant.php index 01f5e695..92b116f8 100644 --- a/src/Grant/RefreshTokenGrant.php +++ b/src/Grant/RefreshTokenGrant.php @@ -60,12 +60,18 @@ class RefreshTokenGrant extends AbstractGrant { $clientId = $this->server->getRequest()->request->get('client_id', null); if (is_null($clientId)) { - throw new Exception\InvalidRequestException('client_id'); + $clientId = $this->server->getRequest()->getUser(); + if (is_null($clientId)) { + throw new Exception\InvalidRequestException('client_id'); + } } $clientSecret = $this->server->getRequest()->request->get('client_secret', null); if (is_null($clientSecret)) { - throw new Exception\InvalidRequestException('client_secret'); + $clientId = $this->server->getRequest()->getPassword(); + if (is_null($clientSecret)) { + throw new Exception\InvalidRequestException('client_secret'); + } } // Validate client ID and client secret