mirror of
https://github.com/elyby/accounts.git
synced 2024-12-26 15:10:22 +05:30
Подменены все ключевые сущности на наши
This commit is contained in:
parent
5f07834f45
commit
4f259a9dc7
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace api\components\OAuth2\Entities;
|
namespace api\components\OAuth2\Entities;
|
||||||
|
|
||||||
use League\OAuth2\Server\Entity\SessionEntity;
|
use League\OAuth2\Server\Entity\SessionEntity as OriginalSessionEntity;
|
||||||
|
|
||||||
class AuthCodeEntity extends \League\OAuth2\Server\Entity\AuthCodeEntity {
|
class AuthCodeEntity extends \League\OAuth2\Server\Entity\AuthCodeEntity {
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ class AuthCodeEntity extends \League\OAuth2\Server\Entity\AuthCodeEntity {
|
|||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
* @return static
|
* @return static
|
||||||
*/
|
*/
|
||||||
public function setSession(SessionEntity $session) {
|
public function setSession(OriginalSessionEntity $session) {
|
||||||
parent::setSession($session);
|
parent::setSession($session);
|
||||||
$this->sessionId = $session->getId();
|
$this->sessionId = $session->getId();
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace api\components\OAuth2\Entities;
|
namespace api\components\OAuth2\Entities;
|
||||||
|
|
||||||
use League\OAuth2\Server\Entity\ClientEntity;
|
use League\OAuth2\Server\Entity\ClientEntity as OriginalClientEntity;
|
||||||
use League\OAuth2\Server\Entity\EntityTrait;
|
use League\OAuth2\Server\Entity\EntityTrait;
|
||||||
|
|
||||||
class SessionEntity extends \League\OAuth2\Server\Entity\SessionEntity {
|
class SessionEntity extends \League\OAuth2\Server\Entity\SessionEntity {
|
||||||
@ -13,11 +13,7 @@ class SessionEntity extends \League\OAuth2\Server\Entity\SessionEntity {
|
|||||||
return $this->clientId;
|
return $this->clientId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function associateClient(OriginalClientEntity $client) {
|
||||||
* @inheritdoc
|
|
||||||
* @return static
|
|
||||||
*/
|
|
||||||
public function associateClient(ClientEntity $client) {
|
|
||||||
parent::associateClient($client);
|
parent::associateClient($client);
|
||||||
$this->clientId = $client->getId();
|
$this->clientId = $client->getId();
|
||||||
|
|
||||||
|
20
api/components/OAuth2/Grants/AuthCodeGrant.php
Normal file
20
api/components/OAuth2/Grants/AuthCodeGrant.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
namespace api\components\OAuth2\Grants;
|
||||||
|
|
||||||
|
use api\components\OAuth2\Entities;
|
||||||
|
|
||||||
|
class AuthCodeGrant extends \League\OAuth2\Server\Grant\AuthCodeGrant {
|
||||||
|
|
||||||
|
protected function createAccessTokenEntity() {
|
||||||
|
return new Entities\AccessTokenEntity($this->server);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createRefreshTokenEntity() {
|
||||||
|
return new Entities\RefreshTokenEntity($this->server);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createSessionEntity() {
|
||||||
|
return new Entities\SessionEntity($this->server);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
22
api/components/OAuth2/Grants/RefreshTokenGrant.php
Normal file
22
api/components/OAuth2/Grants/RefreshTokenGrant.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
namespace api\components\OAuth2\Grants;
|
||||||
|
|
||||||
|
use api\components\OAuth2\Entities;
|
||||||
|
|
||||||
|
class RefreshTokenGrant extends \League\OAuth2\Server\Grant\RefreshTokenGrant {
|
||||||
|
|
||||||
|
public $refreshTokenRotate = false;
|
||||||
|
|
||||||
|
protected function createAccessTokenEntity() {
|
||||||
|
return new Entities\AccessTokenEntity($this->server);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createRefreshTokenEntity() {
|
||||||
|
return new Entities\RefreshTokenEntity($this->server);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createSessionEntity() {
|
||||||
|
return new Entities\SessionEntity($this->server);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
$params = array_merge(
|
$params = array_merge(
|
||||||
require(__DIR__ . '/../../common/config/params.php'),
|
require __DIR__ . '/../../common/config/params.php',
|
||||||
require(__DIR__ . '/params.php')
|
require __DIR__ . '/params.php'
|
||||||
);
|
);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@ -65,6 +65,10 @@ return [
|
|||||||
'oauth' => [
|
'oauth' => [
|
||||||
'class' => api\components\OAuth2\Component::class,
|
'class' => api\components\OAuth2\Component::class,
|
||||||
'grantTypes' => ['authorization_code'],
|
'grantTypes' => ['authorization_code'],
|
||||||
|
'grantMap' => [
|
||||||
|
'authorization_code' => api\components\OAuth2\Grants\AuthCodeGrant::class,
|
||||||
|
'refresh_token' => api\components\OAuth2\Grants\RefreshTokenGrant::class,
|
||||||
|
],
|
||||||
],
|
],
|
||||||
'errorHandler' => [
|
'errorHandler' => [
|
||||||
'class' => api\components\ErrorHandler::class,
|
'class' => api\components\ErrorHandler::class,
|
||||||
|
@ -8,7 +8,6 @@ use common\models\Account;
|
|||||||
use common\models\OauthClient;
|
use common\models\OauthClient;
|
||||||
use common\models\OauthScope;
|
use common\models\OauthScope;
|
||||||
use League\OAuth2\Server\Exception\OAuthException;
|
use League\OAuth2\Server\Exception\OAuthException;
|
||||||
use League\OAuth2\Server\Grant\RefreshTokenGrant;
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\filters\AccessControl;
|
use yii\filters\AccessControl;
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
@ -195,8 +194,8 @@ class OauthController extends Controller {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$grant = new RefreshTokenGrant();
|
$grantClass = Yii::$app->oauth->grantMap['refresh_token'];
|
||||||
$grant->setRefreshTokenRotation(false);
|
$grant = new $grantClass;
|
||||||
|
|
||||||
$this->getServer()->addGrantType($grant);
|
$this->getServer()->addGrantType($grant);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
"yiisoft/yii2": "2.0.9",
|
"yiisoft/yii2": "2.0.9",
|
||||||
"yiisoft/yii2-swiftmailer": "*",
|
"yiisoft/yii2-swiftmailer": "*",
|
||||||
"ramsey/uuid": "^3.5.0",
|
"ramsey/uuid": "^3.5.0",
|
||||||
"league/oauth2-server": "dev-improvements#546dbfe85ae7c049cf9266281d228afe8bdd3ef6",
|
"league/oauth2-server": "dev-improvements#b9277ccd664dcb80a766b73674d21de686cb9dda",
|
||||||
"yiisoft/yii2-redis": "~2.0.0",
|
"yiisoft/yii2-redis": "~2.0.0",
|
||||||
"guzzlehttp/guzzle": "^6.0.0",
|
"guzzlehttp/guzzle": "^6.0.0",
|
||||||
"php-amqplib/php-amqplib": "^2.6.2",
|
"php-amqplib/php-amqplib": "^2.6.2",
|
||||||
|
Loading…
Reference in New Issue
Block a user