diff --git a/src/OAuth2/Grant/RefreshToken.php b/src/OAuth2/Grant/RefreshToken.php
index b396e2d1..bd7839ca 100644
--- a/src/OAuth2/Grant/RefreshToken.php
+++ b/src/OAuth2/Grant/RefreshToken.php
@@ -1,4 +1,13 @@
+ * @copyright Copyright (c) 2013 University of Lincoln
+ * @license http://mit-license.org/
+ * @link http://github.com/lncd/oauth2
+ */
namespace OAuth2\Grant;
@@ -10,22 +19,47 @@ use OAuth2\Storage\SessionInterface;
use OAuth2\Storage\ClientInterface;
use OAuth2\Storage\ScopeInterface;
+/**
+ * Referesh token grant
+ */
class RefreshToken implements GrantTypeInterface {
+ /**
+ * Grant identifier
+ * @var string
+ */
protected $identifier = 'refresh_token';
+
+ /**
+ * Response type
+ * @var string
+ */
protected $responseType = null;
+ /**
+ * Return the identifier
+ * @return string
+ */
public function getIdentifier()
{
return $this->identifier;
}
+ /**
+ * Return the response type
+ * @return string
+ */
public function getResponseType()
{
return $this->responseType;
}
- public function completeFlow($inputParams = null, $authParams = array())
+ /**
+ * Complete the refresh token grant
+ * @param null|array $inputParams
+ * @return array
+ */
+ public function completeFlow($inputParams = null)
{
// Get the required params
$authParams = AuthServer::getParam(array('client_id', 'client_secret', 'refresh_token'), 'post', $inputParams);
diff --git a/src/OAuth2/Storage/ClientInterface.php b/src/OAuth2/Storage/ClientInterface.php
index 2abee251..605c42a9 100644
--- a/src/OAuth2/Storage/ClientInterface.php
+++ b/src/OAuth2/Storage/ClientInterface.php
@@ -1,4 +1,13 @@
+ * @copyright Copyright (c) 2013 University of Lincoln
+ * @license http://mit-license.org/
+ * @link http://github.com/lncd/oauth2
+ */
namespace OAuth2\Storage;
diff --git a/src/OAuth2/Storage/ScopeInterface.php b/src/OAuth2/Storage/ScopeInterface.php
index 8777aee6..82c71c39 100644
--- a/src/OAuth2/Storage/ScopeInterface.php
+++ b/src/OAuth2/Storage/ScopeInterface.php
@@ -1,4 +1,13 @@
+ * @copyright Copyright (c) 2013 University of Lincoln
+ * @license http://mit-license.org/
+ * @link http://github.com/lncd/oauth2
+ */
namespace OAuth2\Storage;
diff --git a/src/OAuth2/Storage/SessionInterface.php b/src/OAuth2/Storage/SessionInterface.php
index 7e9fd368..1c2632f6 100644
--- a/src/OAuth2/Storage/SessionInterface.php
+++ b/src/OAuth2/Storage/SessionInterface.php
@@ -1,4 +1,13 @@
+ * @copyright Copyright (c) 2013 University of Lincoln
+ * @license http://mit-license.org/
+ * @link http://github.com/lncd/oauth2
+ */
namespace OAuth2\Storage;
@@ -16,15 +25,16 @@ interface SessionInterface
* $accessToken, $stage, UNIX_TIMESTAMP(NOW()), UNIX_TIMESTAMP(NOW()))
*
*
- * @param string $clientId The client ID
- * @param string $redirectUri The redirect URI
- * @param string $type The session owner's type (default = "user")
- * @param string $typeId The session owner's ID (default = "null")
- * @param string $authCode The authorisation code (default = "null")
- * @param string $accessToken The access token (default = "null")
- * @param string $refreshToken The refresh token (default = "null")
- * @param string $stage The stage of the session (default ="request")
- * @return int The session ID
+ * @param string $clientId The client ID
+ * @param string $redirectUri The redirect URI
+ * @param string $type The session owner's type (default = "user")
+ * @param string $typeId The session owner's ID (default = "null")
+ * @param string $authCode The authorisation code (default = "null")
+ * @param string $accessToken The access token (default = "null")
+ * @param string $refreshToken The refresh token (default = "null")
+ * @param int $accessTokenExpire The expiry time of an access token as a unix timestamp
+ * @param string $stage The stage of the session (default ="request")
+ * @return int The session ID
*/
public function createSession(
$clientId,
@@ -49,11 +59,12 @@ interface SessionInterface
* id = $sessionId
*
*
- * @param string $sessionId The session ID
- * @param string $authCode The authorisation code (default = "null")
- * @param string $accessToken The access token (default = "null")
- * @param string $refreshToken The refresh token (default = "null")
- * @param string $stage The stage of the session (default ="request")
+ * @param string $sessionId The session ID
+ * @param string $authCode The authorisation code (default = "null")
+ * @param string $accessToken The access token (default = "null")
+ * @param string $refreshToken The refresh token (default = "null")
+ * @param int $accessTokenExpire The expiry time of an access token as a unix timestamp
+ * @param string $stage The stage of the session (default ="request")
* @return void
*/
public function updateSession(
@@ -125,6 +136,29 @@ interface SessionInterface
$authCode
);
+ /**
+ * Validate an access token
+ *
+ * Example SQL query:
+ *
+ *
+ * SELECT id, owner_id, owner_type FROM oauth_sessions WHERE access_token = $accessToken
+ *
+ *
+ * Response:
+ *
+ *
+ * Array
+ * (
+ * [id] => (int) The session ID
+ * [owner_type] => (string) The owner type
+ * [owner_id] => (string) The owner ID
+ * )
+ *
+ *
+ * @param [type] $accessToken [description]
+ * @return [type] [description]
+ */
public function validateAccessToken($accessToken);
/**
@@ -142,6 +176,12 @@ interface SessionInterface
*/
public function getAccessToken($sessionId);
+ /**
+ * Validate a refresh token
+ * @param string $refreshToken The refresh token
+ * @param string $clientId The client ID
+ * @return int The session ID
+ */
public function validateRefreshToken($refreshToken, $clientId);
/**
@@ -174,7 +214,7 @@ interface SessionInterface
*
*
* @param int $sessionId The session ID
- * @param string $scope The scope ID
+ * @param string $scopeId The scope ID
* @return void
*/
public function associateScope($sessionId, $scopeId);
diff --git a/src/OAuth2/Util/RedirectUri.php b/src/OAuth2/Util/RedirectUri.php
index 580758e5..c123b187 100644
--- a/src/OAuth2/Util/RedirectUri.php
+++ b/src/OAuth2/Util/RedirectUri.php
@@ -1,9 +1,28 @@
+ * @copyright Copyright (c) 2013 University of Lincoln
+ * @license http://mit-license.org/
+ * @link http://github.com/lncd/oauth2
+ */
namespace OAuth2\Util;
+/**
+ * RedirectUri class
+ */
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: "?")
+ * @return string The updated URI
+ */
public static function make($uri, $params = array(), $queryDelimeter = '?')
{
$uri .= (strstr($uri, $queryDelimeter) === false) ? $queryDelimeter : '&';
diff --git a/src/OAuth2/Util/SecureKey.php b/src/OAuth2/Util/SecureKey.php
index 35a55298..d6450146 100644
--- a/src/OAuth2/Util/SecureKey.php
+++ b/src/OAuth2/Util/SecureKey.php
@@ -1,9 +1,26 @@
+ * @copyright Copyright (c) 2013 University of Lincoln
+ * @license http://mit-license.org/
+ * @link http://github.com/lncd/oauth2
+ */
namespace OAuth2\Util;
+/**
+ * SecureKey class
+ */
class SecureKey
{
+ /**
+ * Generate a new unique code
+ * @param integer $len Length of the generated code
+ * @return string
+ */
public static function make($len = 40)
{
// We generate twice as many bytes here because we want to ensure we have