This commit is contained in:
Alex Bilbie
2014-09-30 23:55:21 +01:00
parent 62d658524b
commit 136edf16c5
8 changed files with 30 additions and 14 deletions

View File

@@ -13,6 +13,7 @@ namespace League\OAuth2\Server\Grant;
use League\OAuth2\Server\AuthorizationServer;
use League\OAuth2\Server\Entity\ScopeEntity;
use League\OAuth2\Server\Entity\ClientEntity;
use League\OAuth2\Server\Exception;
/**
@@ -120,10 +121,11 @@ abstract class AbstractGrant implements GrantTypeInterface
/**
* Given a list of scopes, validate them and return an arrary of Scope entities
* @param string $scopeParam A string of scopes (e.g. "profile email birthday")
* @param ClientEntity $client A string of scopes (e.g. "profile email birthday")
* @return array
* @throws ClientException If scope is invalid, or no scopes passed when required
*/
public function validateScopes($scopeParam = '')
public function validateScopes($scopeParam = '', ClientEntity $client)
{
$scopesList = explode($this->server->getScopeDelimeter(), $scopeParam);
@@ -153,7 +155,8 @@ abstract class AbstractGrant implements GrantTypeInterface
foreach ($scopesList as $scopeItem) {
$scope = $this->server->getStorage('scope')->get(
$scopeItem,
$this->getIdentifier()
$this->getIdentifier(),
$client->getId()
);
if (($scope instanceof ScopeEntity) === false) {

View File

@@ -114,7 +114,7 @@ class AuthCodeGrant extends AbstractGrant
// Validate any scopes that are in the request
$scopeParam = $this->server->getRequest()->query->get('scope', '');
$scopes = $this->validateScopes($scopeParam);
$scopes = $this->validateScopes($scopeParam, $client);
return [
'client' => $client,

View File

@@ -86,7 +86,7 @@ class ClientCredentialsGrant extends AbstractGrant
// Validate any scopes that are in the request
$scopeParam = $this->server->getRequest()->request->get('scope', '');
$scopes = $this->validateScopes($scopeParam);
$scopes = $this->validateScopes($scopeParam, $client);
// Create a new session
$session = new SessionEntity($this->server);

View File

@@ -127,7 +127,7 @@ class PasswordGrant extends AbstractGrant
// Validate any scopes that are in the request
$scopeParam = $this->server->getRequest()->request->get('scope', '');
$scopes = $this->validateScopes($scopeParam);
$scopes = $this->validateScopes($scopeParam, $client);
// Create a new session
$session = new SessionEntity($this->server);

View File

@@ -108,7 +108,7 @@ class RefreshTokenGrant extends AbstractGrant
// Get and validate any requested scopes
$requestedScopesString = $this->server->getRequest()->request->get('scope', '');
$requestedScopes = $this->validateScopes($requestedScopesString);
$requestedScopes = $this->validateScopes($requestedScopesString, $client);
// If no new scopes are requested then give the access token the original session scopes
if (count($requestedScopes) === 0) {