mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-01-21 02:52:43 +05:30
Clean trailing whitespace
This commit is contained in:
parent
6553fb3f22
commit
302bf1f70d
@ -41,7 +41,7 @@ class Server
|
|||||||
private $_responseTypes = array(
|
private $_responseTypes = array(
|
||||||
'code'
|
'code'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Supported grant types
|
* Supported grant types
|
||||||
* @var array
|
* @var array
|
||||||
@ -69,9 +69,9 @@ class Server
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Error codes.
|
* Error codes.
|
||||||
*
|
*
|
||||||
* To provide i8ln errors just overwrite the keys
|
* To provide i8ln errors just overwrite the keys
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $errors = array(
|
public $errors = array(
|
||||||
@ -89,7 +89,7 @@ class Server
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param array $options Optional list of options to overwrite the defaults
|
* @param array $options Optional list of options to overwrite the defaults
|
||||||
* @return void
|
* @return void
|
||||||
@ -103,7 +103,7 @@ class Server
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a database abstrator class
|
* Register a database abstrator class
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param object $db A class that implements OAuth2ServerDatabase
|
* @param object $db A class that implements OAuth2ServerDatabase
|
||||||
* @return void
|
* @return void
|
||||||
@ -115,7 +115,7 @@ class Server
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check client authorise parameters
|
* Check client authorise parameters
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param array $authParams Optional array of parsed $_GET keys
|
* @param array $authParams Optional array of parsed $_GET keys
|
||||||
* @return array Authorise request parameters
|
* @return array Authorise request parameters
|
||||||
@ -132,7 +132,7 @@ class Server
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
$params['client_id'] = (isset($authParams['client_id'])) ?
|
$params['client_id'] = (isset($authParams['client_id'])) ?
|
||||||
$authParams['client_id'] :
|
$authParams['client_id'] :
|
||||||
$_GET['client_id'];
|
$_GET['client_id'];
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -216,7 +216,7 @@ class Server
|
|||||||
'getScope',
|
'getScope',
|
||||||
$scope
|
$scope
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($scopeDetails === false) {
|
if ($scopeDetails === false) {
|
||||||
|
|
||||||
throw new ClientException(sprintf($this->errors['invalid_scope'], $scope), 4);
|
throw new ClientException(sprintf($this->errors['invalid_scope'], $scope), 4);
|
||||||
@ -233,7 +233,7 @@ class Server
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a new authorise request
|
* Parse a new authorise request
|
||||||
*
|
*
|
||||||
* @param string $type The session owner's type
|
* @param string $type The session owner's type
|
||||||
* @param string $typeId The session owner's ID
|
* @param string $typeId The session owner's ID
|
||||||
* @param array $authoriseParams The authorise request $_GET parameters
|
* @param array $authoriseParams The authorise request $_GET parameters
|
||||||
@ -251,10 +251,10 @@ class Server
|
|||||||
|
|
||||||
// Create the new auth code
|
// Create the new auth code
|
||||||
$authCode = $this->newAuthCode(
|
$authCode = $this->newAuthCode(
|
||||||
$authoriseParams['client_id'],
|
$authoriseParams['client_id'],
|
||||||
'user',
|
'user',
|
||||||
$typeId,
|
$typeId,
|
||||||
$authoriseParams['redirect_uri'],
|
$authoriseParams['redirect_uri'],
|
||||||
$authoriseParams['scopes']
|
$authoriseParams['scopes']
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -263,9 +263,9 @@ class Server
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a unique code
|
* Generate a unique code
|
||||||
*
|
*
|
||||||
* Generate a unique code for an authorisation code, or token
|
* Generate a unique code for an authorisation code, or token
|
||||||
*
|
*
|
||||||
* @return string A unique code
|
* @return string A unique code
|
||||||
*/
|
*/
|
||||||
private function generateCode()
|
private function generateCode()
|
||||||
@ -275,7 +275,7 @@ class Server
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new authorisation code
|
* Create a new authorisation code
|
||||||
*
|
*
|
||||||
* @param string $clientId The client ID
|
* @param string $clientId The client ID
|
||||||
* @param string $type The type of the owner of the session
|
* @param string $type The type of the owner of the session
|
||||||
* @param string $typeId The session owner's ID
|
* @param string $typeId The session owner's ID
|
||||||
@ -288,7 +288,7 @@ class Server
|
|||||||
{
|
{
|
||||||
$authCode = $this->generateCode();
|
$authCode = $this->generateCode();
|
||||||
|
|
||||||
// If an access token exists then update the existing session with the
|
// If an access token exists then update the existing session with the
|
||||||
// new authorisation code otherwise create a new session
|
// new authorisation code otherwise create a new session
|
||||||
if ($accessToken !== null) {
|
if ($accessToken !== null) {
|
||||||
|
|
||||||
@ -301,13 +301,13 @@ class Server
|
|||||||
$accessToken,
|
$accessToken,
|
||||||
'requested'
|
'requested'
|
||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Delete any existing sessions just to be sure
|
// Delete any existing sessions just to be sure
|
||||||
$this->_dbCall('deleteSession', $clientId, $type, $typeId);
|
$this->_dbCall('deleteSession', $clientId, $type, $typeId);
|
||||||
|
|
||||||
// Create a new session
|
// Create a new session
|
||||||
$sessionId = $this->_dbCall(
|
$sessionId = $this->_dbCall(
|
||||||
'newSession',
|
'newSession',
|
||||||
$clientId,
|
$clientId,
|
||||||
@ -319,7 +319,7 @@ class Server
|
|||||||
null,
|
null,
|
||||||
'requested'
|
'requested'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add the scopes
|
// Add the scopes
|
||||||
foreach ($scopes as $key => $scope) {
|
foreach ($scopes as $key => $scope) {
|
||||||
|
|
||||||
@ -332,17 +332,17 @@ class Server
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $authCode;
|
return $authCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Issue an access token
|
* Issue an access token
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*
|
*
|
||||||
* @param array $authParams Optional array of parsed $_POST keys
|
* @param array $authParams Optional array of parsed $_POST keys
|
||||||
*
|
*
|
||||||
* @return array Authorise request parameters
|
* @return array Authorise request parameters
|
||||||
*/
|
*/
|
||||||
public function issueAccessToken($authParams = null)
|
public function issueAccessToken($authParams = null)
|
||||||
@ -369,10 +369,10 @@ class Server
|
|||||||
|
|
||||||
switch ($params['grant_type'])
|
switch ($params['grant_type'])
|
||||||
{
|
{
|
||||||
|
|
||||||
case 'authorization_code': // Authorization code grant
|
case 'authorization_code': // Authorization code grant
|
||||||
return $this->completeAuthCodeGrant($authParams, $params);
|
return $this->completeAuthCodeGrant($authParams, $params);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'refresh_token': // Refresh token
|
case 'refresh_token': // Refresh token
|
||||||
case 'password': // Resource owner password credentials grant
|
case 'password': // Resource owner password credentials grant
|
||||||
@ -385,12 +385,12 @@ class Server
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Complete the authorisation code grant
|
* Complete the authorisation code grant
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*
|
*
|
||||||
* @param array $authParams Array of parsed $_POST keys
|
* @param array $authParams Array of parsed $_POST keys
|
||||||
* @param array $params Generated parameters from issueAccessToken()
|
* @param array $params Generated parameters from issueAccessToken()
|
||||||
*
|
*
|
||||||
* @return array Authorise request parameters
|
* @return array Authorise request parameters
|
||||||
*/
|
*/
|
||||||
private function completeAuthCodeGrant($authParams = array(), $params = array())
|
private function completeAuthCodeGrant($authParams = array(), $params = array())
|
||||||
@ -438,7 +438,7 @@ class Server
|
|||||||
$clientDetails = $this->_dbCall(
|
$clientDetails = $this->_dbCall(
|
||||||
'validateClient',
|
'validateClient',
|
||||||
$params['client_id'],
|
$params['client_id'],
|
||||||
$params['client_secret'],
|
$params['client_secret'],
|
||||||
$params['redirect_uri']
|
$params['redirect_uri']
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -472,7 +472,7 @@ class Server
|
|||||||
if ( ! $session) {
|
if ( ! $session) {
|
||||||
|
|
||||||
throw new ClientException(sprintf($this->errors['invalid_grant'], 'code'), 9);
|
throw new ClientException(sprintf($this->errors['invalid_grant'], 'code'), 9);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// A session ID was returned so update it with an access token,
|
// A session ID was returned so update it with an access token,
|
||||||
@ -510,16 +510,16 @@ class Server
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the redirect uri with appended params
|
* Generates the redirect uri with appended params
|
||||||
*
|
*
|
||||||
* @param string $redirectUri The redirect URI
|
* @param string $redirectUri The redirect URI
|
||||||
* @param array $params The parameters to be appended to the URL
|
* @param array $params The parameters to be appended to the URL
|
||||||
* @param string $query_delimeter The query string delimiter (default: ?)
|
* @param string $query_delimeter The query string delimiter (default: ?)
|
||||||
*
|
*
|
||||||
* @return string The updated redirect URI
|
* @return string The updated redirect URI
|
||||||
*/
|
*/
|
||||||
public function redirectUri($redirectUri, $params = array(), $queryDelimeter = '?')
|
public function redirectUri($redirectUri, $params = array(), $queryDelimeter = '?')
|
||||||
{
|
{
|
||||||
|
|
||||||
if (strstr($redirectUri, $queryDelimeter)) {
|
if (strstr($redirectUri, $queryDelimeter)) {
|
||||||
|
|
||||||
$redirectUri = $redirectUri . '&' . http_build_query($params);
|
$redirectUri = $redirectUri . '&' . http_build_query($params);
|
||||||
@ -529,14 +529,14 @@ class Server
|
|||||||
$redirectUri = $redirectUri . $queryDelimeter . http_build_query($params);
|
$redirectUri = $redirectUri . $queryDelimeter . http_build_query($params);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $redirectUri;
|
return $redirectUri;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call database methods from the abstractor
|
* Call database methods from the abstractor
|
||||||
*
|
*
|
||||||
* @return mixed The query result
|
* @return mixed The query result
|
||||||
*/
|
*/
|
||||||
private function _dbCall()
|
private function _dbCall()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user