Renamed get/setExpiresIn to get/setAccessTokenTTL

This commit is contained in:
Alex Bilbie 2013-05-08 10:35:13 -07:00
parent c77484e97b
commit d6932cbb5e
10 changed files with 49 additions and 49 deletions

View File

@ -37,7 +37,7 @@ class AuthServer
* The TTL (time to live) of an access token in seconds (default: 3600) * The TTL (time to live) of an access token in seconds (default: 3600)
* @var integer * @var integer
*/ */
protected $expiresIn = 3600; protected $accessTokenTTL = 3600;
/** /**
* The registered grant response types * The registered grant response types
@ -349,16 +349,16 @@ class AuthServer
* Get the TTL for an access token * Get the TTL for an access token
* @return int The TTL * @return int The TTL
*/ */
public function getExpiresIn() public function getAccessTokenTTL()
{ {
return $this->expiresIn; return $this->accessTokenTTL;
} }
/** /**
* Set the TTL for an access token * Set the TTL for an access token
* @param int $accessTokenTTL The new TTL * @param int $accessTokenTTL The new TTL
*/ */
public function setAcessTokenTTL($accessTokenTTL) public function setAccessTokenTTL($accessTokenTTL)
{ {
$this->accessTokenTTL = $accessTokenTTL; $this->accessTokenTTL = $accessTokenTTL;
} }

View File

