Compare commits

..

20 Commits
0.3.1 ... 0.3.5

Author SHA1 Message Date
Alex Bilbie
41d8a1efa3 Merge branch 'release/0.3.5' 2012-12-12 11:44:56 +00:00
Alex Bilbie
4928221b49 Version bump 2012-12-12 11:44:51 +00:00
Alex Bilbie
8131d5be90 Merge branch 'hotfix/resourceConfig' into develop 2012-12-12 11:44:04 +00:00
Alex Bilbie
a948335e45 Merge branch 'hotfix/resourceConfig' 2012-12-12 11:43:11 +00:00
Alex Bilbie
aa978d3581 Fix variable name 2012-12-12 11:43:01 +00:00
Alex Bilbie
b1d91f33cf Merge branch 'release/0.3.4' into develop 2012-12-11 15:33:20 +00:00
Alex Bilbie
1be25955d6 Merge branch 'release/0.3.4' 2012-12-11 15:33:05 +00:00
Alex Bilbie
3365953257 Version bump 2012-12-11 15:32:27 +00:00
Alex Bilbie
302bf1f70d Clean trailing whitespace 2012-12-11 15:31:42 +00:00
Alex Bilbie
6553fb3f22 Return client details 2012-12-11 12:09:56 +00:00
Alex Bilbie
fdfe80289a Merge branch 'release/0.3.3'. Release version 0.3.3
Conflicts:
	composer.json
2012-12-10 21:31:58 +00:00
Alex Bilbie
0ed6674ceb Version bump. Fixed website 2012-12-10 21:31:08 +00:00
Alex Bilbie
912cd3fa25 Changed session stage to 'requested' as per enum 2012-12-10 21:19:11 +00:00
Alex Bilbie
a5b83c00bd Version bump 2012-11-20 15:29:43 +00:00
Alex Bilbie
129c9a7b7a Version bump 2012-11-20 15:28:48 +00:00
Alex Bilbie
958eab33a7 Lots of small documentation updates and clarifications 2012-11-20 15:27:33 +00:00
Alex Bilbie
fead044830 Spacing fixes and fixed sessionScopes() example query 2012-11-20 15:27:15 +00:00
Alex Bilbie
21f48c0491 Spacing updates 2012-11-20 15:26:04 +00:00
Alex Bilbie
ac990b609a Fixed client_id column length 2012-11-16 16:40:01 +00:00
Alex Bilbie
b2188514d9 Merge branch 'release/0.3' into develop 2012-10-14 17:21:04 +01:00
7 changed files with 234 additions and 257 deletions

View File

