Compare commits

..

3 Commits
0.2.2 ... 0.2.1

Author SHA1 Message Date
Alex Bilbie
0af98224dd Merge branch 'hotfix/0.2.1' 2012-08-28 12:31:07 +01:00
Alex Bilbie
88185320a8 Version bump 2012-08-28 12:30:58 +01:00
Alex Bilbie
a1e5fdddda Bug fix 2012-08-28 12:30:51 +01:00
2 changed files with 11 additions and 27 deletions

View File

@@ -1,7 +1,7 @@
{
"name": "lncd/Oauth2",
"description": "OAuth 2.0 Framework",
"version": "0.2.2",
"version": "0.2.1",
"homepage": "https://github.com/lncd/OAuth2",
"license": "MIT",
"require": {

View File

@@ -2,12 +2,7 @@
namespace Oauth2\Resource;
class ServerException extends \Exception
{
}
class ClientException extends \Exception
class OAuthResourceServerException extends \Exception
{
}
@@ -61,9 +56,7 @@ class Server
*/
public $errors = array(
'missing_access_token' => 'An access token was not presented with the request',
'invalid_access_token' => 'The access token is not registered with the resource server',
'missing_access_token_details' => 'The registered database abstractor did not return a valid access token details response',
'invalid_access_token_scopes' => 'The registered database abstractor did not return a valid access token scopes response',
'invalid_access_token' => 'The access token is not registered with the resource server'
);
/**
@@ -121,6 +114,9 @@ class Server
{
$accessToken = null;
$_SERVER['REQUEST_METHOD'] = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null;
// Try and get the access token via an access_token or oauth_token parameter
switch ($_SERVER['REQUEST_METHOD'])
{
@@ -154,33 +150,21 @@ class Server
if ($result === false) {
throw new ClientException($this->errors['invalid_access_token']);
throw new OAuthResourceServerException($this->errors['invalid_access_token']);
} else {
if ( ! array_key_exists('id', $result) || ! array_key_exists('owner_id', $result) ||
! array_key_exists('owner_type', $result)) {
throw new ServerException($this->errors['missing_access_token_details']);
}
$this->_accessToken = $accessToken;
$this->_type = $result['owner_type'];
$this->_typeId = $result['owner_id'];
// Get the scopes
$scopes = $this->_dbCall('sessionScopes', $result['id']);
if ( ! is_array($scopes))
{
throw new ServerException($this->errors['invalid_access_token_scopes']);
}
$this->_scopes = $scopes;
$this->_scopes = $this->_dbCall('sessionScopes', $result['id']);
}
} else {
throw new ClientException($this->errors['missing_access_token']);
throw new OAuthResourceServerException($this->errors['missing_access_token']);
}
}
@@ -227,11 +211,11 @@ class Server
private function _dbCall()
{
if ($this->_db === null) {
throw new ServerException('No registered database abstractor');
throw new OAuthResourceServerException('No registered database abstractor');
}
if ( ! $this->_db instanceof Database) {
throw new ServerException('The registered database abstractor is not an instance of Oauth2\Resource\Database');
throw new OAuthResourceServerException('Registered database abstractor is not an instance of Oauth2\Resource\Database');
}
$args = func_get_args();