mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Исправлено поведение при обновлении устаревшего токена
Обновлена логика в компонентах для работы с ключами redis
This commit is contained in:
10
api/components/OAuth2/Entities/RefreshTokenEntity.php
Normal file
10
api/components/OAuth2/Entities/RefreshTokenEntity.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace api\components\OAuth2\Entities;
|
||||
|
||||
class RefreshTokenEntity extends \League\OAuth2\Server\Entity\RefreshTokenEntity {
|
||||
|
||||
public function isExpired() : bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@@ -19,7 +19,7 @@ class AuthCodeStorage extends AbstractStorage implements AuthCodeInterface {
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get($code) {
|
||||
$result = (new Key($this->dataTable, $code))->getValue();
|
||||
$result = json_decode((new Key($this->dataTable, $code))->getValue(), true);
|
||||
if (!$result) {
|
||||
return null;
|
||||
}
|
||||
|
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
namespace api\components\OAuth2\Storage;
|
||||
|
||||
use api\components\OAuth2\Entities\RefreshTokenEntity;
|
||||
use common\components\Redis\Key;
|
||||
use League\OAuth2\Server\Entity\RefreshTokenEntity;
|
||||
use League\OAuth2\Server\Entity\RefreshTokenEntity as OriginalRefreshTokenEntity;
|
||||
use League\OAuth2\Server\Storage\AbstractStorage;
|
||||
use League\OAuth2\Server\Storage\RefreshTokenInterface;
|
||||
|
||||
@@ -14,14 +15,13 @@ class RefreshTokenStorage extends AbstractStorage implements RefreshTokenInterfa
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get($token) {
|
||||
$result = (new Key($this->dataTable, $token))->getValue();
|
||||
$result = json_decode((new Key($this->dataTable, $token))->getValue(), true);
|
||||
if (!$result) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$entity = new RefreshTokenEntity($this->server);
|
||||
$entity->setId($result['id']);
|
||||
$entity->setExpireTime($result['expire_time']);
|
||||
$entity->setAccessTokenId($result['access_token_id']);
|
||||
|
||||
return $entity;
|
||||
@@ -33,7 +33,6 @@ class RefreshTokenStorage extends AbstractStorage implements RefreshTokenInterfa
|
||||
public function create($token, $expireTime, $accessToken) {
|
||||
$payload = [
|
||||
'id' => $token,
|
||||
'expire_time' => $expireTime,
|
||||
'access_token_id' => $accessToken,
|
||||
];
|
||||
|
||||
@@ -43,7 +42,7 @@ class RefreshTokenStorage extends AbstractStorage implements RefreshTokenInterfa
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function delete(RefreshTokenEntity $token) {
|
||||
public function delete(OriginalRefreshTokenEntity $token) {
|
||||
(new Key($this->dataTable, $token->getId()))->delete();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user