@ -254,7 +254,7 @@ class AuthCode implements GrantTypeInterface {
// A session ID was returned so update it with an access token and remove the authorisation code // A session ID was returned so update it with an access token and remove the authorisation code
$accessToken = SecureKey::make(); $accessToken = SecureKey::make();
$accessTokenExpiresIn = ($this->accessTokenTTL !== null) ? $this->accessTokenTTL : $this->authServer->getExpiresIn(); $accessTokenExpiresIn = ($this->accessTokenTTL !== null) ? $this->accessTokenTTL : $this->authServer->getAccessTokenTTL();
$accessTokenExpires = time() + $accessTokenExpiresIn; $accessTokenExpires = time() + $accessTokenExpiresIn;
// Remove the auth code // Remove the auth code

View File

@ -142,7 +142,7 @@ class ClientCredentials implements GrantTypeInterface {
// Generate an access token // Generate an access token
$accessToken = SecureKey::make(); $accessToken = SecureKey::make();
$accessTokenExpiresIn = ($this->accessTokenTTL !== null) ? $this->accessTokenTTL : $this->authServer->getExpiresIn(); $accessTokenExpiresIn = ($this->accessTokenTTL !== null) ? $this->accessTokenTTL : $this->authServer->getAccessTokenTTL();
$accessTokenExpires = time() + $accessTokenExpiresIn; $accessTokenExpires = time() + $accessTokenExpiresIn;
// Delete any existing sessions just to be sure // Delete any existing sessions just to be sure

View File

@ -84,7 +84,7 @@ class Implict implements GrantTypeInterface {
$accessToken = SecureKey::make(); $accessToken = SecureKey::make();
// Compute expiry time // Compute expiry time
$accessTokenExpires = time() + $this->authServer->getExpiresIn(); $accessTokenExpires = time() + $this->authServer->getAccessTokenTTL();
// Create a new session // Create a new session
$sessionId = $this->authServer->getStorage('session')->createSession($authParams['client_id'], 'user', $authParams['user_id']); $sessionId = $this->authServer->getStorage('session')->createSession($authParams['client_id'], 'user', $authParams['user_id']);

View File

@ -185,7 +185,7 @@ class Password implements GrantTypeInterface {
// Generate an access token // Generate an access token
$accessToken = SecureKey::make(); $accessToken = SecureKey::make();
$accessTokenExpiresIn = ($this->accessTokenTTL !== null) ? $this->accessTokenTTL : $this->authServer->getExpiresIn(); $accessTokenExpiresIn = ($this->accessTokenTTL !== null) ? $this->accessTokenTTL : $this->authServer->getAccessTokenTTL();
$accessTokenExpires = time() + $accessTokenExpiresIn; $accessTokenExpires = time() + $accessTokenExpiresIn;
// Delete any existing sessions just to be sure // Delete any existing sessions just to be sure

View File

@ -157,7 +157,7 @@ class RefreshToken implements GrantTypeInterface {
// Generate new tokens and associate them to the session // Generate new tokens and associate them to the session
$accessToken = SecureKey::make(); $accessToken = SecureKey::make();
$accessTokenExpiresIn = ($this->accessTokenTTL !== null) ? $this->accessTokenTTL : $this->authServer->getExpiresIn(); $accessTokenExpiresIn = ($this->accessTokenTTL !== null) ? $this->accessTokenTTL : $this->authServer->getAccessTokenTTL();
$accessTokenExpires = time() + $accessTokenExpiresIn; $accessTokenExpires = time() + $accessTokenExpiresIn;
$refreshToken = SecureKey::make(); $refreshToken = SecureKey::make();
$refreshTokenExpires = time() + $this->getRefreshTokenTTL(); $refreshTokenExpires = time() + $this->getRefreshTokenTTL();

View File

@ -152,14 +152,14 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->assertTrue($v); $this->assertTrue($v);
} }
public function test_getExpiresIn() public function test_getAccessTokenTTL()
{ {
$a = $this->returnDefault(); $a = $this->returnDefault();
$a->setExpiresIn(7200); $a->setAccessTokenTTL(7200);
$this->assertEquals(7200, $a->getExpiresIn()); $this->assertEquals(7200, $a->getAccessTokenTTL());
} }
public function test_setExpiresIn() public function test_setAccessTokenTTL()
{ {
$a = $this->returnDefault(); $a = $this->returnDefault();
$a->setScopeDelimeter(';'); $a->setScopeDelimeter(';');
@ -382,8 +382,8 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires', $v); $this->assertArrayHasKey('expires', $v);
$this->assertArrayHasKey('expires_in', $v); $this->assertArrayHasKey('expires_in', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']); $this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']); $this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
} }
public function test_issueAccessToken() public function test_issueAccessToken()
@ -419,8 +419,8 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires', $v); $this->assertArrayHasKey('expires', $v);
$this->assertArrayHasKey('expires_in', $v); $this->assertArrayHasKey('expires_in', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']); $this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']); $this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
} }
public function test_issueAccessToken_customExpiresIn() public function test_issueAccessToken_customExpiresIn()
@ -439,7 +439,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$a = $this->returnDefault(); $a = $this->returnDefault();
$grant = new OAuth2\Grant\AuthCode($a); $grant = new OAuth2\Grant\AuthCode($a);
$grant->setExpiresIn(30); $grant->setAccessTokenTTL(30);
$a->addGrantType($grant); $a->addGrantType($grant);
$_POST['grant_type'] = 'authorization_code'; $_POST['grant_type'] = 'authorization_code';
@ -458,8 +458,8 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires', $v); $this->assertArrayHasKey('expires', $v);
$this->assertArrayHasKey('expires_in', $v); $this->assertArrayHasKey('expires_in', $v);
$this->assertNotEquals($a->getExpiresIn(), $v['expires_in']); $this->assertNotEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertNotEquals(time()+$a->getExpiresIn(), $v['expires']); $this->assertNotEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
$this->assertEquals(30, $v['expires_in']); $this->assertEquals(30, $v['expires_in']);
$this->assertEquals(time()+30, $v['expires']); $this->assertEquals(time()+30, $v['expires']);
} }
@ -497,8 +497,8 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires', $v); $this->assertArrayHasKey('expires', $v);
$this->assertArrayHasKey('expires_in', $v); $this->assertArrayHasKey('expires_in', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']); $this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']); $this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
} }
public function tearDown() { public function tearDown() {

View File

@ -238,8 +238,8 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires', $v); $this->assertArrayHasKey('expires', $v);
$this->assertArrayHasKey('expires_in', $v); $this->assertArrayHasKey('expires_in', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']); $this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']); $this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
} }
function test_issueAccessToken_clientCredentialsGrant() function test_issueAccessToken_clientCredentialsGrant()
@ -276,8 +276,8 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires', $v); $this->assertArrayHasKey('expires', $v);
$this->assertArrayHasKey('expires_in', $v); $this->assertArrayHasKey('expires_in', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']); $this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']); $this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
} }
function test_issueAccessToken_clientCredentialsGrant_customExpiresIn() function test_issueAccessToken_clientCredentialsGrant_customExpiresIn()
@ -298,7 +298,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$a = $this->returnDefault(); $a = $this->returnDefault();
$grant = new OAuth2\Grant\ClientCredentials($a); $grant = new OAuth2\Grant\ClientCredentials($a);
$grant->setExpiresIn(30); $grant->setAccessTokenTTL(30);
$a->addGrantType($grant); $a->addGrantType($grant);
$a->requireScopeParam(false); $a->requireScopeParam(false);
@ -316,8 +316,8 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires', $v); $this->assertArrayHasKey('expires', $v);
$this->assertArrayHasKey('expires_in', $v); $this->assertArrayHasKey('expires_in', $v);
$this->assertNotEquals($a->getExpiresIn(), $v['expires_in']); $this->assertNotEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertNotEquals(time()+$a->getExpiresIn(), $v['expires']); $this->assertNotEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
$this->assertEquals(30, $v['expires_in']); $this->assertEquals(30, $v['expires_in']);
$this->assertEquals(time()+30, $v['expires']); $this->assertEquals(time()+30, $v['expires']);
} }
@ -356,8 +356,8 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires', $v); $this->assertArrayHasKey('expires', $v);
$this->assertArrayHasKey('expires_in', $v); $this->assertArrayHasKey('expires_in', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']); $this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']); $this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
} }
} }

