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)
* @var integer
*/
protected $expiresIn = 3600;
protected $accessTokenTTL = 3600;
/**
* The registered grant response types
@@ -349,16 +349,16 @@ class AuthServer
* Get the TTL for an access token
* @return int The TTL
*/
public function getExpiresIn()
public function getAccessTokenTTL()
{
return $this->expiresIn;
return $this->accessTokenTTL;
}
/**
* Set the TTL for an access token
* @param int $accessTokenTTL The new TTL
*/
public function setAcessTokenTTL($accessTokenTTL)
public function setAccessTokenTTL($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
$accessToken = SecureKey::make();
$accessTokenExpiresIn = ($this->accessTokenTTL !== null) ? $this->accessTokenTTL : $this->authServer->getExpiresIn();
$accessTokenExpiresIn = ($this->accessTokenTTL !== null) ? $this->accessTokenTTL : $this->authServer->getAccessTokenTTL();
$accessTokenExpires = time() + $accessTokenExpiresIn;
// Remove the auth code

View File

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

View File

@@ -84,7 +84,7 @@ class Implict implements GrantTypeInterface {
$accessToken = SecureKey::make();
// Compute expiry time
$accessTokenExpires = time() + $this->authServer->getExpiresIn();
$accessTokenExpires = time() + $this->authServer->getAccessTokenTTL();
// Create a new session
$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
$accessToken = SecureKey::make();
$accessTokenExpiresIn = ($this->accessTokenTTL !== null) ? $this->accessTokenTTL : $this->authServer->getExpiresIn();
$accessTokenExpiresIn = ($this->accessTokenTTL !== null) ? $this->accessTokenTTL : $this->authServer->getAccessTokenTTL();
$accessTokenExpires = time() + $accessTokenExpiresIn;
// 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
$accessToken = SecureKey::make();
$accessTokenExpiresIn = ($this->accessTokenTTL !== null) ? $this->accessTokenTTL : $this->authServer->getExpiresIn();
$accessTokenExpiresIn = ($this->accessTokenTTL !== null) ? $this->accessTokenTTL : $this->authServer->getAccessTokenTTL();
$accessTokenExpires = time() + $accessTokenExpiresIn;
$refreshToken = SecureKey::make();
$refreshTokenExpires = time() + $this->getRefreshTokenTTL();

View File

@@ -152,14 +152,14 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->assertTrue($v);
}
public function test_getExpiresIn()
public function test_getAccessTokenTTL()
{
$a = $this->returnDefault();
$a->setExpiresIn(7200);
$this->assertEquals(7200, $a->getExpiresIn());
$a->setAccessTokenTTL(7200);
$this->assertEquals(7200, $a->getAccessTokenTTL());
}
public function test_setExpiresIn()
public function test_setAccessTokenTTL()
{
$a = $this->returnDefault();
$a->setScopeDelimeter(';');
@@ -382,8 +382,8 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires', $v);
$this->assertArrayHasKey('expires_in', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']);
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
}
public function test_issueAccessToken()
@@ -419,8 +419,8 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires', $v);
$this->assertArrayHasKey('expires_in', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']);
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
}
public function test_issueAccessToken_customExpiresIn()
@@ -439,7 +439,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$a = $this->returnDefault();
$grant = new OAuth2\Grant\AuthCode($a);
$grant->setExpiresIn(30);
$grant->setAccessTokenTTL(30);
$a->addGrantType($grant);
$_POST['grant_type'] = 'authorization_code';
@@ -458,8 +458,8 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires', $v);
$this->assertArrayHasKey('expires_in', $v);
$this->assertNotEquals($a->getExpiresIn(), $v['expires_in']);
$this->assertNotEquals(time()+$a->getExpiresIn(), $v['expires']);
$this->assertNotEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertNotEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
$this->assertEquals(30, $v['expires_in']);
$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_in', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']);
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
}
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_in', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']);
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
}
function test_issueAccessToken_clientCredentialsGrant()
@@ -276,8 +276,8 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires', $v);
$this->assertArrayHasKey('expires_in', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']);
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
}
function test_issueAccessToken_clientCredentialsGrant_customExpiresIn()
@@ -298,7 +298,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$a = $this->returnDefault();
$grant = new OAuth2\Grant\ClientCredentials($a);
$grant->setExpiresIn(30);
$grant->setAccessTokenTTL(30);
$a->addGrantType($grant);
$a->requireScopeParam(false);
@@ -316,8 +316,8 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires', $v);
$this->assertArrayHasKey('expires_in', $v);
$this->assertNotEquals($a->getExpiresIn(), $v['expires_in']);
$this->assertNotEquals(time()+$a->getExpiresIn(), $v['expires']);
$this->assertNotEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertNotEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
$this->assertEquals(30, $v['expires_in']);
$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_in', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']);
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$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_in', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']);
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
}
function test_issueAccessToken_passwordGrant()
@@ -457,8 +457,8 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires', $v);
$this->assertArrayHasKey('expires_in', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']);
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
}
function test_issueAccessToken_passwordGrant_customExpiresIn()
@@ -483,7 +483,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$a = $this->returnDefault();
$pgrant = new OAuth2\Grant\Password($a);
$pgrant->setVerifyCredentialsCallback($testCredentials);
$pgrant->setExpiresIn(30);
$pgrant->setAccessTokenTTL(30);
$a->addGrantType($pgrant);
$a->requireScopeParam(false);
@@ -503,8 +503,8 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires', $v);
$this->assertArrayHasKey('expires_in', $v);
$this->assertNotEquals($a->getExpiresIn(), $v['expires_in']);
$this->assertNotEquals(time()+$a->getExpiresIn(), $v['expires']);
$this->assertNotEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertNotEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
$this->assertEquals(30, $v['expires_in']);
$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('refresh_token', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']);
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$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('refresh_token', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']);
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$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('refresh_token', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']);
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
}
public function test_issueAccessToken_refreshTokenGrant()
@@ -237,8 +237,8 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires_in', $v);
$this->assertArrayHasKey('refresh_token', $v);
$this->assertEquals($a->getExpiresIn(), $v['expires_in']);
$this->assertEquals(time()+$a->getExpiresIn(), $v['expires']);
$this->assertEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
}
public function test_issueAccessToken_refreshTokenGrant_customExpiresIn()
@@ -262,7 +262,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$a = $this->returnDefault();
$grant = new OAuth2\Grant\RefreshToken($a);
$grant->setExpiresIn(30);
$grant->setAccessTokenTTL(30);
$a->addGrantType($grant);
$v = $a->issueAccessToken(array(
@@ -278,8 +278,8 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->assertArrayHasKey('expires_in', $v);
$this->assertArrayHasKey('refresh_token', $v);
$this->assertNotEquals($a->getExpiresIn(), $v['expires_in']);
$this->assertNotEquals(time()+$a->getExpiresIn(), $v['expires']);
$this->assertNotEquals($a->getAccessTokenTTL(), $v['expires_in']);
$this->assertNotEquals(time()+$a->getAccessTokenTTL(), $v['expires']);
$this->assertEquals(30, $v['expires_in']);
$this->assertEquals(time()+30, $v['expires']);
}