From 9f90cd2635c00e13cbb213c52ec76d71906a516a Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Tue, 7 May 2013 15:20:32 -0700 Subject: [PATCH] Added method to set the auth token TTL --- src/OAuth2/Grant/AuthCode.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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; }