mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-08-01 06:01:42 +00:00
Make OAuth connection grants configurable
This commit is contained in:
parent
28023c9828
commit
aa5edae4d9
15 changed files with 1370 additions and 13 deletions
81
migrations/Version20260727143622.php
Normal file
81
migrations/Version20260727143622.php
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use App\Migration\AbstractMultiPlatformMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
final class Version20260727143622 extends AbstractMultiPlatformMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add oauth_client_grant_preferences (per user+client OAuth2 consent preferences: granted scope level, friendly name, refresh token TTL)';
|
||||
}
|
||||
|
||||
public function mySQLUp(Schema $schema): void
|
||||
{
|
||||
$this->addSql(<<<'SQL'
|
||||
CREATE TABLE oauth_client_grant_preferences (
|
||||
id INT AUTO_INCREMENT NOT NULL,
|
||||
user_identifier VARCHAR(128) NOT NULL,
|
||||
client_identifier VARCHAR(32) NOT NULL,
|
||||
scope_level SMALLINT NOT NULL,
|
||||
friendly_name VARCHAR(255) DEFAULT NULL,
|
||||
refresh_token_ttl_days INT DEFAULT NULL,
|
||||
last_used_at DATETIME DEFAULT NULL,
|
||||
UNIQUE INDEX oauth_client_grant_pref_user_client (user_identifier, client_identifier),
|
||||
PRIMARY KEY (id)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci`
|
||||
SQL);
|
||||
}
|
||||
|
||||
public function mySQLDown(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP TABLE oauth_client_grant_preferences');
|
||||
}
|
||||
|
||||
public function sqLiteUp(Schema $schema): void
|
||||
{
|
||||
$this->addSql(<<<'SQL'
|
||||
CREATE TABLE oauth_client_grant_preferences (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
user_identifier VARCHAR(128) NOT NULL,
|
||||
client_identifier VARCHAR(32) NOT NULL,
|
||||
scope_level SMALLINT NOT NULL,
|
||||
friendly_name VARCHAR(255) DEFAULT NULL,
|
||||
refresh_token_ttl_days INTEGER DEFAULT NULL,
|
||||
last_used_at DATETIME DEFAULT NULL
|
||||
)
|
||||
SQL);
|
||||
$this->addSql('CREATE UNIQUE INDEX oauth_client_grant_pref_user_client ON oauth_client_grant_preferences (user_identifier, client_identifier)');
|
||||
}
|
||||
|
||||
public function sqLiteDown(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP TABLE oauth_client_grant_preferences');
|
||||
}
|
||||
|
||||
public function postgreSQLUp(Schema $schema): void
|
||||
{
|
||||
$this->addSql(<<<'SQL'
|
||||
CREATE TABLE oauth_client_grant_preferences (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
|
||||
user_identifier VARCHAR(128) NOT NULL,
|
||||
client_identifier VARCHAR(32) NOT NULL,
|
||||
scope_level SMALLINT NOT NULL,
|
||||
friendly_name VARCHAR(255) DEFAULT NULL,
|
||||
refresh_token_ttl_days INT DEFAULT NULL,
|
||||
last_used_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL,
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
SQL);
|
||||
$this->addSql('CREATE UNIQUE INDEX oauth_client_grant_pref_user_client ON oauth_client_grant_preferences (user_identifier, client_identifier)');
|
||||
}
|
||||
|
||||
public function postgreSQLDown(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP TABLE oauth_client_grant_preferences');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue