From 3721ecb40aed0095210d68784063a98e86aa8b11 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sun, 5 Apr 2015 17:00:43 +0100 Subject: [PATCH] Updated repository interfaces --- src/Repositories/AbstractRepository.php | 51 ------------- .../AccessTokenRepositoryInterface.php | 44 +++++------- src/Repositories/ClientInterface.php | 41 ----------- .../ClientRepositoryInterface.php | 30 ++++++++ src/Repositories/RepositoryInterface.php | 19 +++++ src/Repositories/ScopeInterface.php | 29 -------- src/Repositories/ScopeRepositoryInterface.php | 29 ++++++++ src/Repositories/SessionInterface.php | 72 ------------------- src/Repositories/StorageInterface.php | 27 ------- 9 files changed, 96 insertions(+), 246 deletions(-) delete mode 100644 src/Repositories/AbstractRepository.php delete mode 100644 src/Repositories/ClientInterface.php create mode 100644 src/Repositories/ClientRepositoryInterface.php create mode 100644 src/Repositories/RepositoryInterface.php delete mode 100644 src/Repositories/ScopeInterface.php create mode 100644 src/Repositories/ScopeRepositoryInterface.php delete mode 100644 src/Repositories/SessionInterface.php delete mode 100644 src/Repositories/StorageInterface.php diff --git a/src/Repositories/AbstractRepository.php b/src/Repositories/AbstractRepository.php deleted file mode 100644 index 2bfb5601..00000000 --- a/src/Repositories/AbstractRepository.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Copyright (c) Alex Bilbie - * @license http://mit-license.org/ - * @link https://github.com/thephpleague/oauth2-server - */ - -namespace League\OAuth2\Server\Storage; - -use League\OAuth2\Server\AbstractServer; - -/** - * Abstract storage class - */ -abstract class AbstractStorage implements StorageInterface -{ - /** - * Server - * - * @var \League\OAuth2\Server\AbstractServer $server - */ - protected $server; - - /** - * Set the server - * - * @param \League\OAuth2\Server\AbstractServer $server - * - * @return self - */ - public function setServer(AbstractServer $server) - { - $this->server = $server; - - return $this; - } - - /** - * Return the server - * - * @return \League\OAuth2\Server\AbstractServer - */ - protected function getServer() - { - return $this->server; - } -} diff --git a/src/Repositories/AccessTokenRepositoryInterface.php b/src/Repositories/AccessTokenRepositoryInterface.php index 5f852b80..41e3011c 100644 --- a/src/Repositories/AccessTokenRepositoryInterface.php +++ b/src/Repositories/AccessTokenRepositoryInterface.php @@ -9,61 +9,53 @@ * @link https://github.com/thephpleague/oauth2-server */ -namespace League\OAuth2\Server\Storage; +namespace League\OAuth2\Server\Repositories; -use League\OAuth2\Server\Entity\AccessTokenEntity; -use League\OAuth2\Server\Entity\ScopeEntity; +use League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface; +use League\OAuth2\Server\Entities\Interfaces\ScopeEntityInterface; /** * Access token interface */ -interface AccessTokenInterface extends StorageInterface +interface AccessTokenRepositoryInterface extends RepositoryInterface { /** * Get an instance of Entity\AccessTokenEntity * - * @param string $token The access token + * @param string $tokenIdentifier The access token identifier * - * @return \League\OAuth2\Server\Entity\AccessTokenEntity + * @return \League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface */ - public function get($token); + public function get($tokenIdentifier); /** * Get the scopes for an access token * - * @param \League\OAuth2\Server\Entity\AccessTokenEntity $token The access token + * @param \League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface $token * - * @return array Array of \League\OAuth2\Server\Entity\ScopeEntity + * @return \League\OAuth2\Server\Entities\Interfaces\ScopeEntityInterface[] */ - public function getScopes(AccessTokenEntity $token); + public function getScopes(AccessTokenEntityInterface $token); /** * Creates a new access token * - * @param string $token The access token - * @param integer $expireTime The expire time expressed as a unix timestamp - * @param string|integer $sessionId The session ID - * - * @return void + * @param \League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface $accessTokenEntity */ - public function create($token, $expireTime, $sessionId); + public function create(AccessTokenEntityInterface $accessTokenEntity); /** - * Associate a scope with an acess token + * Associate a scope with an access token * - * @param \League\OAuth2\Server\Entity\AccessTokenEntity $token The access token - * @param \League\OAuth2\Server\Entity\ScopeEntity $scope The scope - * - * @return void + * @param \League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface $accessTokenEntityInterface + * @param \League\OAuth2\Server\Entities\Interfaces\ScopeEntityInterface $scope */ - public function associateScope(AccessTokenEntity $token, ScopeEntity $scope); + public function associateScope(AccessTokenEntityInterface $accessTokenEntityInterface, ScopeEntityInterface $scope); /** * Delete an access token * - * @param \League\OAuth2\Server\Entity\AccessTokenEntity $token The access token to delete - * - * @return void + * @param \League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface $accessToken */ - public function delete(AccessTokenEntity $token); + public function delete(AccessTokenEntityInterface $accessToken); } diff --git a/src/Repositories/ClientInterface.php b/src/Repositories/ClientInterface.php deleted file mode 100644 index 4e9cc39a..00000000 --- a/src/Repositories/ClientInterface.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @copyright Copyright (c) Alex Bilbie - * @license http://mit-license.org/ - * @link https://github.com/thephpleague/oauth2-server - */ - -namespace League\OAuth2\Server\Storage; - -use League\OAuth2\Server\Entity\SessionEntity; - -/** - * Client storage interface - */ -interface ClientInterface extends StorageInterface -{ - /** - * Validate a client - * - * @param string $clientId The client's ID - * @param string $clientSecret The client's secret (default = "null") - * @param string $redirectUri The client's redirect URI (default = "null") - * @param string $grantType The grant type used (default = "null") - * - * @return \League\OAuth2\Server\Entity\ClientEntity - */ - public function get($clientId, $clientSecret = null, $redirectUri = null, $grantType = null); - - /** - * Get the client associated with a session - * - * @param \League\OAuth2\Server\Entity\SessionEntity $session The session - * - * @return \League\OAuth2\Server\Entity\ClientEntity - */ - public function getBySession(SessionEntity $session); -} diff --git a/src/Repositories/ClientRepositoryInterface.php b/src/Repositories/ClientRepositoryInterface.php new file mode 100644 index 00000000..09360909 --- /dev/null +++ b/src/Repositories/ClientRepositoryInterface.php @@ -0,0 +1,30 @@ + + * @copyright Copyright (c) Alex Bilbie + * @license http://mit-license.org/ + * @link https://github.com/thephpleague/oauth2-server + */ + +namespace League\OAuth2\Server\Repositories; + +/** + * Client storage interface + */ +interface ClientRepositoryInterface extends RepositoryInterface +{ + /** + * Get a client + * + * @param string $clientIdentifier The client's identifier + * @param string $clientSecret The client's secret (default = "null") + * @param string $redirectUri The client's redirect URI (default = "null") + * @param string $grantType The grant type used (default = "null") + * + * @return \League\OAuth2\Server\Entities\Interfaces\ClientEntityInterface + */ + public function get($clientIdentifier, $clientSecret = null, $redirectUri = null, $grantType = null); +} diff --git a/src/Repositories/RepositoryInterface.php b/src/Repositories/RepositoryInterface.php new file mode 100644 index 00000000..030c116f --- /dev/null +++ b/src/Repositories/RepositoryInterface.php @@ -0,0 +1,19 @@ + + * @copyright Copyright (c) Alex Bilbie + * @license http://mit-license.org/ + * @link https://github.com/thephpleague/oauth2-server + */ + +namespace League\OAuth2\Server\Repositories; + +/** + * Repository interface + */ +interface RepositoryInterface +{ +} diff --git a/src/Repositories/ScopeInterface.php b/src/Repositories/ScopeInterface.php deleted file mode 100644 index e8bc10b0..00000000 --- a/src/Repositories/ScopeInterface.php +++ /dev/null @@ -1,29 +0,0 @@ - - * @copyright Copyright (c) Alex Bilbie - * @license http://mit-license.org/ - * @link https://github.com/thephpleague/oauth2-server - */ - -namespace League\OAuth2\Server\Storage; - -/** - * Scope interface - */ -interface ScopeInterface extends StorageInterface -{ - /** - * Return information about a scope - * - * @param string $scope The scope - * @param string $grantType The grant type used in the request (default = "null") - * @param string $clientId The client sending the request (default = "null") - * - * @return \League\OAuth2\Server\Entity\ScopeEntity - */ - public function get($scope, $grantType = null, $clientId = null); -} diff --git a/src/Repositories/ScopeRepositoryInterface.php b/src/Repositories/ScopeRepositoryInterface.php new file mode 100644 index 00000000..20bf2590 --- /dev/null +++ b/src/Repositories/ScopeRepositoryInterface.php @@ -0,0 +1,29 @@ + + * @copyright Copyright (c) Alex Bilbie + * @license http://mit-license.org/ + * @link https://github.com/thephpleague/oauth2-server + */ + +namespace League\OAuth2\Server\Repositories; + +/** + * Scope interface + */ +interface ScopeRepositoryInterface extends RepositoryInterface +{ + /** + * Return information about a scope + * + * @param string $scopeIdentifier The scope identifier + * @param string $grantType The grant type used in the request (default = "null") + * @param string $clientId The client sending the request (default = "null") + * + * @return \League\OAuth2\Server\Entities\Interfaces\ScopeEntityInterface + */ + public function get($scopeIdentifier, $grantType = null, $clientId = null); +} diff --git a/src/Repositories/SessionInterface.php b/src/Repositories/SessionInterface.php deleted file mode 100644 index ab205180..00000000 --- a/src/Repositories/SessionInterface.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Copyright (c) Alex Bilbie - * @license http://mit-license.org/ - * @link https://github.com/thephpleague/oauth2-server - */ - -namespace League\OAuth2\Server\Storage; - -use League\OAuth2\Server\Entity\AccessTokenEntity; -use League\OAuth2\Server\Entity\AuthCodeEntity; -use League\OAuth2\Server\Entity\ScopeEntity; -use League\OAuth2\Server\Entity\SessionEntity; - -/** - * Session storage interface - */ -interface SessionInterface extends StorageInterface -{ - /** - * Get a session from an access token - * - * @param \League\OAuth2\Server\Entity\AccessTokenEntity $accessToken The access token - * - * @return \League\OAuth2\Server\Entity\SessionEntity - */ - public function getByAccessToken(AccessTokenEntity $accessToken); - - /** - * Get a session from an auth code - * - * @param \League\OAuth2\Server\Entity\AuthCodeEntity $authCode The auth code - * - * @return \League\OAuth2\Server\Entity\SessionEntity - */ - public function getByAuthCode(AuthCodeEntity $authCode); - - /** - * Get a session's scopes - * - * @param \League\OAuth2\Server\Entity\SessionEntity - * - * @return array Array of \League\OAuth2\Server\Entity\ScopeEntity - */ - public function getScopes(SessionEntity $session); - - /** - * Create a new session - * - * @param string $ownerType Session owner's type (user, client) - * @param string $ownerId Session owner's ID - * @param string $clientId Client ID - * @param string $clientRedirectUri Client redirect URI (default = null) - * - * @return integer The session's ID - */ - public function create($ownerType, $ownerId, $clientId, $clientRedirectUri = null); - - /** - * Associate a scope with a session - * - * @param \League\OAuth2\Server\Entity\SessionEntity $session The session - * @param \League\OAuth2\Server\Entity\ScopeEntity $scope The scope - * - * @return void - */ - public function associateScope(SessionEntity $session, ScopeEntity $scope); -} diff --git a/src/Repositories/StorageInterface.php b/src/Repositories/StorageInterface.php deleted file mode 100644 index ff9614b5..00000000 --- a/src/Repositories/StorageInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @copyright Copyright (c) Alex Bilbie - * @license http://mit-license.org/ - * @link https://github.com/thephpleague/oauth2-server - */ - -namespace League\OAuth2\Server\Storage; - -use League\OAuth2\Server\AbstractServer; - -/** - * Storage interface - */ -interface StorageInterface -{ - /** - * Set the server - * - * @param \League\OAuth2\Server\AbstractServer $server - */ - public function setServer(AbstractServer $server); -}