From a7b4f7d66bfc3bb650eb831f1a6df3215f17ee5b Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Wed, 27 Mar 2013 14:47:07 +0000 Subject: [PATCH] Added grant to getClient calls. Fixes #21 --- src/OAuth2/Grant/AuthCode.php | 2 +- src/OAuth2/Grant/ClientCredentials.php | 2 +- src/OAuth2/Grant/Password.php | 4 ++-- src/OAuth2/Grant/RefreshToken.php | 2 +- src/OAuth2/Storage/ClientInterface.php | 3 ++- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/OAuth2/Grant/AuthCode.php b/src/OAuth2/Grant/AuthCode.php index c0240cc5..d6e77d03 100644 --- a/src/OAuth2/Grant/AuthCode.php +++ b/src/OAuth2/Grant/AuthCode.php @@ -93,7 +93,7 @@ class AuthCode implements GrantTypeInterface { } // Validate client ID and redirect URI - $clientDetails = $this->authServer->getStorage('client')->getClient($authParams['client_id'], $authParams['client_secret'], $authParams['redirect_uri']); + $clientDetails = $this->authServer->getStorage('client')->getClient($authParams['client_id'], $authParams['client_secret'], $authParams['redirect_uri'], $this->identifier); if ($clientDetails === false) { throw new Exception\ClientException($this->authServer->getExceptionMessage('invalid_client'), 8); diff --git a/src/OAuth2/Grant/ClientCredentials.php b/src/OAuth2/Grant/ClientCredentials.php index 2becff4f..88ac8d1a 100644 --- a/src/OAuth2/Grant/ClientCredentials.php +++ b/src/OAuth2/Grant/ClientCredentials.php @@ -89,7 +89,7 @@ class ClientCredentials implements GrantTypeInterface { } // Validate client ID and client secret - $clientDetails = $this->authServer->getStorage('client')->getClient($authParams['client_id'], $authParams['client_secret']); + $clientDetails = $this->authServer->getStorage('client')->getClient($authParams['client_id'], $authParams['client_secret'], null, $this->identifier); if ($clientDetails === false) { throw new Exception\ClientException(AuthServer::getExceptionMessage('invalid_client'), 8); diff --git a/src/OAuth2/Grant/Password.php b/src/OAuth2/Grant/Password.php index c9eb0cf6..8ea78101 100644 --- a/src/OAuth2/Grant/Password.php +++ b/src/OAuth2/Grant/Password.php @@ -116,8 +116,8 @@ class Password implements GrantTypeInterface { throw new Exception\ClientException(sprintf($this->authServer->getExceptionMessage('invalid_request'), 'client_secret'), 0); } - // Validate client ID and redirect URI - $clientDetails = $this->authServer->getStorage('client')->getClient($authParams['client_id'], $authParams['client_secret']); + // Validate client credentials + $clientDetails = $this->authServer->getStorage('client')->getClient($authParams['client_id'], $authParams['client_secret'], null, $this->identifier); if ($clientDetails === false) { throw new Exception\ClientException($this->authServer->getExceptionMessage('invalid_client'), 8); diff --git a/src/OAuth2/Grant/RefreshToken.php b/src/OAuth2/Grant/RefreshToken.php index ee941554..b8f62805 100644 --- a/src/OAuth2/Grant/RefreshToken.php +++ b/src/OAuth2/Grant/RefreshToken.php @@ -89,7 +89,7 @@ class RefreshToken implements GrantTypeInterface { } // Validate client ID and client secret - $clientDetails = $this->authServer->getStorage('client')->getClient($authParams['client_id'], $authParams['client_secret']); + $clientDetails = $this->authServer->getStorage('client')->getClient($authParams['client_id'], $authParams['client_secret'], null, $this->identifier); if ($clientDetails === false) { throw new Exception\ClientException($this->authServer->getExceptionMessage('invalid_client'), 8); diff --git a/src/OAuth2/Storage/ClientInterface.php b/src/OAuth2/Storage/ClientInterface.php index 408ff959..ee4437b8 100644 --- a/src/OAuth2/Storage/ClientInterface.php +++ b/src/OAuth2/Storage/ClientInterface.php @@ -48,7 +48,8 @@ interface ClientInterface * @param string $clientId The client's ID * @param string $clientSecret The client's secret (default = "null") * @param string $redirectUri The client's redirect URI (default = "null") + * @param string $grantType The grant type used in the request * @return bool|array Returns false if the validation fails, array on success */ - public function getClient($clientId = null, $clientSecret = null, $redirectUri = null); + public function getClient($clientId = null, $clientSecret = null, $redirectUri = null, $grantType = null); } \ No newline at end of file