Merge branch 'V5-WIP' into minor_merge

This commit is contained in:
Julián Gutiérrez
2016-02-12 00:12:56 +01:00
14 changed files with 108 additions and 173 deletions

View File

@@ -12,6 +12,7 @@
namespace League\OAuth2\Server\Grant;
use League\Event\EmitterAwareTrait;
use League\Event\EmitterInterface;
use League\Event\Event;
use League\OAuth2\Server\Entities\AccessTokenEntity;
use League\OAuth2\Server\Entities\Interfaces\ClientEntityInterface;
@@ -77,6 +78,11 @@ abstract class AbstractGrant implements GrantTypeInterface
*/
protected $pathToPublicKey;
/**
* @var \DateInterval
*/
protected $refreshTokenTTL;
/**
* @param ClientRepositoryInterface $clientRepository
*/
@@ -117,6 +123,22 @@ abstract class AbstractGrant implements GrantTypeInterface
$this->pathToPublicKey = $pathToPublicKey;
}
/**
* @inheritdoc
*/
public function setEmitter(EmitterInterface $emitter = null)
{
$this->emitter = $emitter;
}
/**
* @inheritdoc
*/
public function setRefreshTokenTTL(\DateInterval $refreshTokenTTL)
{
$this->refreshTokenTTL = $refreshTokenTTL;
}
/**
* {@inheritdoc}
*/
@@ -280,7 +302,7 @@ abstract class AbstractGrant implements GrantTypeInterface
{
$refreshToken = new RefreshTokenEntity();
$refreshToken->setIdentifier(SecureKey::generate());
$refreshToken->setExpiryDateTime((new \DateTime())->add(new \DateInterval('P1M')));
$refreshToken->setExpiryDateTime((new \DateTime())->add($this->refreshTokenTTL));
$refreshToken->setAccessToken($accessToken);
return $refreshToken;