2016-02-14 23:20:10 +05:30
|
|
|
<?php
|
2019-09-22 02:47:21 +05:30
|
|
|
declare(strict_types=1);
|
2016-02-14 23:20:10 +05:30
|
|
|
|
2019-09-22 02:47:21 +05:30
|
|
|
namespace api\components\OAuth2\Entities;
|
2016-02-14 23:20:10 +05:30
|
|
|
|
2019-09-22 02:47:21 +05:30
|
|
|
use api\components\Tokens\TokensFactory;
|
|
|
|
use League\OAuth2\Server\CryptKeyInterface;
|
|
|
|
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
|
|
|
|
use League\OAuth2\Server\Entities\Traits\EntityTrait;
|
|
|
|
use League\OAuth2\Server\Entities\Traits\TokenEntityTrait;
|
2016-02-14 23:20:10 +05:30
|
|
|
|
2019-09-22 02:47:21 +05:30
|
|
|
class AccessTokenEntity implements AccessTokenEntityInterface {
|
|
|
|
use EntityTrait;
|
|
|
|
use TokenEntityTrait {
|
|
|
|
getExpiryDateTime as parentGetExpiryDateTime;
|
2016-02-14 23:20:10 +05:30
|
|
|
}
|
|
|
|
|
2019-09-22 02:47:21 +05:30
|
|
|
public function __toString(): string {
|
|
|
|
// TODO: strip "offline_access" scope from the scopes list
|
|
|
|
return (string)TokensFactory::createForOAuthClient($this);
|
2016-11-30 04:49:14 +05:30
|
|
|
}
|
|
|
|
|
2019-09-22 02:47:21 +05:30
|
|
|
public function setPrivateKey(CryptKeyInterface $privateKey): void {
|
|
|
|
// We use a general-purpose component to build JWT tokens, so there is no need to keep the key
|
2016-02-14 23:20:10 +05:30
|
|
|
}
|
|
|
|
|
2019-09-22 02:47:21 +05:30
|
|
|
public function getExpiryDateTime() {
|
|
|
|
// TODO: extend token life depending on scopes list
|
|
|
|
return $this->parentGetExpiryDateTime();
|
2016-11-30 04:49:14 +05:30
|
|
|
}
|
|
|
|
|
2016-02-14 23:20:10 +05:30
|
|
|
}
|