mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-22 21:19:46 +05:30
Fix #232
This commit is contained in:
parent
fa55a791e7
commit
856051bfb3
@ -64,15 +64,6 @@ class ResourceServer extends AbstractServer
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the query string key for the access token.
|
||||
* @return string
|
||||
*/
|
||||
public function getIdKey()
|
||||
{
|
||||
return $this->tokenKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the query string key for the access token.
|
||||
* @param $key The new query string key
|
||||
@ -85,24 +76,6 @@ class ResourceServer extends AbstractServer
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the access token owner ID
|
||||
* @return string
|
||||
*/
|
||||
public function getOwnerId()
|
||||
{
|
||||
return $this->accessToken->getSession()->getOwnerId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the owner type
|
||||
* @return string
|
||||
*/
|
||||
public function getOwnerType()
|
||||
{
|
||||
return $this->accessToken->getSession()->getOwnerType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the access token
|
||||
* @return string
|
||||
@ -112,46 +85,6 @@ class ResourceServer extends AbstractServer
|
||||
return $this->accessToken->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the client ID that created the session
|
||||
* @return string
|
||||
*/
|
||||
public function getClientId()
|
||||
{
|
||||
return $this->accessToken->getSession()->getClient()->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the session scopes
|
||||
* @return array
|
||||
*/
|
||||
public function getScopes()
|
||||
{
|
||||
return $this->accessToken->getScopes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the presented access token has the given scope(s)
|
||||
* @param array|string $scopes An array of scopes or a single scope as a string
|
||||
* @return bool Returns bool if all scopes are found, false if any fail
|
||||
*/
|
||||
public function hasScope($scopes)
|
||||
{
|
||||
if (is_string($scopes)) {
|
||||
return $this->accessToken->hasScope($scopes);
|
||||
}
|
||||
|
||||
if (is_array($scopes)) {
|
||||
foreach ($scopes as $scope) {
|
||||
if (!$this->accessToken->hasScope($scope)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the access token is valid or not
|
||||
* @param $headersOnly Limit Access Token to Authorization header only
|
||||
|
@ -165,17 +165,6 @@ class ResourceServerTest extends \PHPUnit_Framework_TestCase
|
||||
$server->setRequest($request);
|
||||
|
||||
$this->assertTrue($server->isValidRequest());
|
||||
$this->assertEquals('at', $server->getIdKey());
|
||||
$this->assertEquals(123, $server->getOwnerId());
|
||||
$this->assertEquals('user', $server->getOwnerType());
|
||||
$this->assertEquals('abcdef', $server->getAccessToken());
|
||||
$this->assertEquals('testapp', $server->getClientId());
|
||||
$this->assertTrue($server->hasScope('foo'));
|
||||
$this->assertTrue($server->hasScope('bar'));
|
||||
$this->assertTrue($server->hasScope(['foo', 'bar']));
|
||||
$this->assertTrue(isset($server->getScopes()['foo']));
|
||||
$this->assertTrue(isset($server->getScopes()['bar']));
|
||||
$this->assertFalse($server->hasScope(['foobar']));
|
||||
$this->assertFalse($server->hasScope('foobar'));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user