Merge pull request #184 from fahmiardi/basic-authentication

[4.0] Basic authentication
This commit is contained in:
Alex Bilbie
2014-07-06 20:07:11 +01:00
4 changed files with 32 additions and 8 deletions

View File

@@ -164,14 +164,20 @@ class AuthCodeGrant extends AbstractGrant
{ {
// Get the required params // Get the required params
$clientId = $this->server->getRequest()->request->get('client_id', null); $clientId = $this->server->getRequest()->request->get('client_id', null);
if (is_null($clientId)) {
$clientId = $this->server->getRequest()->getUser();
if (is_null($clientId)) { if (is_null($clientId)) {
throw new Exception\InvalidRequestException('client_id'); throw new Exception\InvalidRequestException('client_id');
} }
}
$clientSecret = $this->server->getRequest()->request->get('client_secret', null); $clientSecret = $this->server->getRequest()->request->get('client_secret', null);
if (is_null($clientSecret)) {
$clientSecret = $this->server->getRequest()->getPassword();
if (is_null($clientSecret)) { if (is_null($clientSecret)) {
throw new Exception\InvalidRequestException('client_secret'); throw new Exception\InvalidRequestException('client_secret');
} }
}
$redirectUri = $this->server->getRequest()->request->get('redirect_uri', null); $redirectUri = $this->server->getRequest()->request->get('redirect_uri', null);
if (is_null($redirectUri)) { if (is_null($redirectUri)) {

View File

@@ -55,14 +55,20 @@ class ClientCredentialsGrant extends AbstractGrant
{ {
// Get the required params // Get the required params
$clientId = $this->server->getRequest()->request->get('client_id', null); $clientId = $this->server->getRequest()->request->get('client_id', null);
if (is_null($clientId)) {
$clientId = $this->server->getRequest()->getUser();
if (is_null($clientId)) { if (is_null($clientId)) {
throw new Exception\InvalidRequestException('client_id'); throw new Exception\InvalidRequestException('client_id');
} }
}
$clientSecret = $this->server->getRequest()->request->get('client_secret', null); $clientSecret = $this->server->getRequest()->request->get('client_secret', null);
if (is_null($clientSecret)) {
$clientSecret = $this->server->getRequest()->getPassword();
if (is_null($clientSecret)) { if (is_null($clientSecret)) {
throw new Exception\InvalidRequestException('client_secret'); throw new Exception\InvalidRequestException('client_secret');
} }
}
// Validate client ID and client secret // Validate client ID and client secret
$client = $this->server->getStorage('client')->get( $client = $this->server->getStorage('client')->get(

View File

@@ -79,14 +79,20 @@ class PasswordGrant extends AbstractGrant
{ {
// Get the required params // Get the required params
$clientId = $this->server->getRequest()->request->get('client_id', null); $clientId = $this->server->getRequest()->request->get('client_id', null);
if (is_null($clientId)) {
$clientId = $this->server->getRequest()->getUser();
if (is_null($clientId)) { if (is_null($clientId)) {
throw new Exception\InvalidRequestException('client_id'); throw new Exception\InvalidRequestException('client_id');
} }
}
$clientSecret = $this->server->getRequest()->request->get('client_secret', null); $clientSecret = $this->server->getRequest()->request->get('client_secret', null);
if (is_null($clientSecret)) {
$clientSecret = $this->server->getRequest()->getPassword();
if (is_null($clientSecret)) { if (is_null($clientSecret)) {
throw new Exception\InvalidRequestException('client_secret'); throw new Exception\InvalidRequestException('client_secret');
} }
}
// Validate client ID and client secret // Validate client ID and client secret
$client = $this->server->getStorage('client')->get( $client = $this->server->getStorage('client')->get(

View File

@@ -59,14 +59,20 @@ class RefreshTokenGrant extends AbstractGrant
public function completeFlow() public function completeFlow()
{ {
$clientId = $this->server->getRequest()->request->get('client_id', null); $clientId = $this->server->getRequest()->request->get('client_id', null);
if (is_null($clientId)) {
$clientId = $this->server->getRequest()->getUser();
if (is_null($clientId)) { if (is_null($clientId)) {
throw new Exception\InvalidRequestException('client_id'); throw new Exception\InvalidRequestException('client_id');
} }
}
$clientSecret = $this->server->getRequest()->request->get('client_secret', null); $clientSecret = $this->server->getRequest()->request->get('client_secret', null);
if (is_null($clientSecret)) {
$clientSecret = $this->server->getRequest()->getPassword();
if (is_null($clientSecret)) { if (is_null($clientSecret)) {
throw new Exception\InvalidRequestException('client_secret'); throw new Exception\InvalidRequestException('client_secret');
} }
}
// Validate client ID and client secret // Validate client ID and client secret
$client = $this->server->getStorage('client')->get( $client = $this->server->getStorage('client')->get(