mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-15 17:56:14 +05:30
Accept token instead of strings
This commit is contained in:
parent
b5f02d0739
commit
16bdc36ccb
@ -164,7 +164,7 @@ abstract class AbstractToken
|
||||
{
|
||||
if ($this->scopes === null) {
|
||||
$this->scopes = $this->formatScopes(
|
||||
$this->server->getStorage('access_token')->getScopes($this->getToken())
|
||||
$this->server->getStorage('access_token')->getScopes($this)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ class AccessToken extends AbstractToken
|
||||
|
||||
// Associate the scope with the token
|
||||
foreach ($this->getScopes() as $scope) {
|
||||
$this->server->getStorage('access_token')->associateScope($this->getToken(), $scope->getId());
|
||||
$this->server->getStorage('access_token')->associateScope($this, $scope);
|
||||
}
|
||||
|
||||
return $this;
|
||||
@ -46,6 +46,6 @@ class AccessToken extends AbstractToken
|
||||
*/
|
||||
public function expire()
|
||||
{
|
||||
$this->server->getStorage('access_token')->delete($this->getToken());
|
||||
$this->server->getStorage('access_token')->delete($this);
|
||||
}
|
||||
}
|
||||
|
@ -11,26 +11,37 @@
|
||||
|
||||
namespace League\OAuth2\Server\Storage;
|
||||
|
||||
use League\OAuth2\Server\Entity\AccessToken;
|
||||
use League\OAuth2\Server\Entity\AbstractToken;
|
||||
use League\OAuth2\Server\Entity\RefreshToken;
|
||||
use League\OAuth2\Server\Entity\AuthCode;
|
||||
use League\OAuth2\Server\Entity\Scope;
|
||||
|
||||
/**
|
||||
* Access token interface
|
||||
*/
|
||||
interface AccessTokenInterface
|
||||
{
|
||||
/**
|
||||
* Get an instance of Entites\AccessToken
|
||||
* Get an instance of Entity\AccessToken
|
||||
* @param string $token The access token
|
||||
* @return \League\OAuth2\Server\Entity\AccessToken
|
||||
*/
|
||||
public function get($token);
|
||||
|
||||
public function getByRefreshToken($refreshToken);
|
||||
/**
|
||||
* Get the access token associated with an access token
|
||||
* @param \League\OAuth2\Server\Entity\RefreshToken $refreshToken
|
||||
* @return \League\OAuth2\Server\Entity\AccessToken
|
||||
*/
|
||||
public function getByRefreshToken(RefreshToken $refreshToken);
|
||||
|
||||
/**
|
||||
* Get the scopes for an access token
|
||||
* @param string $token The access token
|
||||
* @param \League\OAuth2\Server\Entity\AbstractToken $token The access token
|
||||
* @return array Array of \League\OAuth2\Server\Entity\Scope
|
||||
*/
|
||||
public function getScopes($token);
|
||||
public function getScopes(AbstractToken $token);
|
||||
|
||||
/**
|
||||
* Creates a new access token
|
||||
@ -43,16 +54,16 @@ interface AccessTokenInterface
|
||||
|
||||
/**
|
||||
* Associate a scope with an acess token
|
||||
* @param string $token The access token
|
||||
* @param string $scope The scope
|
||||
* @param \League\OAuth2\Server\Entity\AbstractToken $token The access token
|
||||
* @param \League\OAuth2\Server\Entity\Scope $scope The scope
|
||||
* @return void
|
||||
*/
|
||||
public function associateScope($token, $scope);
|
||||
public function associateScope(AbstractToken $token, Scope $scope);
|
||||
|
||||
/**
|
||||
* Delete an access token
|
||||
* @param string $token The access token to delete
|
||||
* @param \League\OAuth2\Server\Entity\AbstractToken $token The access token to delete
|
||||
* @return void
|
||||
*/
|
||||
public function delete($token);
|
||||
public function delete(AbstractToken $token);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user