feat: use custom entity class for OAuth2Clients with consented property
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
league_oauth2_server:
|
||||
client:
|
||||
classname: App\Entity\OAuth2Client
|
||||
authorization_server:
|
||||
private_key: '%env(resolve:OAUTH_PRIVATE_KEY)%'
|
||||
private_key_passphrase: '%env(resolve:OAUTH_PASSPHRASE)%'
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260413141741 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add is_consented column to oauth2_clients table';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE oauth2_client ADD is_consented TINYINT(1) NOT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE oauth2_client DROP is_consented');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use League\Bundle\OAuth2ServerBundle\Model\AbstractClient;
|
||||
|
||||
#[ORM\Entity()]
|
||||
class OAuth2Client extends AbstractClient
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: Types::STRING, length: 32)]
|
||||
protected string $identifier;
|
||||
|
||||
#[ORM\Column(type: Types::BOOLEAN)]
|
||||
private bool $isConsented = false;
|
||||
|
||||
/**
|
||||
* Returns true if the client can skip the consent page.
|
||||
*/
|
||||
public function isConsented(): bool
|
||||
{
|
||||
return $this->isConsented;
|
||||
}
|
||||
|
||||
public function setConsented(bool $isConsented): void
|
||||
{
|
||||
$this->isConsented = $isConsented;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user