Update Implicit Grant Type with the following:

- Added accessTokenTTL variable and setter method
 - Updated response in the completeFlow method to include all required parameters per OAuth2 spec
 - completeFlow function accounts for local grant TTL override
This commit is contained in:
jlehner 2013-09-26 14:40:56 -04:00
parent 4a71c376b8
commit d3158a830b

View File

@ -42,6 +42,12 @@ class Implicit implements GrantTypeInterface {
*/
protected $authServer = null;
/**
* Access token expires in override
* @var int
*/
protected $accessTokenTTL = null;
/**
* Constructor
* @param Authorization $authServer Authorization server instance
@ -70,6 +76,16 @@ class Implicit implements GrantTypeInterface {
return $this->responseType;
}
/**
* Override the default access token expire time
* @param int $accessTokenTTL
* @return void
*/
public function setAccessTokenTTL($accessTokenTTL)
{
$this->accessTokenTTL = $accessTokenTTL;
}
/**
* Complete the client credentials grant
* @param null|array $inputParams
@ -84,7 +100,8 @@ class Implicit implements GrantTypeInterface {
$accessToken = SecureKey::make();
// Compute expiry time
$accessTokenExpires = time() + $this->authServer->getAccessTokenTTL();
$accessTokenExpiresIn = ($this->accessTokenTTL !== null) ? $this->accessTokenTTL : $this->authServer->getAccessTokenTTL();
$accessTokenExpires = time() + $accessTokenExpiresIn;
// Create a new session
$sessionId = $this->authServer->getStorage('session')->createSession($authParams['client_id'], 'user', $authParams['user_id']);
@ -98,7 +115,10 @@ class Implicit implements GrantTypeInterface {
}
$response = array(
'access_token' => $accessToken
'access_token' => $accessToken,
'token_type' => 'Bearer',
'expires' => $accessTokenExpires,
'expires_in' => $accessTokenExpiresIn,
);
return $response;