@@ -1,7 +1,7 @@
{ {
"name": "lncd/oauth2", "name": "lncd/oauth2",
"description": "OAuth 2.0 Framework", "description": "OAuth 2.0 Framework",
"version": "0.3.1", "version": "0.3.5",
"homepage": "https://github.com/lncd/OAuth2", "homepage": "https://github.com/lncd/OAuth2",
"license": "MIT", "license": "MIT",
"require": { "require": {
@@ -29,7 +29,7 @@
{ {
"name": "Alex Bilbie", "name": "Alex Bilbie",
"email": "hello@alexbilbie.com", "email": "hello@alexbilbie.com",
"homepage": "http://www.httpster.org", "homepage": "http://www.alexbilbie.com",
"role": "Developer" "role": "Developer"
} }
], ],

View File

@@ -20,7 +20,7 @@ CREATE TABLE `client_endpoints` (
-- Create syntax for TABLE 'oauth_sessions' -- Create syntax for TABLE 'oauth_sessions'
CREATE TABLE `oauth_sessions` ( CREATE TABLE `oauth_sessions` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`client_id` varchar(32) NOT NULL DEFAULT '', `client_id` varchar(40) NOT NULL DEFAULT '',
`redirect_uri` varchar(250) NOT NULL DEFAULT '', `redirect_uri` varchar(250) NOT NULL DEFAULT '',
`owner_type` enum('user','client') NOT NULL DEFAULT 'user', `owner_type` enum('user','client') NOT NULL DEFAULT 'user',
`owner_id` varchar(255) DEFAULT NULL, `owner_id` varchar(255) DEFAULT NULL,

View File

@@ -26,10 +26,22 @@ interface Database
* $redirectUri * $redirectUri
* </code> * </code>
* *
* @param string $clientId The client's ID * Response:
*
* <code>
* Array
* (
* [client_id] => (string) The client ID
* [client secret] => (string) The client secret
* [redirect_uri] => (string) The redirect URI used in this request
* [name] => (string) The name of the client
* )
* </code>
*
* @param string $clientId The client's ID
* @param string $clientSecret The client's secret (default = "null") * @param string $clientSecret The client's secret (default = "null")
* @param string $redirectUri The client's redirect URI (default = "null") * @param string $redirectUri The client's redirect URI (default = "null")
* @return [type] [description] * @return bool|array Returns false if the validation fails, array on success
*/ */
public function validateClient( public function validateClient(
$clientId, $clientId,
@@ -56,7 +68,7 @@ interface Database
* @param string $authCode The authorisation code (default = "null") * @param string $authCode The authorisation code (default = "null")
* @param string $accessToken The access token (default = "null") * @param string $accessToken The access token (default = "null")
* @param string $stage The stage of the session (default ="request") * @param string $stage The stage of the session (default ="request")
* @return [type] [description] * @return int The session ID
*/ */
public function newSession( public function newSession(
$clientId, $clientId,
@@ -84,7 +96,7 @@ interface Database
* @param string $authCode The authorisation code (default = "null") * @param string $authCode The authorisation code (default = "null")
* @param string $accessToken The access token (default = "null") * @param string $accessToken The access token (default = "null")
* @param string $stage The stage of the session (default ="request") * @param string $stage The stage of the session (default ="request")
* @return void * @return void
*/ */
public function updateSession( public function updateSession(
$sessionId, $sessionId,
@@ -105,7 +117,7 @@ interface Database
* @param string $clientId The client ID * @param string $clientId The client ID
* @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
* @return [type] [description] * @return void
*/ */
public function deleteSession( public function deleteSession(
$clientId, $clientId,
@@ -145,7 +157,7 @@ interface Database
* @param string $clientId The client ID * @param string $clientId The client ID
* @param string $redirectUri The redirect URI * @param string $redirectUri The redirect URI
* @param string $authCode The authorisation code * @param string $authCode The authorisation code
* @return int|bool Returns the session ID if the auth code * @return int|bool Returns the session ID if the auth code
* is valid otherwise returns false * is valid otherwise returns false
*/ */
public function validateAuthCode( public function validateAuthCode(

View File

@@ -163,6 +163,8 @@ class Server
throw new ClientException($this->errors['invalid_client'], 8); throw new ClientException($this->errors['invalid_client'], 8);
} }
$params['client_details'] = $clientDetails;
// Response type // Response type
if ( ! isset($authParams['response_type']) && ! isset($_GET['response_type'])) { if ( ! isset($authParams['response_type']) && ! isset($_GET['response_type'])) {
@@ -297,7 +299,7 @@ class Server
$typeId, $typeId,
$authCode, $authCode,
$accessToken, $accessToken,
'request' 'requested'
); );
} else { } else {
@@ -315,7 +317,7 @@ class Server
$authCode, $authCode,
null, null,
null, null,
'request' 'requested'
); );
// Add the scopes // Add the scopes

View File

@@ -37,8 +37,8 @@ interface Database
* Database query: * Database query:
* *
* <code> * <code>
* SELECT scope FROM oauth_session_scopes WHERE access_token = * SELECT scope FROM oauth_session_scopes WHERE session_id =
* '291dca1c74900f5f252de351e0105aa3fc91b90b' * $sessionId
* </code> * </code>
* *
* Response: * Response:

View File

@@ -75,7 +75,7 @@ class Server
public function __construct($options = null) public function __construct($options = null)
{ {
if ($options !== null) { if ($options !== null) {
$this->config = array_merge($this->config, $options); $this->_config = array_merge($this->_config, $options);
} }
} }

View File

@@ -23,169 +23,132 @@ class OAuthdb implements Database
'description' => 'test' 'description' => 'test'
)); ));
public function validateClient( public function validateClient($clientId, $clientSecret = null, $redirectUri = null)
$clientId, {
$clientSecret = null, if ($clientId !== $this->clients[0]['client_id'])
$redirectUri = null {
) return false;
{ }
if ($clientId !== $this->clients[0]['client_id'])
{
return false;
}
if ($clientSecret !== null && $clientSecret !== $this->clients[0]['client_secret']) if ($clientSecret !== null && $clientSecret !== $this->clients[0]['client_secret'])
{ {
return false; return false;
} }
if ($redirectUri !== null && $redirectUri !== $this->clients[0]['redirect_uri']) if ($redirectUri !== null && $redirectUri !== $this->clients[0]['redirect_uri'])
{ {
return false; return false;
} }
return $this->clients[0]; return $this->clients[0];
} }
public function newSession( public function newSession($clientId, $redirectUri, $type = 'user', $typeId = null, $authCode = null, $accessToken = null, $accessTokenExpire = null, $stage = 'requested')
$clientId, {
$redirectUri, $id = count($this->sessions);
$type = 'user',
$typeId = null,
$authCode = null,
$accessToken = null,
$accessTokenExpire = null,
$stage = 'requested'
)
{
$id = count($this->sessions);
$this->sessions[$id] = array( $this->sessions[$id] = array(
'id' => $id, 'id' => $id,
'client_id' => $clientId, 'client_id' => $clientId,
'redirect_uri' => $redirectUri, 'redirect_uri' => $redirectUri,
'owner_type' => $type, 'owner_type' => $type,
'owner_id' => $typeId, 'owner_id' => $typeId,
'auth_code' => $authCode, 'auth_code' => $authCode,
'access_token' => $accessToken, 'access_token' => $accessToken,
'access_token_expire' => $accessTokenExpire, 'access_token_expire' => $accessTokenExpire,
'stage' => $stage 'stage' => $stage
); );
$this->sessions_client_type_id[$clientId . ':' . $type . ':' . $typeId] = $id; $this->sessions_client_type_id[$clientId . ':' . $type . ':' . $typeId] = $id;
$this->sessions_code[$clientId . ':' . $redirectUri . ':' . $authCode] = $id; $this->sessions_code[$clientId . ':' . $redirectUri . ':' . $authCode] = $id;
return true; return $id;
} }
public function updateSession( public function updateSession($sessionId, $authCode = null, $accessToken = null, $accessTokenExpire = null, $stage = 'requested')
$sessionId, {
$authCode = null, $this->sessions[$sessionId]['auth_code'] = $authCode;
$accessToken = null, $this->sessions[$sessionId]['access_token'] = $accessToken;
$accessTokenExpire = null, $this->sessions[$sessionId]['access_token_expire'] = $accessTokenExpire;
$stage = 'requested' $this->sessions[$sessionId]['stage'] = $stage;
)
{
$this->sessions[$sessionId]['auth_code'] = $authCode;
$this->sessions[$sessionId]['access_token'] = $accessToken;
$this->sessions[$sessionId]['access_token_expire'] = $accessTokenExpire;
$this->sessions[$sessionId]['stage'] = $stage;
return true; return true;
} }
public function deleteSession( public function deleteSession($clientId, $type, $typeId)
$clientId, {
$type, $key = $clientId . ':' . $type . ':' . $typeId;
$typeId if (isset($this->sessions_client_type_id[$key]))
) {
{ unset($this->sessions[$this->sessions_client_type_id[$key]]);
$key = $clientId . ':' . $type . ':' . $typeId; }
if (isset($this->sessions_client_type_id[$key])) return true;
{ }
unset($this->sessions[$this->sessions_client_type_id[$key]]);
}
return true;
}
public function validateAuthCode( public function validateAuthCode($clientId, $redirectUri, $authCode)
$clientId, {
$redirectUri, $key = $clientId . ':' . $redirectUri . ':' . $authCode;
$authCode
)
{
$key = $clientId . ':' . $redirectUri . ':' . $authCode;
if (isset($this->sessions_code[$key])) if (isset($this->sessions_code[$key]))
{ {
return $this->sessions[$this->sessions_code[$key]]; return $this->sessions[$this->sessions_code[$key]];
} }
return false; return false;
} }
public function hasSession( public function hasSession($type, $typeId, $clientId)
$type, {
$typeId, die('not implemented hasSession');
$clientId }
)
{
die('not implemented hasSession');
}
public function getAccessToken($sessionId) public function getAccessToken($sessionId)
{ {
die('not implemented getAccessToken'); die('not implemented getAccessToken');
} }
public function removeAuthCode($sessionId) public function removeAuthCode($sessionId)
{ {
die('not implemented removeAuthCode'); die('not implemented removeAuthCode');
} }
public function setAccessToken( public function setAccessToken(
$sessionId, $sessionId,
$accessToken $accessToken
) )
{ {
die('not implemented setAccessToken'); die('not implemented setAccessToken');
} }
public function addSessionScope( public function addSessionScope($sessionId, $scope)
$sessionId, {
$scope if ( ! isset($this->session_scopes[$sessionId]))
) {
{ $this->session_scopes[$sessionId] = array();
if ( ! isset($this->session_scopes[$sessionId])) }
{
$this->session_scopes[$sessionId] = array();
}
$this->session_scopes[$sessionId][] = $scope; $this->session_scopes[$sessionId][] = $scope;
return true; return true;
} }
public function getScope($scope) public function getScope($scope)
{ {
if ( ! isset($this->scopes[$scope])) if ( ! isset($this->scopes[$scope]))
{ {
return false; return false;
} }
return $this->scopes[$scope]; return $this->scopes[$scope];
} }
public function updateSessionScopeAccessToken( public function updateSessionScopeAccessToken($sessionId, $accessToken)
$sessionId, {
$accessToken return true;
) }
{
return true;
}
public function accessTokenScopes($accessToken) public function accessTokenScopes($accessToken)
{ {
die('not implemented accessTokenScopes'); die('not implemented accessTokenScopes');
} }
} }