mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-02 00:43:11 +05:30
Added issueAuthCode method
This commit is contained in:
parent
0b6bcad9fb
commit
c2c199cf98
@ -15,6 +15,7 @@ use League\Event\EmitterAwareTrait;
|
|||||||
use League\Event\EmitterInterface;
|
use League\Event\EmitterInterface;
|
||||||
use League\Event\Event;
|
use League\Event\Event;
|
||||||
use League\OAuth2\Server\Entities\AccessTokenEntity;
|
use League\OAuth2\Server\Entities\AccessTokenEntity;
|
||||||
|
use League\OAuth2\Server\Entities\AuthCodeEntity;
|
||||||
use League\OAuth2\Server\Entities\Interfaces\ClientEntityInterface;
|
use League\OAuth2\Server\Entities\Interfaces\ClientEntityInterface;
|
||||||
use League\OAuth2\Server\Entities\RefreshTokenEntity;
|
use League\OAuth2\Server\Entities\RefreshTokenEntity;
|
||||||
use League\OAuth2\Server\Entities\ScopeEntity;
|
use League\OAuth2\Server\Entities\ScopeEntity;
|
||||||
@ -321,6 +322,39 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
return $accessToken;
|
return $accessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Issue an auth code
|
||||||
|
*
|
||||||
|
* @param \DateInterval $tokenTTL
|
||||||
|
* @param \League\OAuth2\Server\Entities\Interfaces\ClientEntityInterface $client
|
||||||
|
* @param string $userIdentifier
|
||||||
|
* @param string $redirectUri
|
||||||
|
* @param array $scopes
|
||||||
|
*
|
||||||
|
* @return \League\OAuth2\Server\Entities\AuthCodeEntity
|
||||||
|
* @throws \League\OAuth2\Server\Exception\OAuthServerException
|
||||||
|
*/
|
||||||
|
protected function issueAuthCode(
|
||||||
|
\DateInterval $tokenTTL,
|
||||||
|
ClientEntityInterface $client,
|
||||||
|
$userIdentifier,
|
||||||
|
$redirectUri,
|
||||||
|
array $scopes = []
|
||||||
|
) {
|
||||||
|
$authCode = new AuthCodeEntity();
|
||||||
|
$authCode->setIdentifier(SecureKey::generate());
|
||||||
|
$authCode->setExpiryDateTime((new \DateTime())->add($tokenTTL));
|
||||||
|
$authCode->setClient($client);
|
||||||
|
$authCode->setUserIdentifier($userIdentifier);
|
||||||
|
$authCode->setRedirectUri($redirectUri);
|
||||||
|
|
||||||
|
foreach ($scopes as $scope) {
|
||||||
|
$authCode->addScope($scope);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $authCode;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \League\OAuth2\Server\Entities\AccessTokenEntity $accessToken
|
* @param \League\OAuth2\Server\Entities\AccessTokenEntity $accessToken
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user