Updated scope validation

This commit is contained in:
Alex Bilbie
2016-03-24 10:04:15 +00:00
parent 614fbde56e
commit 6383a58755
9 changed files with 39 additions and 44 deletions

View File

@@ -2,6 +2,8 @@
namespace OAuth2ServerExamples\Repositories;
use League\OAuth2\Server\Entities\Interfaces\ClientEntityInterface;
use League\OAuth2\Server\Entities\Interfaces\ScopeEntityInterface;
use League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
use OAuth2ServerExamples\Entities\ScopeEntity;
@@ -10,7 +12,7 @@ class ScopeRepository implements ScopeRepositoryInterface
/**
* {@inheritdoc}
*/
public function getScopeEntityByIdentifier($scopeIdentifier, $grantType, $clientId = null)
public function getScopeEntityByIdentifier($scopeIdentifier)
{
$scopes = [
'basic' => [
@@ -30,4 +32,17 @@ class ScopeRepository implements ScopeRepositoryInterface
return $scope;
}
/**
* @inheritdoc
*/
public function finalizeScopes(
array $scopes,
$grantType,
ClientEntityInterface $clientEntity,
$userIdentifier = null
) {
return $scopes;
}
}

View File

@@ -3,7 +3,6 @@
namespace OAuth2ServerExamples\Repositories;
use League\OAuth2\Server\Entities\Interfaces\ClientEntityInterface;
use League\OAuth2\Server\Entities\Interfaces\ScopeEntityInterface;
use League\OAuth2\Server\Repositories\UserRepositoryInterface;
use OAuth2ServerExamples\Entities\ScopeEntity;
use OAuth2ServerExamples\Entities\UserEntity;
@@ -11,22 +10,13 @@ use OAuth2ServerExamples\Entities\UserEntity;
class UserRepository implements UserRepositoryInterface
{
/**
* Get a user entity.
*
* @param string $username
* @param string $password
* @param string $grantType The grant type used
* @param \League\OAuth2\Server\Entities\Interfaces\ClientEntityInterface $clientEntity
* @param ScopeEntityInterface[] $scopes
*
* @return \League\OAuth2\Server\Entities\Interfaces\UserEntityInterface
* @inheritdoc
*/
public function getUserEntityByUserCredentials(
$username,
$password,
$grantType,
ClientEntityInterface $clientEntity,
array &$scopes
ClientEntityInterface $clientEntity
) {
if ($username === 'alex' && $password === 'whisky') {
$scope = new ScopeEntity();