Updated repository interfaces

This commit is contained in:
Alex Bilbie 2015-04-05 17:00:43 +01:00
parent 5fcf01f4c8
commit 3721ecb40a
9 changed files with 96 additions and 246 deletions

View File

@ -1,51 +0,0 @@
<?php
/**
* OAuth 2.0 abstract storage
*
* @package league/oauth2-server
* @author Alex Bilbie <hello@alexbilbie.com>
* @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;
}
}

View File

@ -9,61 +9,53 @@
* @link https://github.com/thephpleague/oauth2-server * @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\Entities\Interfaces\AccessTokenEntityInterface;
use League\OAuth2\Server\Entity\ScopeEntity; use League\OAuth2\Server\Entities\Interfaces\ScopeEntityInterface;
/** /**
* Access token interface * Access token interface
*/ */
interface AccessTokenInterface extends StorageInterface interface AccessTokenRepositoryInterface extends RepositoryInterface
{ {
/** /**
* Get an instance of Entity\AccessTokenEntity * 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 * 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 * Creates a new access token
* *
* @param string $token The access token * @param \League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface $accessTokenEntity
* @param integer $expireTime The expire time expressed as a unix timestamp
* @param string|integer $sessionId The session ID
*
* @return void
*/ */
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\Entities\Interfaces\AccessTokenEntityInterface $accessTokenEntityInterface
* @param \League\OAuth2\Server\Entity\ScopeEntity $scope The scope * @param \League\OAuth2\Server\Entities\Interfaces\ScopeEntityInterface $scope
*
* @return void
*/ */
public function associateScope(AccessTokenEntity $token, ScopeEntity $scope); public function associateScope(AccessTokenEntityInterface $accessTokenEntityInterface, ScopeEntityInterface $scope);
/** /**
* Delete an access token * Delete an access token
* *
* @param \League\OAuth2\Server\Entity\AccessTokenEntity $token The access token to delete * @param \League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface $accessToken
*
* @return void
*/ */
public function delete(AccessTokenEntity $token); public function delete(AccessTokenEntityInterface $accessToken);
} }

View File

@ -1,41 +0,0 @@
<?php
/**
* OAuth 2.0 Client storage interface
*
* @package league/oauth2-server
* @author Alex Bilbie <hello@alexbilbie.com>
* @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);
}

View File

@ -0,0 +1,30 @@
<?php
/**
* OAuth 2.0 Client storage interface
*
* @package league/oauth2-server
* @author Alex Bilbie <hello@alexbilbie.com>
* @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);
}

View File

@ -0,0 +1,19 @@
<?php
/**
* OAuth 2.0 Repository interface
*
* @package league/oauth2-server
* @author Alex Bilbie <hello@alexbilbie.com>
* @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
{
}

View File

@ -1,29 +0,0 @@
<?php
/**
* OAuth 2.0 Scope storage interface
*
* @package league/oauth2-server
* @author Alex Bilbie <hello@alexbilbie.com>
* @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);
}

View File

@ -0,0 +1,29 @@
<?php
/**
* OAuth 2.0 Scope storage interface
*
* @package league/oauth2-server
* @author Alex Bilbie <hello@alexbilbie.com>
* @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);
}

View File

@ -1,72 +0,0 @@
<?php
/**
* OAuth 2.0 Session storage interface
*
* @package league/oauth2-server
* @author Alex Bilbie <hello@alexbilbie.com>
* @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);
}

View File

@ -1,27 +0,0 @@
<?php
/**
* OAuth 2.0 Storage interface
*
* @package league/oauth2-server
* @author Alex Bilbie <hello@alexbilbie.com>
* @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);
}