If the client should redirect during AuthCodeGrant authorisation then provide a redirect uri

This commit is contained in:
Alex Bilbie
2014-11-08 17:03:15 +00:00
parent b9debaab26
commit 6b29b7450e
6 changed files with 34 additions and 18 deletions

View File

@@ -121,11 +121,12 @@ abstract class AbstractGrant implements GrantTypeInterface
/**
* Given a list of scopes, validate them and return an array of Scope entities
* @param string $scopeParam A string of scopes (e.g. "profile email birthday")
* @param \League\OAuth2\Server\Entity\ClientEntity $client A string of scopes (e.g. "profile email birthday")
* @param \League\OAuth2\Server\Entity\ClientEntity $client Client entity
* @param string|null $redirectUri The redirect URI to return the user to
* @return \League\OAuth2\Server\Entity\ScopeEntity[]
* @throws \League\OAuth2\Server\Exception\ClientException If scope is invalid, or no scopes passed when required
* @throws \League\OAuth2\Server\Exception\InvalidScopeException If scope is invalid, or no scopes passed when required
*/
public function validateScopes($scopeParam = '', ClientEntity $client)
public function validateScopes($scopeParam = '', ClientEntity $client, $redirectUri = null)
{
$scopesList = explode($this->server->getScopeDelimeter(), $scopeParam);
@@ -160,7 +161,7 @@ abstract class AbstractGrant implements GrantTypeInterface
);
if (($scope instanceof ScopeEntity) === false) {
throw new Exception\InvalidScopeException($scopeItem, true);
throw new Exception\InvalidScopeException($scopeItem, $redirectUri);
}
$scopes[$scope->getId()] = $scope;

View File

@@ -99,22 +99,22 @@ class AuthCodeGrant extends AbstractGrant
$state = $this->server->getRequest()->query->get('state', null);
if ($this->server->stateParamRequired() === true && is_null($state)) {
throw new Exception\InvalidRequestException('state', true);
throw new Exception\InvalidRequestException('state', $redirectUri);
}
$responseType = $this->server->getRequest()->query->get('response_type', null);
if (is_null($responseType)) {
throw new Exception\InvalidRequestException('response_type', true);
throw new Exception\InvalidRequestException('response_type', $redirectUri);
}
// Ensure response type is one that is recognised
if (!in_array($responseType, $this->server->getResponseTypes())) {
throw new Exception\UnsupportedResponseTypeException($responseType);
throw new Exception\UnsupportedResponseTypeException($responseType, $redirectUri);
}
// Validate any scopes that are in the request
$scopeParam = $this->server->getRequest()->query->get('scope', '');
$scopes = $this->validateScopes($scopeParam, $client);
$scopes = $this->validateScopes($scopeParam, $client, $redirectUri);
return [
'client' => $client,