35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use DateTimeImmutable;
|
|
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
|
|
use League\OAuth2\Server\Entities\Traits\AccessTokenTrait;
|
|
use League\OAuth2\Server\Entities\Traits\EntityTrait;
|
|
use League\OAuth2\Server\Entities\Traits\TokenEntityTrait;
|
|
|
|
|
|
final class AccessToken implements AccessTokenEntityInterface
|
|
{
|
|
use AccessTokenTrait;
|
|
use EntityTrait;
|
|
use TokenEntityTrait;
|
|
|
|
|
|
private function convertToJWT()
|
|
{
|
|
$this->initJwtConfiguration();
|
|
|
|
return $this->jwtConfiguration->builder()
|
|
->permittedFor($this->getClient()->getIdentifier())
|
|
->identifiedBy($this->getIdentifier())
|
|
->issuedAt(new DateTimeImmutable())
|
|
->canOnlyBeUsedAfter(new DateTimeImmutable())
|
|
->expiresAt($this->getExpiryDateTime())
|
|
->relatedTo((string) $this->getUserIdentifier())
|
|
->withClaim('scopes', $this->getScopes())
|
|
->withClaim('email', $this->getUserIdentifier())
|
|
->getToken($this->jwtConfiguration->signer(), $this->jwtConfiguration->signingKey());
|
|
}
|
|
|
|
} |