mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-23 05:29:52 +05:30
Renamed entities (added Entity to the end of class name)
This commit is contained in:
parent
e5315dc016
commit
bdd2bc322c
@ -20,7 +20,7 @@ use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
/**
|
||||
* Abstract token class
|
||||
*/
|
||||
abstract class AbstractToken
|
||||
abstract class AbstractTokenEntity
|
||||
{
|
||||
/**
|
||||
* Access token ID
|
||||
@ -30,7 +30,7 @@ abstract class AbstractToken
|
||||
|
||||
/**
|
||||
* Associated session
|
||||
* @var \League\OAuth2\Server\Session
|
||||
* @var \League\OAuth2\Server\SessionEntity
|
||||
*/
|
||||
protected $session;
|
||||
|
||||
@ -48,7 +48,7 @@ abstract class AbstractToken
|
||||
|
||||
/**
|
||||
* Authorization or resource server
|
||||
* @var \League\OAuth2\Server\Authorization|\League\OAuth2\Server\Resource
|
||||
* @var \League\OAuth2\Server\AbstractServer
|
||||
*/
|
||||
protected $server;
|
||||
|
||||
@ -65,29 +65,15 @@ abstract class AbstractToken
|
||||
|
||||
/**
|
||||
* Set session
|
||||
* @param \League\OAuth2\Server\Session $session
|
||||
* @param \League\OAuth2\Server\SessionEntity $session
|
||||
* @return self
|
||||
*/
|
||||
public function setSession(Session $session)
|
||||
public function setSession(SessionEntity $session)
|
||||
{
|
||||
$this->session = $session;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get session
|
||||
* @return \League\OAuth2\Server\Session
|
||||
*/
|
||||
public function getSession()
|
||||
{
|
||||
if ($this->session instanceof Session) {
|
||||
return $this->session;
|
||||
}
|
||||
|
||||
$this->session = $this->server->getStorage('session')->getByAccessToken($this->token);
|
||||
return $this->session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the expire time of the token
|
||||
* @param integer $expireTime Unix time stamp
|
||||
@ -130,10 +116,10 @@ abstract class AbstractToken
|
||||
|
||||
/**
|
||||
* Associate a scope
|
||||
* @param \League\OAuth2\Server\Entity\Scope $scope
|
||||
* @param \League\OAuth2\Server\Entity\ScopeEntity $scope
|
||||
* @return self
|
||||
*/
|
||||
public function associateScope(Scope $scope)
|
||||
public function associateScope(ScopeEntity $scope)
|
||||
{
|
||||
if (!isset($this->scopes[$scope->getId()])) {
|
||||
$this->scopes[$scope->getId()] = $scope;
|
||||
@ -142,35 +128,6 @@ abstract class AbstractToken
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if access token has an associated scope
|
||||
* @param string $scope Scope to check
|
||||
* @return bool
|
||||
*/
|
||||
public function hasScope($scope)
|
||||
{
|
||||
if ($this->scopes === null) {
|
||||
$this->getScopes();
|
||||
}
|
||||
|
||||
return isset($this->scopes[$scope]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all scopes associated with the session
|
||||
* @return array Array of \League\OAuth2\Server\Entity\Scope
|
||||
*/
|
||||
public function getScopes()
|
||||
{
|
||||
if ($this->scopes === null) {
|
||||
$this->scopes = $this->formatScopes(
|
||||
$this->server->getStorage('access_token')->getScopes($this)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->scopes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the local scopes array
|
||||
* @param array $unformatted Array of \League\OAuth2\Server\Entity\Scope
|
||||
@ -180,7 +137,7 @@ abstract class AbstractToken
|
||||
{
|
||||
$scopes = [];
|
||||
foreach ($unformatted as $scope) {
|
||||
if ($scope instanceof Scope) {
|
||||
if ($scope instanceof ScopeEntity) {
|
||||
$scopes[$scope->getId()] = $scope;
|
||||
}
|
||||
}
|
@ -20,8 +20,51 @@ use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
/**
|
||||
* Access token entity class
|
||||
*/
|
||||
class AccessToken extends AbstractToken
|
||||
class AccessTokenEntity extends AbstractTokenEntity
|
||||
{
|
||||
/**
|
||||
* Get session
|
||||
* @return \League\OAuth2\Server\SessionEntity
|
||||
*/
|
||||
public function getSession()
|
||||
{
|
||||
if ($this->session instanceof SessionEntity) {
|
||||
return $this->session;
|
||||
}
|
||||
|
||||
$this->session = $this->server->getStorage('session')->getByAccessToken($this);
|
||||
return $this->session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if access token has an associated scope
|
||||
* @param string $scope Scope to check
|
||||
* @return bool
|
||||
*/
|
||||
public function hasScope($scope)
|
||||
{
|
||||
if ($this->scopes === null) {
|
||||
$this->getScopes();
|
||||
}
|
||||
|
||||
return isset($this->scopes[$scope]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all scopes associated with the session
|
||||
* @return array Array of \League\OAuth2\Server\Entity\Scope
|
||||
*/
|
||||
public function getScopes()
|
||||
{
|
||||
if ($this->scopes === null) {
|
||||
$this->scopes = $this->formatScopes(
|
||||
$this->server->getStorage('access_token')->getScopes($this)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->scopes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
@ -20,7 +20,7 @@ use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
/**
|
||||
* Access token entity class
|
||||
*/
|
||||
class AuthCode extends AbstractToken
|
||||
class AuthCodeEntity extends AbstractTokenEntity
|
||||
{
|
||||
/**
|
||||
* Redirect URI
|
||||
@ -49,7 +49,7 @@ class AuthCode extends AbstractToken
|
||||
}
|
||||
|
||||
/**
|
||||
* [generateRedirectUri description]
|
||||
* Generate a redirect URI
|
||||
* @param string $state The state parameter if set by the client
|
||||
* @param string $queryDelimeter The query delimiter ('?' for auth code grant, '#' for implicit grant)
|
||||
* @return string
|
||||
@ -69,11 +69,11 @@ class AuthCode extends AbstractToken
|
||||
*/
|
||||
public function getSession()
|
||||
{
|
||||
if ($this->session instanceof Session) {
|
||||
if ($this->session instanceof SessionEntity) {
|
||||
return $this->session;
|
||||
}
|
||||
|
||||
$this->session = $this->server->getStorage('session')->getByAuthCode($this->token);
|
||||
$this->session = $this->server->getStorage('session')->getByAuthCode($this);
|
||||
return $this->session;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ use League\OAuth2\Server\AbstractServer;
|
||||
/**
|
||||
* Client entity class
|
||||
*/
|
||||
class Client
|
||||
class ClientEntity
|
||||
{
|
||||
/**
|
||||
* Client identifier
|
@ -20,7 +20,7 @@ use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
/**
|
||||
* Refresh token entity class
|
||||
*/
|
||||
class RefreshToken extends AbstractToken
|
||||
class RefreshTokenEntity extends AbstractTokenEntity
|
||||
{
|
||||
/**
|
||||
* Access token associated to refresh token
|
||||
@ -30,10 +30,10 @@ class RefreshToken extends AbstractToken
|
||||
|
||||
/**
|
||||
* Associate an access token
|
||||
* @param \League\OAuth2\Server\Entity\AccessToken $accessToken
|
||||
* @param \League\OAuth2\Server\Entity\AccessTokenEntity $accessToken
|
||||
* @return self
|
||||
*/
|
||||
public function setAccessToken(AccessToken $accessToken)
|
||||
public function setAccessToken(AccessTokenEntity $accessToken)
|
||||
{
|
||||
$this->accessToken = $accessToken;
|
||||
return $this;
|
||||
@ -45,7 +45,7 @@ class RefreshToken extends AbstractToken
|
||||
*/
|
||||
public function getAccessToken()
|
||||
{
|
||||
if (! $this->accessToken instanceof AccessToken) {
|
||||
if (! $this->accessToken instanceof AccessTokenEntity) {
|
||||
$this->accessToken = $this->server->getStorage('access_token')->getByRefreshToken($this);
|
||||
}
|
||||
return $this->accessToken;
|
@ -17,7 +17,7 @@ use League\OAuth2\Server\AbstractServer;
|
||||
/**
|
||||
* Scope entity class
|
||||
*/
|
||||
class Scope
|
||||
class ScopeEntity
|
||||
{
|
||||
/**
|
||||
* Scope identifier
|
||||
@ -33,7 +33,7 @@ class Scope
|
||||
|
||||
/**
|
||||
* Authorization or resource server
|
||||
* @var \League\OAuth2\Server\Authorization|\League\OAuth2\Server\Resource
|
||||
* @var \League\OAuth2\Server\AbstractServer
|
||||
*/
|
||||
protected $server;
|
||||
|
@ -20,7 +20,7 @@ use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
/**
|
||||
* Session entity grant
|
||||
*/
|
||||
class Session
|
||||
class SessionEntity
|
||||
{
|
||||
/**
|
||||
* Session identifier
|
||||
@ -48,19 +48,19 @@ class Session
|
||||
|
||||
/**
|
||||
* Auth code
|
||||
* @var \League\OAuth2\Server\Entity\AuthCode
|
||||
* @var \League\OAuth2\Server\Entity\AuthCodeEntity
|
||||
*/
|
||||
protected $authCode;
|
||||
|
||||
/**
|
||||
* Access token
|
||||
* @var \League\OAuth2\Server\Entity\AccessToken
|
||||
* @var \League\OAuth2\Server\Entity\AccessTokenEntity
|
||||
*/
|
||||
protected $accessToken;
|
||||
|
||||
/**
|
||||
* Refresh token
|
||||
* @var \League\OAuth2\Server\Entity\RefreshToken
|
||||
* @var \League\OAuth2\Server\Entity\RefreshTokenEntity
|
||||
*/
|
||||
protected $refreshToken;
|
||||
|
||||
@ -109,10 +109,10 @@ class Session
|
||||
|
||||
/**
|
||||
* Associate a scope
|
||||
* @param \League\OAuth2\Server\Entity\Scope $scope
|
||||
* @param \League\OAuth2\Server\Entity\ScopeEntity $scope
|
||||
* @return self
|
||||
*/
|
||||
public function associateScope(Scope $scope)
|
||||
public function associateScope(ScopeEntity $scope)
|
||||
{
|
||||
if (!isset($this->scopes[$scope->getId()])) {
|
||||
$this->scopes[$scope->getId()] = $scope;
|
||||
@ -158,7 +158,7 @@ class Session
|
||||
$scopes = [];
|
||||
if (is_array($unformated)) {
|
||||
foreach ($unformated as $scope) {
|
||||
if ($scope instanceof Scope) {
|
||||
if ($scope instanceof ScopeEntity) {
|
||||
$scopes[$scope->getId()] = $scope;
|
||||
}
|
||||
}
|
||||
@ -168,10 +168,10 @@ class Session
|
||||
|
||||
/**
|
||||
* Associate an access token with the session
|
||||
* @param \League\OAuth2\Server\Entity\AccessToken $accessToken
|
||||
* @param \League\OAuth2\Server\Entity\AccessTokenEntity $accessToken
|
||||
* @return self
|
||||
*/
|
||||
public function associateAccessToken(AccessToken $accessToken)
|
||||
public function associateAccessToken(AccessTokenEntity $accessToken)
|
||||
{
|
||||
$this->accessToken = $accessToken;
|
||||
return $this;
|
||||
@ -179,10 +179,10 @@ class Session
|
||||
|
||||
/**
|
||||
* Associate a refresh token with the session
|
||||
* @param \League\OAuth2\Server\Entity\RefreshToken $refreshToken
|
||||
* @param \League\OAuth2\Server\Entity\RefreshTokenEntity $refreshToken
|
||||
* @return self
|
||||
*/
|
||||
public function associateRefreshToken(RefreshToken $refreshToken)
|
||||
public function associateRefreshToken(RefreshTokenEntity $refreshToken)
|
||||
{
|
||||
$this->refreshToken = $refreshToken;
|
||||
return $this;
|
||||
@ -190,10 +190,10 @@ class Session
|
||||
|
||||
/**
|
||||
* Associate a client with the session
|
||||
* @param League\OAuth2\Server\Entity\Client $client The client
|
||||
* @param League\OAuth2\Server\Entity\ClientEntity $client The client
|
||||
* @return self
|
||||
*/
|
||||
public function associateClient(Client $client)
|
||||
public function associateClient(ClientEntity $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
return $this;
|
||||
@ -205,7 +205,7 @@ class Session
|
||||
*/
|
||||
public function getClient()
|
||||
{
|
||||
if ($this->client instanceof Client) {
|
||||
if ($this->client instanceof ClientEntity) {
|
||||
return $this->client;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user