diff --git a/src/OAuth2/Grant/AuthCode.php b/src/OAuth2/Grant/AuthCode.php index 4433bf56..a4afc834 100644 --- a/src/OAuth2/Grant/AuthCode.php +++ b/src/OAuth2/Grant/AuthCode.php @@ -48,6 +48,12 @@ class AuthCode implements GrantTypeInterface { */ protected $accessTokenTTL = null; + /** + * The TTL of the auth token + * @var integer + */ + protected $authTokenTTL = 600; + /** * Constructor * @param AuthServer $authServer AuthServer instance @@ -86,6 +92,16 @@ class AuthCode implements GrantTypeInterface { $this->accessTokenTTL = $accessTokenTTL; } + /** + * Override the default access token expire time + * @param int $authTokenTTL + * @return void + */ + public function setAuthTokenTTL($authTokenTTL) + { + $this->authTokenTTL = $authTokenTTL; + } + /** * Check authorise parameters * @@ -187,7 +203,7 @@ class AuthCode implements GrantTypeInterface { $this->authServer->getStorage('session')->associateRedirectUri($sessionId, $authParams['redirect_uri']); // Associate the auth code - $this->authServer->getStorage('session')->associateAuthCode($sessionId, $authCode, time()+600, implode(',', $scopeIds)); + $this->authServer->getStorage('session')->associateAuthCode($sessionId, $authCode, time() + $this->authTokenTTL, implode(',', $scopeIds)); return $authCode; }