芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/public_html/mctv/lib/OAuth/AccessTokenEntity.php
. */ namespace Xibo\OAuth; use Carbon\Carbon; use Lcobucci\JWT\Builder; use Lcobucci\JWT\Signer\Key; use Lcobucci\JWT\Signer\Rsa\Sha256; use Lcobucci\JWT\Token; use League\OAuth2\Server\CryptKey; 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; /** * Class AccessTokenEntity * @package Xibo\OAuth */ class AccessTokenEntity implements AccessTokenEntityInterface { use AccessTokenTrait, TokenEntityTrait, EntityTrait; /** * Generate a JWT from the access token * * @param CryptKey $privateKey * * @return Token */ private function convertToJWT(CryptKey $privateKey) { $userId = $this->getUserIdentifier(); return (new Builder()) ->issuedBy('info@xibosignage.com') ->permittedFor($this->getClient()->getIdentifier()) ->identifiedBy($this->getIdentifier()) ->issuedAt(Carbon::now()->toDateTimeImmutable()) ->canOnlyBeUsedAfter(Carbon::now()->toDateTimeImmutable()) ->expiresAt($this->getExpiryDateTime()) ->relatedTo($userId) ->withClaim('scopes', $this->getScopes()) ->getToken(new Sha256(), new Key($privateKey->getKeyPath())) ; } /** * Generate a string representation from the access token */ public function __toString() { return (string) $this->convertToJWT($this->privateKey); } }