configurable refresh token TTL per grant

This commit is contained in:
Julián Gutiérrez
2016-01-21 18:11:53 +01:00
parent 44155a8efc
commit b85f81c429
6 changed files with 40 additions and 29 deletions

View File

@@ -80,6 +80,11 @@ abstract class AbstractGrant implements GrantTypeInterface
*/
protected $pathToPublicKey;
/**
* @var \DateInterval
*/
protected $refreshTokenTTL;
/**
* @param ClientRepositoryInterface $clientRepository
*/
@@ -128,6 +133,14 @@ abstract class AbstractGrant implements GrantTypeInterface
$this->emitter = $emitter;
}
/**
* @inheritdoc
*/
public function setRefreshTokenTTL(\DateInterval $refreshTokenTTL)
{
$this->refreshTokenTTL = $refreshTokenTTL;
}
/**
* {@inheritdoc}
*/
@@ -283,16 +296,15 @@ abstract class AbstractGrant implements GrantTypeInterface
}
/**
* @param \DateInterval $tokenTTL
* @param \League\OAuth2\Server\Entities\AccessTokenEntity $accessToken
*
* @return \League\OAuth2\Server\Entities\RefreshTokenEntity
*/
protected function issueRefreshToken(\DateInterval $tokenTTL, AccessTokenEntity $accessToken)
protected function issueRefreshToken(AccessTokenEntity $accessToken)
{
$refreshToken = new RefreshTokenEntity();
$refreshToken->setIdentifier(SecureKey::generate());
$refreshToken->setExpiryDateTime((new \DateTime())->add($tokenTTL));
$refreshToken->setExpiryDateTime((new \DateTime())->add($this->refreshTokenTTL));
$refreshToken->setAccessToken($accessToken);
return $refreshToken;