diff --git a/examples/relational/Model/Users.php b/examples/relational/Model/Users.php index 44af86f3..76caab85 100644 --- a/examples/relational/Model/Users.php +++ b/examples/relational/Model/Users.php @@ -20,6 +20,6 @@ class Users return $result; } - return null; + return; } } diff --git a/examples/relational/Storage/AccessTokenStorage.php b/examples/relational/Storage/AccessTokenStorage.php index c724e43f..59e27362 100644 --- a/examples/relational/Storage/AccessTokenStorage.php +++ b/examples/relational/Storage/AccessTokenStorage.php @@ -3,7 +3,6 @@ namespace RelationalExample\Storage; use Illuminate\Database\Capsule\Manager as Capsule; -use League\OAuth2\Server\Entity\AbstractTokenEntity; use League\OAuth2\Server\Entity\AccessTokenEntity; use League\OAuth2\Server\Entity\ScopeEntity; use League\OAuth2\Server\Storage\AbstractStorage; @@ -28,7 +27,7 @@ class AccessTokenStorage extends AbstractStorage implements AccessTokenInterface return $token; } - return null; + return; } /** diff --git a/examples/relational/Storage/AuthCodeStorage.php b/examples/relational/Storage/AuthCodeStorage.php index 6a44a714..c0f84d9a 100644 --- a/examples/relational/Storage/AuthCodeStorage.php +++ b/examples/relational/Storage/AuthCodeStorage.php @@ -29,7 +29,7 @@ class AuthCodeStorage extends AbstractStorage implements AuthCodeInterface return $token; } - return null; + return; } public function create($token, $expireTime, $sessionId, $redirectUri) diff --git a/examples/relational/Storage/ClientStorage.php b/examples/relational/Storage/ClientStorage.php index 16987b9a..9d62263d 100644 --- a/examples/relational/Storage/ClientStorage.php +++ b/examples/relational/Storage/ClientStorage.php @@ -41,7 +41,7 @@ class ClientStorage extends AbstractStorage implements ClientInterface return $client; } - return null; + return; } /** @@ -65,6 +65,6 @@ class ClientStorage extends AbstractStorage implements ClientInterface return $client; } - return null; + return; } } diff --git a/examples/relational/Storage/RefreshTokenStorage.php b/examples/relational/Storage/RefreshTokenStorage.php index 148a1eb2..580efaf1 100644 --- a/examples/relational/Storage/RefreshTokenStorage.php +++ b/examples/relational/Storage/RefreshTokenStorage.php @@ -27,7 +27,7 @@ class RefreshTokenStorage extends AbstractStorage implements RefreshTokenInterfa return $token; } - return null; + return; } /** diff --git a/examples/relational/Storage/ScopeStorage.php b/examples/relational/Storage/ScopeStorage.php index 5f3bf614..4a6dd20e 100644 --- a/examples/relational/Storage/ScopeStorage.php +++ b/examples/relational/Storage/ScopeStorage.php @@ -19,7 +19,7 @@ class ScopeStorage extends AbstractStorage implements ScopeInterface ->get(); if (count($result) === 0) { - return null; + return; } return (new ScopeEntity($this->server))->hydrate([ diff --git a/examples/relational/Storage/SessionStorage.php b/examples/relational/Storage/SessionStorage.php index 28b538a9..612b1489 100644 --- a/examples/relational/Storage/SessionStorage.php +++ b/examples/relational/Storage/SessionStorage.php @@ -31,7 +31,7 @@ class SessionStorage extends AbstractStorage implements SessionInterface return $session; } - return null; + return; } /** @@ -53,7 +53,7 @@ class SessionStorage extends AbstractStorage implements SessionInterface return $session; } - return null; + return; } /** diff --git a/src/AbstractServer.php b/src/AbstractServer.php index d3b7e661..04c5d02f 100644 --- a/src/AbstractServer.php +++ b/src/AbstractServer.php @@ -36,48 +36,56 @@ abstract class AbstractServer /** * Session storage + * * @var \League\OAuth2\Server\Storage\SessionInterface */ protected $sessionStorage; /** * Access token storage + * * @var \League\OAuth2\Server\Storage\AccessTokenInterface */ protected $accessTokenStorage; /** * Refresh token storage + * * @var \League\OAuth2\Server\Storage\RefreshTokenInterface */ protected $refreshTokenStorage; /** * Auth code storage + * * @var \League\OAuth2\Server\Storage\AuthCodeInterface */ protected $authCodeStorage; /** * Scope storage + * * @var \League\OAuth2\Server\Storage\ScopeInterface */ protected $scopeStorage; /** * Client storage + * * @var \League\OAuth2\Server\Storage\ClientInterface */ protected $clientStorage; /** * Token type + * * @var \League\OAuth2\Server\TokenType\TokenTypeInterface */ protected $tokenType; /** * Event emitter + * * @var \League\Event\Emitter */ protected $eventEmitter; @@ -92,6 +100,7 @@ abstract class AbstractServer /** * Set an event emitter + * * @param object $emitter Event emitter object */ public function setEventEmitter($emitter = null) @@ -105,6 +114,7 @@ abstract class AbstractServer /** * Add an event listener to the event emitter + * * @param string $eventName Event name * @param callable $listener Callable function or method */ @@ -115,6 +125,7 @@ abstract class AbstractServer /** * Returns the event emitter + * * @return \League\Event\Emitter */ public function getEventEmitter() @@ -124,7 +135,9 @@ abstract class AbstractServer /** * Sets the Request Object + * * @param \Symfony\Component\HttpFoundation\Request The Request Object + * * @return self */ public function setRequest($request) @@ -136,6 +149,7 @@ abstract class AbstractServer /** * Gets the Request object. It will create one from the globals if one is not set. + * * @return \Symfony\Component\HttpFoundation\Request */ public function getRequest() @@ -149,7 +163,9 @@ abstract class AbstractServer /** * Set the client storage - * @param \League\OAuth2\Server\Storage\ClientInterface $storage + * + * @param \League\OAuth2\Server\Storage\ClientInterface $storage + * * @return self */ public function setClientStorage(ClientInterface $storage) @@ -162,7 +178,9 @@ abstract class AbstractServer /** * Set the session storage - * @param \League\OAuth2\Server\Storage\SessionInterface $storage + * + * @param \League\OAuth2\Server\Storage\SessionInterface $storage + * * @return self */ public function setSessionStorage(SessionInterface $storage) @@ -175,7 +193,9 @@ abstract class AbstractServer /** * Set the access token storage - * @param \League\OAuth2\Server\Storage\AccessTokenInterface $storage + * + * @param \League\OAuth2\Server\Storage\AccessTokenInterface $storage + * * @return self */ public function setAccessTokenStorage(AccessTokenInterface $storage) @@ -188,7 +208,9 @@ abstract class AbstractServer /** * Set the refresh token storage - * @param \League\OAuth2\Server\Storage\RefreshTokenInterface $storage + * + * @param \League\OAuth2\Server\Storage\RefreshTokenInterface $storage + * * @return self */ public function setRefreshTokenStorage(RefreshTokenInterface $storage) @@ -201,7 +223,9 @@ abstract class AbstractServer /** * Set the auth code storage - * @param \League\OAuth2\Server\Storage\AuthCodeInterface $storage + * + * @param \League\OAuth2\Server\Storage\AuthCodeInterface $storage + * * @return self */ public function setAuthCodeStorage(AuthCodeInterface $storage) @@ -214,7 +238,9 @@ abstract class AbstractServer /** * Set the scope storage - * @param \League\OAuth2\Server\Storage\ScopeInterface $storage + * + * @param \League\OAuth2\Server\Storage\ScopeInterface $storage + * * @return self */ public function setScopeStorage(ScopeInterface $storage) @@ -227,6 +253,7 @@ abstract class AbstractServer /** * Return the client storage + * * @return \League\OAuth2\Server\Storage\ClientInterface */ public function getClientStorage() @@ -236,6 +263,7 @@ abstract class AbstractServer /** * Return the scope storage + * * @return \League\OAuth2\Server\Storage\ScopeInterface */ public function getScopeStorage() @@ -245,6 +273,7 @@ abstract class AbstractServer /** * Return the session storage + * * @return \League\OAuth2\Server\Storage\SessionInterface */ public function getSessionStorage() @@ -254,6 +283,7 @@ abstract class AbstractServer /** * Return the refresh token storage + * * @return \League\OAuth2\Server\Storage\RefreshTokenInterface */ public function getRefreshTokenStorage() @@ -263,6 +293,7 @@ abstract class AbstractServer /** * Return the access token storage + * * @return \League\OAuth2\Server\Storage\AccessTokenInterface */ public function getAccessTokenStorage() @@ -272,6 +303,7 @@ abstract class AbstractServer /** * Return the auth code storage + * * @return \League\OAuth2\Server\Storage\AuthCodeInterface */ public function getAuthCodeStorage() @@ -281,7 +313,9 @@ abstract class AbstractServer /** * Set the access token type - * @param TokenTypeInterface $tokenType The token type + * + * @param TokenTypeInterface $tokenType The token type + * * @return void */ public function setTokenType(TokenTypeInterface $tokenType) @@ -292,6 +326,7 @@ abstract class AbstractServer /** * Get the access token type + * * @return TokenTypeInterface */ public function getTokenType() diff --git a/src/AuthorizationServer.php b/src/AuthorizationServer.php index 4f373938..8ad2351c 100644 --- a/src/AuthorizationServer.php +++ b/src/AuthorizationServer.php @@ -22,48 +22,56 @@ class AuthorizationServer extends AbstractServer /** * The delimeter between scopes specified in the scope query string parameter * The OAuth 2 specification states it should be a space but most use a comma + * * @var string */ protected $scopeDelimiter = ' '; /** * The TTL (time to live) of an access token in seconds (default: 3600) + * * @var integer */ protected $accessTokenTTL = 3600; /** * The registered grant response types + * * @var array */ protected $responseTypes = []; /** * The registered grant types + * * @var array */ protected $grantTypes = []; /** * Require the "scope" parameter to be in checkAuthoriseParams() + * * @var boolean */ protected $requireScopeParam = false; /** * Default scope(s) to be used if none is provided + * * @var string|array */ protected $defaultScope; /** * Require the "state" parameter to be in checkAuthoriseParams() + * * @var boolean */ protected $requireStateParam = false; /** * Create a new OAuth2 authorization server + * * @return self */ public function __construct() @@ -78,8 +86,10 @@ class AuthorizationServer extends AbstractServer /** * Enable support for a grant - * @param GrantTypeInterface $grantType A grant class which conforms to Interface/GrantTypeInterface - * @param null|string $identifier An identifier for the grant (autodetected if not passed) + * + * @param GrantTypeInterface $grantType A grant class which conforms to Interface/GrantTypeInterface + * @param null|string $identifier An identifier for the grant (autodetected if not passed) + * * @return self */ public function addGrantType(GrantTypeInterface $grantType, $identifier = null) @@ -102,7 +112,9 @@ class AuthorizationServer extends AbstractServer /** * Check if a grant type has been enabled - * @param string $identifier The grant type identifier + * + * @param string $identifier The grant type identifier + * * @return boolean Returns "true" if enabled, "false" if not */ public function hasGrantType($identifier) @@ -112,6 +124,7 @@ class AuthorizationServer extends AbstractServer /** * Returns response types + * * @return array */ public function getResponseTypes() @@ -121,7 +134,9 @@ class AuthorizationServer extends AbstractServer /** * Require the "scope" parameter in checkAuthoriseParams() - * @param boolean $require + * + * @param boolean $require + * * @return self */ public function requireScopeParam($require = true) @@ -133,6 +148,7 @@ class AuthorizationServer extends AbstractServer /** * Is the scope parameter required? + * * @return bool */ public function scopeParamRequired() @@ -142,7 +158,9 @@ class AuthorizationServer extends AbstractServer /** * Default scope to be used if none is provided and requireScopeParam() is false + * * @param string $default Name of the default scope + * * @return self */ public function setDefaultScope($default = null) @@ -154,6 +172,7 @@ class AuthorizationServer extends AbstractServer /** * Default scope to be used if none is provided and requireScopeParam is false + * * @return string|null */ public function getDefaultScope() @@ -163,6 +182,7 @@ class AuthorizationServer extends AbstractServer /** * Require the "state" paremter in checkAuthoriseParams() + * * @return bool */ public function stateParamRequired() @@ -172,7 +192,9 @@ class AuthorizationServer extends AbstractServer /** * Require the "state" paremter in checkAuthoriseParams() - * @param boolean $require + * + * @param boolean $require + * * @return self */ public function requireStateParam($require = true) @@ -184,6 +206,7 @@ class AuthorizationServer extends AbstractServer /** * Get the scope delimiter + * * @return string The scope delimiter (default: ",") */ public function getScopeDelimiter() @@ -193,7 +216,9 @@ class AuthorizationServer extends AbstractServer /** * Set the scope delimiter + * * @param string $scopeDelimiter + * * @return self */ public function setScopeDelimiter($scopeDelimiter = ' ') @@ -205,6 +230,7 @@ class AuthorizationServer extends AbstractServer /** * Get the TTL for an access token + * * @return int The TTL */ public function getAccessTokenTTL() @@ -214,7 +240,9 @@ class AuthorizationServer extends AbstractServer /** * Set the TTL for an access token + * * @param int $accessTokenTTL The new TTL + * * @return self */ public function setAccessTokenTTL($accessTokenTTL = 3600) @@ -226,7 +254,9 @@ class AuthorizationServer extends AbstractServer /** * Issue an access token + * * @return array Authorise request parameters + * * @throws */ public function issueAccessToken() @@ -247,8 +277,11 @@ class AuthorizationServer extends AbstractServer /** * Return a grant type class - * @param string $grantType The grant type identifier + * + * @param string $grantType The grant type identifier + * * @return Grant\GrantTypeInterface + * * @throws */ public function getGrantType($grantType) diff --git a/src/Entity/AbstractTokenEntity.php b/src/Entity/AbstractTokenEntity.php index 95405707..5f0465c3 100644 --- a/src/Entity/AbstractTokenEntity.php +++ b/src/Entity/AbstractTokenEntity.php @@ -21,37 +21,44 @@ abstract class AbstractTokenEntity { /** * Token identifier + * * @var string */ protected $id; /** * Associated session + * * @var \League\OAuth2\Server\Entity\SessionEntity */ protected $session; /** * Session scopes + * * @var \League\OAuth2\Server\Entity\ScopeEntity[] */ protected $scopes; /** * Token expire time + * * @var int */ protected $expireTime = 0; /** * Authorization or resource server + * * @var \League\OAuth2\Server\AbstractServer */ protected $server; /** * __construct - * @param \League\OAuth2\Server\AbstractServer $server + * + * @param \League\OAuth2\Server\AbstractServer $server + * * @return self */ public function __construct(AbstractServer $server) @@ -63,7 +70,9 @@ abstract class AbstractTokenEntity /** * Set session - * @param \League\OAuth2\Server\Entity\SessionEntity $session + * + * @param \League\OAuth2\Server\Entity\SessionEntity $session + * * @return self */ public function setSession(SessionEntity $session) @@ -75,7 +84,9 @@ abstract class AbstractTokenEntity /** * Set the expire time of the token - * @param integer $expireTime Unix time stamp + * + * @param integer $expireTime Unix time stamp + * * @return self */ public function setExpireTime($expireTime) @@ -87,6 +98,7 @@ abstract class AbstractTokenEntity /** * Return token expire time + * * @return int */ public function getExpireTime() @@ -96,6 +108,7 @@ abstract class AbstractTokenEntity /** * Is the token expired? + * * @return bool */ public function isExpired() @@ -105,7 +118,9 @@ abstract class AbstractTokenEntity /** * Set token ID - * @param string $id Token ID + * + * @param string $id Token ID + * * @return self */ public function setId($id = null) @@ -117,6 +132,7 @@ abstract class AbstractTokenEntity /** * Get the token ID + * * @return string */ public function getId() @@ -126,7 +142,9 @@ abstract class AbstractTokenEntity /** * Associate a scope - * @param \League\OAuth2\Server\Entity\ScopeEntity $scope + * + * @param \League\OAuth2\Server\Entity\ScopeEntity $scope + * * @return self */ public function associateScope(ScopeEntity $scope) @@ -140,7 +158,9 @@ abstract class AbstractTokenEntity /** * Format the local scopes array + * * @param \League\OAuth2\Server\Entity\ScopeEntity[] + * * @return array */ protected function formatScopes($unformatted = []) @@ -161,6 +181,7 @@ abstract class AbstractTokenEntity /** * Returns the token as a string if the object is cast as a string + * * @return string */ public function __toString() @@ -174,12 +195,14 @@ abstract class AbstractTokenEntity /** * Expire the token + * * @return void */ abstract public function expire(); /** * Save the token + * * @return void */ abstract public function save(); diff --git a/src/Entity/AccessTokenEntity.php b/src/Entity/AccessTokenEntity.php index 12208687..7342b498 100644 --- a/src/Entity/AccessTokenEntity.php +++ b/src/Entity/AccessTokenEntity.php @@ -18,6 +18,7 @@ class AccessTokenEntity extends AbstractTokenEntity { /** * Get session + * * @return \League\OAuth2\Server\Entity\SessionEntity */ public function getSession() @@ -33,7 +34,9 @@ class AccessTokenEntity extends AbstractTokenEntity /** * Check if access token has an associated scope - * @param string $scope Scope to check + * + * @param string $scope Scope to check + * * @return bool */ public function hasScope($scope) @@ -47,6 +50,7 @@ class AccessTokenEntity extends AbstractTokenEntity /** * Return all scopes associated with the access token + * * @return \League\OAuth2\Server\Entity\ScopeEntity[] */ public function getScopes() diff --git a/src/Entity/AuthCodeEntity.php b/src/Entity/AuthCodeEntity.php index 954e22ff..ae106f7f 100644 --- a/src/Entity/AuthCodeEntity.php +++ b/src/Entity/AuthCodeEntity.php @@ -18,13 +18,16 @@ class AuthCodeEntity extends AbstractTokenEntity { /** * Redirect URI + * * @var string */ protected $redirectUri = ''; /** * Set the redirect URI for the authorization request - * @param string $redirectUri + * + * @param string $redirectUri + * * @return self */ public function setRedirectUri($redirectUri) @@ -36,6 +39,7 @@ class AuthCodeEntity extends AbstractTokenEntity /** * Get the redirect URI + * * @return string */ public function getRedirectUri() @@ -45,8 +49,10 @@ class AuthCodeEntity extends AbstractTokenEntity /** * 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) + * + * @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 */ public function generateRedirectUri($state = null, $queryDelimeter = '?') @@ -62,6 +68,7 @@ class AuthCodeEntity extends AbstractTokenEntity /** * Get session + * * @return \League\OAuth2\Server\Entity\SessionEntity */ public function getSession() @@ -77,6 +84,7 @@ class AuthCodeEntity extends AbstractTokenEntity /** * Return all scopes associated with the session + * * @return \League\OAuth2\Server\Entity\ScopeEntity[] */ public function getScopes() diff --git a/src/Entity/ClientEntity.php b/src/Entity/ClientEntity.php index 34a3320a..b0e95285 100644 --- a/src/Entity/ClientEntity.php +++ b/src/Entity/ClientEntity.php @@ -22,37 +22,44 @@ class ClientEntity /** * Client identifier + * * @var string */ protected $id = null; /** * Client secret + * * @var string */ protected $secret = null; /** * Client name + * * @var string */ protected $name = null; /** * Client redirect URI + * * @var string */ protected $redirectUri = null; /** * Authorization or resource server + * * @var \League\OAuth2\Server\AbstractServer */ protected $server; /** * __construct - * @param \League\OAuth2\Server\AbstractServer $server + * + * @param \League\OAuth2\Server\AbstractServer $server + * * @return self */ public function __construct(AbstractServer $server) @@ -64,6 +71,7 @@ class ClientEntity /** * Return the client identifier + * * @return string */ public function getId() @@ -73,6 +81,7 @@ class ClientEntity /** * Return the client secret + * * @return string */ public function getSecret() @@ -82,6 +91,7 @@ class ClientEntity /** * Get the client name + * * @return string */ public function getName() @@ -91,6 +101,7 @@ class ClientEntity /** * Returnt the client redirect URI + * * @return string */ public function getRedirectUri() diff --git a/src/Entity/EntityTrait.php b/src/Entity/EntityTrait.php index 354745ff..9424fdfd 100644 --- a/src/Entity/EntityTrait.php +++ b/src/Entity/EntityTrait.php @@ -15,7 +15,9 @@ trait EntityTrait { /** * Hydrate an entity with properites + * * @param array $properties + * * @return self */ public function hydrate(array $properties) diff --git a/src/Entity/RefreshTokenEntity.php b/src/Entity/RefreshTokenEntity.php index 143c93c5..f1ec89a5 100644 --- a/src/Entity/RefreshTokenEntity.php +++ b/src/Entity/RefreshTokenEntity.php @@ -18,19 +18,23 @@ class RefreshTokenEntity extends AbstractTokenEntity { /** * Access token associated to refresh token + * * @var \League\OAuth2\Server\Entity\AccessTokenEntity */ protected $accessTokenEntity; /** * Id of the access token + * * @var string */ protected $accessTokenId; /** * Set the ID of the associated access token - * @param string $accessTokenId + * + * @param string $accessTokenId + * * @return self */ public function setAccessTokenId($accessTokenId) @@ -42,7 +46,9 @@ class RefreshTokenEntity extends AbstractTokenEntity /** * Associate an access token - * @param \League\OAuth2\Server\Entity\AccessTokenEntity $accessTokenEntity + * + * @param \League\OAuth2\Server\Entity\AccessTokenEntity $accessTokenEntity + * * @return self */ public function setAccessToken(AccessTokenEntity $accessTokenEntity) @@ -54,6 +60,7 @@ class RefreshTokenEntity extends AbstractTokenEntity /** * Return access token + * * @return AccessTokenEntity */ public function getAccessToken() diff --git a/src/Entity/ScopeEntity.php b/src/Entity/ScopeEntity.php index 4b4ed673..1d5c946f 100644 --- a/src/Entity/ScopeEntity.php +++ b/src/Entity/ScopeEntity.php @@ -22,25 +22,30 @@ class ScopeEntity implements \JsonSerializable /** * Scope identifier + * * @var string */ protected $id; /** * Scope description + * * @var string */ protected $description; /** * Authorization or resource server + * * @var \League\OAuth2\Server\AbstractServer */ protected $server; /** * __construct - * @param \League\OAuth2\Server\AbstractServer $server + * + * @param \League\OAuth2\Server\AbstractServer $server + * * @return self */ public function __construct(AbstractServer $server) @@ -52,6 +57,7 @@ class ScopeEntity implements \JsonSerializable /** * Return the scope identifer + * * @return string */ public function getId() @@ -61,6 +67,7 @@ class ScopeEntity implements \JsonSerializable /** * Return the scope's description + * * @return string */ public function getDescription() @@ -70,6 +77,7 @@ class ScopeEntity implements \JsonSerializable /** * Returns a JSON object when entity is passed into json_encode + * * @return array */ public function jsonSerialize() diff --git a/src/Entity/SessionEntity.php b/src/Entity/SessionEntity.php index 399bd6fb..c78cead5 100644 --- a/src/Entity/SessionEntity.php +++ b/src/Entity/SessionEntity.php @@ -21,61 +21,72 @@ class SessionEntity { /** * Session identifier + * * @var string */ protected $id; /** * Client identifier + * * @var \League\OAuth2\Server\Entity\ClientEntity */ protected $client; /** * Session owner identifier + * * @var string */ protected $ownerId; /** * Session owner type (e.g. "user") + * * @var string */ protected $ownerType; /** * Auth code + * * @var \League\OAuth2\Server\Entity\AuthCodeEntity */ protected $authCode; /** * Access token + * * @var \League\OAuth2\Server\Entity\AccessTokenEntity */ protected $accessToken; /** * Refresh token + * * @var \League\OAuth2\Server\Entity\RefreshTokenEntity */ protected $refreshToken; /** * Session scopes + * * @var \Symfony\Component\HttpFoundation\ParameterBag */ protected $scopes; /** * Authorization or resource server + * * @var \League\OAuth2\Server\AuthorizationServer|\League\OAuth2\Server\ResourceServer */ protected $server; /** * __construct - * @param \League\OAuth2\Server\AbstractServer $server + * + * @param \League\OAuth2\Server\AbstractServer $server + * * @return self */ public function __construct(AbstractServer $server) @@ -87,7 +98,9 @@ class SessionEntity /** * Set the session identifier - * @param string $id + * + * @param string $id + * * @return self */ public function setId($id) @@ -99,6 +112,7 @@ class SessionEntity /** * Return the session identifier + * * @return string */ public function getId() @@ -108,7 +122,9 @@ class SessionEntity /** * Associate a scope - * @param \League\OAuth2\Server\Entity\ScopeEntity $scope + * + * @param \League\OAuth2\Server\Entity\ScopeEntity $scope + * * @return self */ public function associateScope(ScopeEntity $scope) @@ -122,7 +138,9 @@ class SessionEntity /** * Check if access token has an associated scope - * @param string $scope Scope to check + * + * @param string $scope Scope to check + * * @return bool */ public function hasScope($scope) @@ -136,6 +154,7 @@ class SessionEntity /** * Return all scopes associated with the session + * * @return \League\OAuth2\Server\Entity\ScopeEntity[] */ public function getScopes() @@ -149,7 +168,9 @@ class SessionEntity /** * Format the local scopes array + * * @param \League\OAuth2\Server\Entity\Scope[] + * * @return array */ private function formatScopes($unformatted = []) @@ -168,7 +189,9 @@ class SessionEntity /** * Associate an access token with the session - * @param \League\OAuth2\Server\Entity\AccessTokenEntity $accessToken + * + * @param \League\OAuth2\Server\Entity\AccessTokenEntity $accessToken + * * @return self */ public function associateAccessToken(AccessTokenEntity $accessToken) @@ -180,7 +203,9 @@ class SessionEntity /** * Associate a refresh token with the session - * @param \League\OAuth2\Server\Entity\RefreshTokenEntity $refreshToken + * + * @param \League\OAuth2\Server\Entity\RefreshTokenEntity $refreshToken + * * @return self */ public function associateRefreshToken(RefreshTokenEntity $refreshToken) @@ -192,7 +217,9 @@ class SessionEntity /** * Associate a client with the session - * @param \League\OAuth2\Server\Entity\ClientEntity $client The client + * + * @param \League\OAuth2\Server\Entity\ClientEntity $client The client + * * @return self */ public function associateClient(ClientEntity $client) @@ -204,6 +231,7 @@ class SessionEntity /** * Return the session client + * * @return \League\OAuth2\Server\Entity\ClientEntity */ public function getClient() @@ -219,8 +247,10 @@ class SessionEntity /** * Set the session owner - * @param string $type The type of the owner (e.g. user, app) - * @param string $id The identifier of the owner + * + * @param string $type The type of the owner (e.g. user, app) + * @param string $id The identifier of the owner + * * @return self */ public function setOwner($type, $id) @@ -235,6 +265,7 @@ class SessionEntity /** * Return session owner identifier + * * @return string */ public function getOwnerId() @@ -244,6 +275,7 @@ class SessionEntity /** * Return session owner type + * * @return string */ public function getOwnerType() @@ -253,6 +285,7 @@ class SessionEntity /** * Save the session + * * @return void */ public function save() diff --git a/src/Event/ClientAuthenticationFailedEvent.php b/src/Event/ClientAuthenticationFailedEvent.php index 917dd68d..4448bb4e 100644 --- a/src/Event/ClientAuthenticationFailedEvent.php +++ b/src/Event/ClientAuthenticationFailedEvent.php @@ -18,12 +18,14 @@ class ClientAuthenticationFailedEvent extends AbstractEvent { /** * Request + * * @var \Symfony\Component\HttpFoundation\Request */ private $request; /** * Init the event with a request + * * @param \Symfony\Component\HttpFoundation\Request $request */ public function __construct(Request $request) @@ -33,6 +35,7 @@ class ClientAuthenticationFailedEvent extends AbstractEvent /** * The name of the event + * * @return string */ public function getName() @@ -42,6 +45,7 @@ class ClientAuthenticationFailedEvent extends AbstractEvent /** * Return request + * * @return \Symfony\Component\HttpFoundation\Request */ public function getRequest() diff --git a/src/Event/SessionOwnerEvent.php b/src/Event/SessionOwnerEvent.php index 621d0a83..83c4e766 100644 --- a/src/Event/SessionOwnerEvent.php +++ b/src/Event/SessionOwnerEvent.php @@ -18,12 +18,14 @@ class SessionOwnerEvent extends AbstractEvent { /** * Session entity + * * @var \League\OAuth2\Server\Entity\SessionEntity */ private $session; /** * Init the event with a session + * * @param \League\OAuth2\Server\Entity\SessionEntity $session */ public function __construct(SessionEntity $session) @@ -33,6 +35,7 @@ class SessionOwnerEvent extends AbstractEvent /** * The name of the event + * * @return string */ public function getName() @@ -42,6 +45,7 @@ class SessionOwnerEvent extends AbstractEvent /** * Return session + * * @return \League\OAuth2\Server\Entity\SessionEntity */ public function getSession() diff --git a/src/Event/UserAuthenticationFailedEvent.php b/src/Event/UserAuthenticationFailedEvent.php index ae011411..4cd8c4cd 100644 --- a/src/Event/UserAuthenticationFailedEvent.php +++ b/src/Event/UserAuthenticationFailedEvent.php @@ -18,12 +18,14 @@ class UserAuthenticationFailedEvent extends AbstractEvent { /** * Request + * * @var \Symfony\Component\HttpFoundation\Request */ private $request; /** * Init the event with a request + * * @param \Symfony\Component\HttpFoundation\Request $request */ public function __construct(Request $request) @@ -33,6 +35,7 @@ class UserAuthenticationFailedEvent extends AbstractEvent /** * The name of the event + * * @return string */ public function getName() @@ -42,6 +45,7 @@ class UserAuthenticationFailedEvent extends AbstractEvent /** * Return request + * * @return \Symfony\Component\HttpFoundation\Request */ public function getRequest() diff --git a/src/Exception/OAuthException.php b/src/Exception/OAuthException.php index 1242ec04..e8e5e723 100644 --- a/src/Exception/OAuthException.php +++ b/src/Exception/OAuthException.php @@ -26,6 +26,7 @@ class OAuthException extends \Exception /** * Redirect URI if the server should redirect back to the client + * * @var string|null */ public $redirectUri = null; @@ -37,6 +38,7 @@ class OAuthException extends \Exception /** * Throw a new exception + * * @param string $msg Exception Message */ public function __construct($msg = 'An error occured') @@ -46,6 +48,7 @@ class OAuthException extends \Exception /** * Should the server redirect back to the client? + * * @return bool */ public function shouldRedirect() @@ -55,6 +58,7 @@ class OAuthException extends \Exception /** * Return redirect URI if set + * * @return string|null */ public function getRedirectUri() @@ -70,6 +74,7 @@ class OAuthException extends \Exception /** * Get all headers that have to be send with the error response + * * @return array Array with header values */ public function getHttpHeaders() diff --git a/src/Grant/AbstractGrant.php b/src/Grant/AbstractGrant.php index 2ea5fd58..fd5cb52f 100644 --- a/src/Grant/AbstractGrant.php +++ b/src/Grant/AbstractGrant.php @@ -23,30 +23,35 @@ abstract class AbstractGrant implements GrantTypeInterface { /** * Grant identifier + * * @var string */ protected $identifier = ''; /** * Response type + * * @var string */ protected $responseType; /** * Callback to authenticate a user's name and password + * * @var callable */ protected $callback; /** * AuthServer instance + * * @var \League\OAuth2\Server\AuthorizationServer */ protected $server; /** * Access token expires in override + * * @var int */ protected $accessTokenTTL; @@ -79,6 +84,7 @@ abstract class AbstractGrant implements GrantTypeInterface /** * Get the TTL for an access token + * * @return int The TTL */ public function getAccessTokenTTL() @@ -92,7 +98,9 @@ abstract class AbstractGrant implements GrantTypeInterface /** * Override the default access token expire time - * @param int $accessTokenTTL + * + * @param int $accessTokenTTL + * * @return self */ public function setAccessTokenTTL($accessTokenTTL) @@ -114,10 +122,13 @@ abstract class AbstractGrant implements GrantTypeInterface /** * Given a list of scopes, validate them and return an array of Scope entities - * @param string $scopeParam A string of scopes (e.g. "profile email birthday") - * @param \League\OAuth2\Server\Entity\ClientEntity $client Client entity - * @param string|null $redirectUri The redirect URI to return the user to + * + * @param string $scopeParam A string of scopes (e.g. "profile email birthday") + * @param \League\OAuth2\Server\Entity\ClientEntity $client Client entity + * @param string|null $redirectUri The redirect URI to return the user to + * * @return \League\OAuth2\Server\Entity\ScopeEntity[] + * * @throws \League\OAuth2\Server\Exception\InvalidScopeException If scope is invalid, or no scopes passed when required * @throws */ @@ -167,7 +178,9 @@ abstract class AbstractGrant implements GrantTypeInterface /** * Format the local scopes array + * * @param \League\OAuth2\Server\Entity\ScopeEntity[] + * * @return array */ protected function formatScopes($unformated = []) diff --git a/src/Grant/AuthCodeGrant.php b/src/Grant/AuthCodeGrant.php index 3773c083..a248dc16 100644 --- a/src/Grant/AuthCodeGrant.php +++ b/src/Grant/AuthCodeGrant.php @@ -27,37 +27,44 @@ class AuthCodeGrant extends AbstractGrant { /** * Grant identifier + * * @var string */ protected $identifier = 'authorization_code'; /** * Response type + * * @var string */ protected $responseType = 'code'; /** * AuthServer instance + * * @var \League\OAuth2\Server\AuthorizationServer */ protected $server = null; /** * Access token expires in override + * * @var int */ protected $accessTokenTTL = null; /** * The TTL of the auth token + * * @var integer */ protected $authTokenTTL = 600; /** * Override the default access token expire time - * @param int $authTokenTTL + * + * @param int $authTokenTTL + * * @return void */ public function setAuthTokenTTL($authTokenTTL) @@ -129,9 +136,10 @@ class AuthCodeGrant extends AbstractGrant /** * Parse a new authorize request * - * @param string $type The session owner's type - * @param string $typeId The session owner's ID - * @param array $authParams The authorize request $_GET parameters + * @param string $type The session owner's type + * @param string $typeId The session owner's ID + * @param array $authParams The authorize request $_GET parameters + * * @return string An authorisation code */ public function newAuthorizeRequest($type, $typeId, $authParams = []) @@ -160,7 +168,9 @@ class AuthCodeGrant extends AbstractGrant /** * Complete the auth code grant + * * @return array + * * @throws */ public function completeFlow() diff --git a/src/Grant/ClientCredentialsGrant.php b/src/Grant/ClientCredentialsGrant.php index 21669d9b..e219c633 100644 --- a/src/Grant/ClientCredentialsGrant.php +++ b/src/Grant/ClientCredentialsGrant.php @@ -25,31 +25,37 @@ class ClientCredentialsGrant extends AbstractGrant { /** * Grant identifier + * * @var string */ protected $identifier = 'client_credentials'; /** * Response type + * * @var string */ protected $responseType = null; /** * AuthServer instance + * * @var \League\OAuth2\Server\AuthorizationServer */ protected $server = null; /** * Access token expires in override + * * @var int */ protected $accessTokenTTL = null; /** * Complete the client credentials grant + * * @return array + * * @throws */ public function completeFlow() diff --git a/src/Grant/GrantTypeInterface.php b/src/Grant/GrantTypeInterface.php index 77ada2c7..a9468655 100644 --- a/src/Grant/GrantTypeInterface.php +++ b/src/Grant/GrantTypeInterface.php @@ -20,32 +20,39 @@ interface GrantTypeInterface { /** * Return the identifier + * * @return string */ public function getIdentifier(); /** * Return the identifier - * @param string $identifier + * + * @param string $identifier + * * @return self */ public function setIdentifier($identifier); /** * Return the response type + * * @return string */ public function getResponseType(); /** * Inject the authorization server into the grant - * @param \League\OAuth2\Server\AuthorizationServer $server The authorization server instance + * + * @param \League\OAuth2\Server\AuthorizationServer $server The authorization server instance + * * @return self */ public function setAuthorizationServer(AuthorizationServer $server); /** * Complete the grant flow + * * @return array */ public function completeFlow(); diff --git a/src/Grant/PasswordGrant.php b/src/Grant/PasswordGrant.php index e545f5ec..71921085 100644 --- a/src/Grant/PasswordGrant.php +++ b/src/Grant/PasswordGrant.php @@ -26,31 +26,37 @@ class PasswordGrant extends AbstractGrant { /** * Grant identifier + * * @var string */ protected $identifier = 'password'; /** * Response type + * * @var string */ protected $responseType; /** * Callback to authenticate a user's name and password + * * @var callable */ protected $callback; /** * Access token expires in override + * * @var int */ protected $accessTokenTTL; /** * Set the callback to verify a user's username and password - * @param callable $callback The callback function + * + * @param callable $callback The callback function + * * @return void */ public function setVerifyCredentialsCallback(callable $callback) @@ -60,7 +66,9 @@ class PasswordGrant extends AbstractGrant /** * Return the callback function + * * @return callable + * * @throws */ protected function getVerifyCredentialsCallback() @@ -74,7 +82,9 @@ class PasswordGrant extends AbstractGrant /** * Complete the password grant + * * @return array + * * @throws */ public function completeFlow() diff --git a/src/Grant/RefreshTokenGrant.php b/src/Grant/RefreshTokenGrant.php index 3350bf9d..2d1b4ce5 100644 --- a/src/Grant/RefreshTokenGrant.php +++ b/src/Grant/RefreshTokenGrant.php @@ -30,13 +30,16 @@ class RefreshTokenGrant extends AbstractGrant /** * Refresh token TTL (default = 604800 | 1 week) + * * @var integer */ protected $refreshTokenTTL = 604800; /** * Set the TTL of the refresh token - * @param int $refreshTokenTTL + * + * @param int $refreshTokenTTL + * * @return void */ public function setRefreshTokenTTL($refreshTokenTTL) @@ -46,6 +49,7 @@ class RefreshTokenGrant extends AbstractGrant /** * Get the TTL of the refresh token + * * @return int */ public function getRefreshTokenTTL() diff --git a/src/ResourceServer.php b/src/ResourceServer.php index ded35cbc..fc607510 100644 --- a/src/ResourceServer.php +++ b/src/ResourceServer.php @@ -25,22 +25,26 @@ class ResourceServer extends AbstractServer { /** * The access token + * * @var \League\OAuth2\Server\Entity\AccessTokenEntity */ protected $accessToken; /** * The query string key which is used by clients to present the access token (default: access_token) + * * @var string */ protected $tokenKey = 'access_token'; /** * Initialise the resource server - * @param SessionInterface $sessionStorage - * @param AccessTokenInterface $accessTokenStorage - * @param ClientInterface $clientStorage - * @param ScopeInterface $scopeStorage + * + * @param SessionInterface $sessionStorage + * @param AccessTokenInterface $accessTokenStorage + * @param ClientInterface $clientStorage + * @param ScopeInterface $scopeStorage + * * @return self */ public function __construct( @@ -64,7 +68,9 @@ class ResourceServer extends AbstractServer /** * Sets the query string key for the access token. + * * @param string $key The new query string key + * * @return self */ public function setIdKey($key) @@ -76,6 +82,7 @@ class ResourceServer extends AbstractServer /** * Gets the access token + * * @return \League\OAuth2\Server\Entity\AccessTokenEntity */ public function getAccessToken() @@ -85,7 +92,8 @@ class ResourceServer extends AbstractServer /** * Checks if the access token is valid or not - * @param bool $headersOnly Limit Access Token to Authorization header only + * + * @param bool $headersOnly Limit Access Token to Authorization header only * @param AccessTokenEntity|null $accessToken Access Token * * @return bool @@ -117,8 +125,11 @@ class ResourceServer extends AbstractServer /** * Reads in the access token from the headers + * * @param bool $headersOnly Limit Access Token to Authorization header only + * * @throws Exception\InvalidRequestException Thrown if there is no access token presented + * * @return string */ public function determineAccessToken($headersOnly = false) diff --git a/src/Storage/AbstractStorage.php b/src/Storage/AbstractStorage.php index 41dc88a6..2bfb5601 100644 --- a/src/Storage/AbstractStorage.php +++ b/src/Storage/AbstractStorage.php @@ -20,13 +20,16 @@ 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) @@ -38,6 +41,7 @@ abstract class AbstractStorage implements StorageInterface /** * Return the server + * * @return \League\OAuth2\Server\AbstractServer */ protected function getServer() diff --git a/src/Storage/AccessTokenInterface.php b/src/Storage/AccessTokenInterface.php index 0287c2d1..5f852b80 100644 --- a/src/Storage/AccessTokenInterface.php +++ b/src/Storage/AccessTokenInterface.php @@ -21,38 +21,48 @@ interface AccessTokenInterface extends StorageInterface { /** * Get an instance of Entity\AccessTokenEntity - * @param string $token The access token + * + * @param string $token The access token + * * @return \League\OAuth2\Server\Entity\AccessTokenEntity */ public function get($token); /** * Get the scopes for an access token - * @param \League\OAuth2\Server\Entity\AccessTokenEntity $token The access token - * @return array Array of \League\OAuth2\Server\Entity\ScopeEntity + * + * @param \League\OAuth2\Server\Entity\AccessTokenEntity $token The access token + * + * @return array Array of \League\OAuth2\Server\Entity\ScopeEntity */ public function getScopes(AccessTokenEntity $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 + * + * @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 */ public function create($token, $expireTime, $sessionId); /** * Associate a scope with an acess token - * @param \League\OAuth2\Server\Entity\AccessTokenEntity $token The access token - * @param \League\OAuth2\Server\Entity\ScopeEntity $scope The scope + * + * @param \League\OAuth2\Server\Entity\AccessTokenEntity $token The access token + * @param \League\OAuth2\Server\Entity\ScopeEntity $scope The scope + * * @return void */ public function associateScope(AccessTokenEntity $token, ScopeEntity $scope); /** * Delete an access token - * @param \League\OAuth2\Server\Entity\AccessTokenEntity $token The access token to delete + * + * @param \League\OAuth2\Server\Entity\AccessTokenEntity $token The access token to delete + * * @return void */ public function delete(AccessTokenEntity $token); diff --git a/src/Storage/AuthCodeInterface.php b/src/Storage/AuthCodeInterface.php index c066d809..1fe0f8b9 100644 --- a/src/Storage/AuthCodeInterface.php +++ b/src/Storage/AuthCodeInterface.php @@ -21,39 +21,49 @@ interface AuthCodeInterface extends StorageInterface { /** * Get the auth code - * @param string $code + * + * @param string $code + * * @return \League\OAuth2\Server\Entity\AuthCodeEntity */ public function get($code); /** * Create an auth code. + * * @param string $token The token ID * @param integer $expireTime Token expire time * @param integer $sessionId Session identifier * @param string $redirectUri Client redirect uri + * * @return void */ public function create($token, $expireTime, $sessionId, $redirectUri); /** * Get the scopes for an access token - * @param \League\OAuth2\Server\Entity\AuthCodeEntity $token The auth code - * @return array Array of \League\OAuth2\Server\Entity\ScopeEntity + * + * @param \League\OAuth2\Server\Entity\AuthCodeEntity $token The auth code + * + * @return array Array of \League\OAuth2\Server\Entity\ScopeEntity */ public function getScopes(AuthCodeEntity $token); /** * Associate a scope with an acess token - * @param \League\OAuth2\Server\Entity\AuthCodeEntity $token The auth code - * @param \League\OAuth2\Server\Entity\ScopeEntity $scope The scope + * + * @param \League\OAuth2\Server\Entity\AuthCodeEntity $token The auth code + * @param \League\OAuth2\Server\Entity\ScopeEntity $scope The scope + * * @return void */ public function associateScope(AuthCodeEntity $token, ScopeEntity $scope); /** * Delete an access token - * @param \League\OAuth2\Server\Entity\AuthCodeEntity $token The access token to delete + * + * @param \League\OAuth2\Server\Entity\AuthCodeEntity $token The access token to delete + * * @return void */ public function delete(AuthCodeEntity $token); diff --git a/src/Storage/ClientInterface.php b/src/Storage/ClientInterface.php index 4da715dc..4e9cc39a 100644 --- a/src/Storage/ClientInterface.php +++ b/src/Storage/ClientInterface.php @@ -20,17 +20,21 @@ 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") + * + * @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 + * + * @param \League\OAuth2\Server\Entity\SessionEntity $session The session + * * @return \League\OAuth2\Server\Entity\ClientEntity */ public function getBySession(SessionEntity $session); diff --git a/src/Storage/RefreshTokenInterface.php b/src/Storage/RefreshTokenInterface.php index 5be23d1c..bf65468c 100644 --- a/src/Storage/RefreshTokenInterface.php +++ b/src/Storage/RefreshTokenInterface.php @@ -20,23 +20,29 @@ interface RefreshTokenInterface extends StorageInterface { /** * Return a new instance of \League\OAuth2\Server\Entity\RefreshTokenEntity - * @param string $token + * + * @param string $token + * * @return \League\OAuth2\Server\Entity\RefreshTokenEntity */ public function get($token); /** * Create a new refresh token_name - * @param string $token - * @param integer $expireTime - * @param string $accessToken + * + * @param string $token + * @param integer $expireTime + * @param string $accessToken + * * @return \League\OAuth2\Server\Entity\RefreshTokenEntity */ public function create($token, $expireTime, $accessToken); /** * Delete the refresh token - * @param \League\OAuth2\Server\Entity\RefreshTokenEntity $token + * + * @param \League\OAuth2\Server\Entity\RefreshTokenEntity $token + * * @return void */ public function delete(RefreshTokenEntity $token); diff --git a/src/Storage/ScopeInterface.php b/src/Storage/ScopeInterface.php index 95ff8aac..e8bc10b0 100644 --- a/src/Storage/ScopeInterface.php +++ b/src/Storage/ScopeInterface.php @@ -18,9 +18,11 @@ 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") + * + * @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/Storage/SessionInterface.php b/src/Storage/SessionInterface.php index 130a3ce4..ab205180 100644 --- a/src/Storage/SessionInterface.php +++ b/src/Storage/SessionInterface.php @@ -23,39 +23,49 @@ interface SessionInterface extends StorageInterface { /** * Get a session from an access token - * @param \League\OAuth2\Server\Entity\AccessTokenEntity $accessToken The 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 + * + * @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) + * + * @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 + * + * @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/Storage/StorageInterface.php b/src/Storage/StorageInterface.php index e1c7b83d..ff9614b5 100644 --- a/src/Storage/StorageInterface.php +++ b/src/Storage/StorageInterface.php @@ -20,6 +20,7 @@ interface StorageInterface { /** * Set the server + * * @param \League\OAuth2\Server\AbstractServer $server */ public function setServer(AbstractServer $server); diff --git a/src/TokenType/AbstractTokenType.php b/src/TokenType/AbstractTokenType.php index a89997cf..adb8837b 100644 --- a/src/TokenType/AbstractTokenType.php +++ b/src/TokenType/AbstractTokenType.php @@ -18,18 +18,21 @@ abstract class AbstractTokenType { /** * Response array + * * @var array */ protected $response = []; /** * Server + * * @var \League\OAuth2\Server\AbstractServer $server */ protected $server; /** * Server + * * @var \League\OAuth2\Server\Entity\SessionEntity $session */ protected $session; diff --git a/src/TokenType/TokenTypeInterface.php b/src/TokenType/TokenTypeInterface.php index 1757a07b..17c2c1cf 100644 --- a/src/TokenType/TokenTypeInterface.php +++ b/src/TokenType/TokenTypeInterface.php @@ -19,19 +19,23 @@ interface TokenTypeInterface { /** * Generate a response + * * @return array */ public function generateResponse(); /** * Set the server + * * @param \League\OAuth2\Server\AbstractServer $server + * * @return self */ public function setServer(AbstractServer $server); /** * Set a key/value response pair + * * @param string $key * @param mixed $value */ @@ -39,20 +43,25 @@ interface TokenTypeInterface /** * Get a key from the response array - * @param string $key + * + * @param string $key + * * @return mixed */ public function getParam($key); /** * @param \League\OAuth2\Server\Entity\SessionEntity $session + * * @return self */ public function setSession(SessionEntity $session); /** * Determine the access token in the authorization header - * @param \Symfony\Component\HttpFoundation\Request $request + * + * @param \Symfony\Component\HttpFoundation\Request $request + * * @return string */ public function determineAccessTokenInHeader(Request $request); diff --git a/src/Util/KeyAlgorithm/DefaultAlgorithm.php b/src/Util/KeyAlgorithm/DefaultAlgorithm.php index 14cc5273..70fecb14 100644 --- a/src/Util/KeyAlgorithm/DefaultAlgorithm.php +++ b/src/Util/KeyAlgorithm/DefaultAlgorithm.php @@ -21,7 +21,7 @@ class DefaultAlgorithm implements KeyAlgorithmInterface $stripped = ''; do { $bytes = openssl_random_pseudo_bytes($len, $strong); - + // We want to stop execution if the key fails because, well, that is bad. if ($bytes === false || $strong === false) { // @codeCoverageIgnoreStart @@ -30,6 +30,7 @@ class DefaultAlgorithm implements KeyAlgorithmInterface } $stripped .= str_replace(['/', '+', '='], '', base64_encode($bytes)); } while (strlen($stripped) < $len); + return substr($stripped, 0, $len); } } diff --git a/src/Util/KeyAlgorithm/KeyAlgorithmInterface.php b/src/Util/KeyAlgorithm/KeyAlgorithmInterface.php index 64c0ed3c..c1237f91 100644 --- a/src/Util/KeyAlgorithm/KeyAlgorithmInterface.php +++ b/src/Util/KeyAlgorithm/KeyAlgorithmInterface.php @@ -15,7 +15,9 @@ interface KeyAlgorithmInterface { /** * Generate a new unique code - * @param integer $len Length of the generated code + * + * @param integer $len Length of the generated code + * * @return string */ public function generate($len); diff --git a/src/Util/RedirectUri.php b/src/Util/RedirectUri.php index 15caddb3..848e854a 100644 --- a/src/Util/RedirectUri.php +++ b/src/Util/RedirectUri.php @@ -18,9 +18,11 @@ class RedirectUri { /** * Generate a new redirect uri - * @param string $uri The base URI - * @param array $params The query string parameters - * @param string $queryDelimeter The query string delimeter (default: "?") + * + * @param string $uri The base URI + * @param array $params The query string parameters + * @param string $queryDelimeter The query string delimeter (default: "?") + * * @return string The updated URI */ public static function make($uri, $params = [], $queryDelimeter = '?') diff --git a/src/Util/SecureKey.php b/src/Util/SecureKey.php index 51767d7c..95ca56b0 100644 --- a/src/Util/SecureKey.php +++ b/src/Util/SecureKey.php @@ -23,7 +23,9 @@ class SecureKey /** * Generate a new unique code - * @param integer $len Length of the generated code + * + * @param integer $len Length of the generated code + * * @return string */ public static function generate($len = 40) diff --git a/tests/unit/Entity/AbstractTokenEntityTest.php b/tests/unit/Entity/AbstractTokenEntityTest.php index 4c3b1020..24428085 100644 --- a/tests/unit/Entity/AbstractTokenEntityTest.php +++ b/tests/unit/Entity/AbstractTokenEntityTest.php @@ -2,10 +2,10 @@ namespace LeagueTests\Entity; -use LeagueTests\Stubs\StubAbstractTokenEntity; use League\OAuth2\Server\AuthorizationServer; use League\OAuth2\Server\Entity\ScopeEntity; use League\OAuth2\Server\Entity\SessionEntity; +use LeagueTests\Stubs\StubAbstractTokenEntity; use Mockery as M; class AbstractTokenEntityTest extends \PHPUnit_Framework_TestCase diff --git a/tests/unit/Grant/AbstractGrantTest.php b/tests/unit/Grant/AbstractGrantTest.php index e7c5043e..8a57b61b 100644 --- a/tests/unit/Grant/AbstractGrantTest.php +++ b/tests/unit/Grant/AbstractGrantTest.php @@ -2,12 +2,12 @@ namespace LeagueTests\Grant; -use LeagueTests\Stubs\StubAbstractGrant; use League\OAuth2\Server\AuthorizationServer; use League\OAuth2\Server\Entity\ClientEntity; use League\OAuth2\Server\Entity\ScopeEntity; use League\OAuth2\Server\Exception\InvalidRequestException; use League\OAuth2\Server\Grant; +use LeagueTests\Stubs\StubAbstractGrant; use Mockery as M; class AbstractGrantTest extends \PHPUnit_Framework_TestCase diff --git a/tests/unit/Grant/RefreshTokenGrantTest.php b/tests/unit/Grant/RefreshTokenGrantTest.php index 84247b06..be7a02df 100644 --- a/tests/unit/Grant/RefreshTokenGrantTest.php +++ b/tests/unit/Grant/RefreshTokenGrantTest.php @@ -288,7 +288,7 @@ class RefreshTokenGrantTest extends \PHPUnit_Framework_TestCase public function testCompleteFlowExpiredRefreshToken() { $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRefreshException'); - + $_POST = [ 'grant_type' => 'refresh_token', 'client_id' => 'testapp',