View File

@ -412,8 +412,8 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires', $v); $this->assertArrayHasKey('expires', $v);
$this->assertArrayHasKey('expires_in', $v); $this->assertArrayHasKey('expires_in', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']); $this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']); $this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
} }
function test_issueAccessToken_passwordGrant() function test_issueAccessToken_passwordGrant()
@ -457,8 +457,8 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires', $v); $this->assertArrayHasKey('expires', $v);
$this->assertArrayHasKey('expires_in', $v); $this->assertArrayHasKey('expires_in', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']); $this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']); $this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
} }
function test_issueAccessToken_passwordGrant_customExpiresIn() function test_issueAccessToken_passwordGrant_customExpiresIn()
@ -483,7 +483,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$a = $this->returnDefault(); $a = $this->returnDefault();
$pgrant = new OAuth2\Grant\Password($a); $pgrant = new OAuth2\Grant\Password($a);
$pgrant->setVerifyCredentialsCallback($testCredentials); $pgrant->setVerifyCredentialsCallback($testCredentials);
$pgrant->setExpiresIn(30); $pgrant->setAccessTokenTTL(30);
$a->addGrantType($pgrant); $a->addGrantType($pgrant);
$a->requireScopeParam(false); $a->requireScopeParam(false);
@ -503,8 +503,8 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires', $v); $this->assertArrayHasKey('expires', $v);
$this->assertArrayHasKey('expires_in', $v); $this->assertArrayHasKey('expires_in', $v);
$this->assertNotEquals($a->getExpiresIn(), $v['expires_in']); $this->assertNotEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertNotEquals(time()+$a->getExpiresIn(), $v['expires']); $this->assertNotEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
$this->assertEquals(30, $v['expires_in']); $this->assertEquals(30, $v['expires_in']);
$this->assertEquals(time()+30, $v['expires']); $this->assertEquals(time()+30, $v['expires']);
} }
@ -552,8 +552,8 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires_in', $v); $this->assertArrayHasKey('expires_in', $v);
$this->assertArrayHasKey('refresh_token', $v); $this->assertArrayHasKey('refresh_token', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']); $this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']); $this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
} }
} }

View File

@ -56,8 +56,8 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires_in', $v); $this->assertArrayHasKey('expires_in', $v);
$this->assertArrayHasKey('refresh_token', $v); $this->assertArrayHasKey('refresh_token', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']); $this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']); $this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
} }
/** /**
@ -198,8 +198,8 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires_in', $v); $this->assertArrayHasKey('expires_in', $v);
$this->assertArrayHasKey('refresh_token', $v); $this->assertArrayHasKey('refresh_token', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']); $this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']); $this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
} }
public function test_issueAccessToken_refreshTokenGrant() public function test_issueAccessToken_refreshTokenGrant()
@ -237,8 +237,8 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires_in', $v); $this->assertArrayHasKey('expires_in', $v);
$this->assertArrayHasKey('refresh_token', $v); $this->assertArrayHasKey('refresh_token', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']); $this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']); $this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
} }
public function test_issueAccessToken_refreshTokenGrant_customExpiresIn() public function test_issueAccessToken_refreshTokenGrant_customExpiresIn()
@ -262,7 +262,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$a = $this->returnDefault(); $a = $this->returnDefault();
$grant = new OAuth2\Grant\RefreshToken($a); $grant = new OAuth2\Grant\RefreshToken($a);
$grant->setExpiresIn(30); $grant->setAccessTokenTTL(30);
$a->addGrantType($grant); $a->addGrantType($grant);
$v = $a->issueAccessToken(array( $v = $a->issueAccessToken(array(
@ -278,8 +278,8 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires_in', $v); $this->assertArrayHasKey('expires_in', $v);
$this->assertArrayHasKey('refresh_token', $v); $this->assertArrayHasKey('refresh_token', $v);
$this->assertNotEquals($a->getExpiresIn(), $v['expires_in']); $this->assertNotEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertNotEquals(time()+$a->getExpiresIn(), $v['expires']); $this->assertNotEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
$this->assertEquals(30, $v['expires_in']); $this->assertEquals(30, $v['expires_in']);
$this->assertEquals(time()+30, $v['expires']); $this->assertEquals(time()+30, $v['expires']);
} }