mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Some progress [skip ci]
This commit is contained in:
@@ -6,6 +6,7 @@ namespace common\components\OAuth2;
|
||||
use Carbon\CarbonInterval;
|
||||
use DateInterval;
|
||||
use League\OAuth2\Server\AuthorizationServer;
|
||||
use League\OAuth2\Server\Grant\DeviceCodeGrant;
|
||||
use yii\base\Component as BaseComponent;
|
||||
|
||||
final class AuthorizationServerFactory extends BaseComponent {
|
||||
@@ -17,6 +18,7 @@ final class AuthorizationServerFactory extends BaseComponent {
|
||||
$internalScopesRepo = new Repositories\InternalScopeRepository();
|
||||
$authCodesRepo = new Repositories\AuthCodeRepository();
|
||||
$refreshTokensRepo = new Repositories\RefreshTokenRepository();
|
||||
$deviceCodesRepo = new Repositories\DeviceCodeRepository();
|
||||
|
||||
$accessTokenTTL = CarbonInterval::create(-1); // Set negative value to make tokens non expiring
|
||||
|
||||
@@ -42,6 +44,11 @@ final class AuthorizationServerFactory extends BaseComponent {
|
||||
$authServer->enableGrantType($clientCredentialsGrant, $accessTokenTTL);
|
||||
$clientCredentialsGrant->setScopeRepository($internalScopesRepo); // Change repository after enabling
|
||||
|
||||
// TODO: provide verification url
|
||||
$deviceCodeGrant = new DeviceCodeGrant($deviceCodesRepo, $refreshTokensRepo, new DateInterval('PT2M'), '');
|
||||
$authServer->enableGrantType($deviceCodeGrant, $accessTokenTTL);
|
||||
$deviceCodeGrant->setScopeRepository($publicScopesRepo); // Change repository after enabling
|
||||
|
||||
return $authServer;
|
||||
}
|
||||
|
||||
|
||||
16
common/components/OAuth2/Entities/DeviceCodeEntity.php
Normal file
16
common/components/OAuth2/Entities/DeviceCodeEntity.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace common\components\OAuth2\Entities;
|
||||
|
||||
use League\OAuth2\Server\Entities\DeviceCodeEntityInterface;
|
||||
use League\OAuth2\Server\Entities\Traits\DeviceCodeTrait;
|
||||
use League\OAuth2\Server\Entities\Traits\EntityTrait;
|
||||
use League\OAuth2\Server\Entities\Traits\TokenEntityTrait;
|
||||
|
||||
final class DeviceCodeEntity implements DeviceCodeEntityInterface {
|
||||
use EntityTrait;
|
||||
use TokenEntityTrait;
|
||||
use DeviceCodeTrait;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace common\components\OAuth2\Repositories;
|
||||
|
||||
use common\components\OAuth2\Entities\DeviceCodeEntity;
|
||||
use League\OAuth2\Server\Entities\DeviceCodeEntityInterface;
|
||||
use League\OAuth2\Server\Repositories\DeviceCodeRepositoryInterface;
|
||||
|
||||
final class DeviceCodeRepository implements DeviceCodeRepositoryInterface {
|
||||
|
||||
public function getNewDeviceCode(): DeviceCodeEntityInterface {
|
||||
return new DeviceCodeEntity();
|
||||
}
|
||||
|
||||
public function persistDeviceCode(DeviceCodeEntityInterface $deviceCodeEntity): void {
|
||||
// TODO: Implement persistDeviceCode() method.
|
||||
}
|
||||
|
||||
public function getDeviceCodeEntityByDeviceCode(string $deviceCodeEntity): ?DeviceCodeEntityInterface {
|
||||
// TODO: Implement getDeviceCodeEntityByDeviceCode() method.
|
||||
}
|
||||
|
||||
public function revokeDeviceCode(string $codeId): void {
|
||||
// TODO: Implement revokeDeviceCode() method.
|
||||
}
|
||||
|
||||
public function isDeviceCodeRevoked(string $codeId): bool {
|
||||
// TODO: Implement isDeviceCodeRevoked() method.
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
namespace common\models\amqp;
|
||||
|
||||
use yii\base\BaseObject;
|
||||
|
||||
class AccountBanned extends BaseObject {
|
||||
|
||||
public $accountId;
|
||||
|
||||
public $duration = -1;
|
||||
|
||||
public $message = '';
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
namespace common\models\amqp;
|
||||
|
||||
use yii\base\BaseObject;
|
||||
|
||||
class AccountPardoned extends BaseObject {
|
||||
|
||||
public $accountId;
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
namespace common\models\amqp;
|
||||
|
||||
use yii\base\BaseObject;
|
||||
|
||||
class EmailChanged extends BaseObject {
|
||||
|
||||
public $accountId;
|
||||
|
||||
public $oldEmail;
|
||||
|
||||
public $newEmail;
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
namespace common\models\amqp;
|
||||
|
||||
use yii\base\BaseObject;
|
||||
|
||||
class UsernameChanged extends BaseObject {
|
||||
|
||||
public $accountId;
|
||||
|
||||
public $oldUsername;
|
||||
|
||||
public $newUsername;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user