10 changed files with 89 additions and 112 deletions
@ -1,71 +0,0 @@
@@ -1,71 +0,0 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace DoctrineMigrations; |
||||
|
||||
use Doctrine\DBAL\Schema\Schema; |
||||
use Doctrine\Migrations\AbstractMigration; |
||||
|
||||
/** |
||||
* Auto-generated Migration: Please modify to your needs! |
||||
*/ |
||||
final class Version20250729102713 extends AbstractMigration |
||||
{ |
||||
public function getDescription(): string |
||||
{ |
||||
return ''; |
||||
} |
||||
|
||||
public function up(Schema $schema): void |
||||
{ |
||||
// this up() migration is auto-generated, please modify it to your needs |
||||
$this->addSql(<<<'SQL' |
||||
CREATE TABLE app_user (id INT AUTO_INCREMENT NOT NULL, npub VARCHAR(255) NOT NULL, roles JSON DEFAULT NULL, UNIQUE INDEX UNIQ_88BDF3E95FB8BABB (npub), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 |
||||
SQL); |
||||
$this->addSql(<<<'SQL' |
||||
CREATE TABLE article (id INT AUTO_INCREMENT NOT NULL, raw JSON DEFAULT NULL, event_id VARCHAR(225) DEFAULT NULL, slug LONGTEXT DEFAULT NULL, content LONGTEXT DEFAULT NULL, kind INT DEFAULT NULL, title LONGTEXT DEFAULT NULL, summary LONGTEXT DEFAULT NULL, pubkey VARCHAR(255) NOT NULL, created_at DATETIME DEFAULT NULL, sig VARCHAR(255) NOT NULL, image LONGTEXT DEFAULT NULL, published_at DATETIME DEFAULT NULL, topics JSON DEFAULT NULL, event_status INT DEFAULT NULL, current_places JSON DEFAULT NULL, rating_negative INT DEFAULT NULL, rating_positive INT DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 |
||||
SQL); |
||||
$this->addSql(<<<'SQL' |
||||
CREATE TABLE event (id VARCHAR(225) NOT NULL, event_id VARCHAR(225) DEFAULT NULL, kind INT NOT NULL, pubkey VARCHAR(255) NOT NULL, content LONGTEXT NOT NULL, created_at BIGINT NOT NULL, tags JSON NOT NULL, sig VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 |
||||
SQL); |
||||
$this->addSql(<<<'SQL' |
||||
CREATE TABLE nzine (id INT AUTO_INCREMENT NOT NULL, npub VARCHAR(255) NOT NULL, main_categories JSON NOT NULL, lists JSON DEFAULT NULL, editor VARCHAR(255) DEFAULT NULL, slug LONGTEXT DEFAULT NULL, state VARCHAR(255) NOT NULL, nzine_bot_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_65025D9871FD5427 (nzine_bot_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 |
||||
SQL); |
||||
$this->addSql(<<<'SQL' |
||||
CREATE TABLE nzine_bot (id INT AUTO_INCREMENT NOT NULL, encrypted_nsec VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 |
||||
SQL); |
||||
$this->addSql(<<<'SQL' |
||||
CREATE TABLE sessions (sess_id VARBINARY(128) NOT NULL, sess_data LONGBLOB NOT NULL, sess_lifetime INT UNSIGNED NOT NULL, sess_time INT UNSIGNED NOT NULL, INDEX sess_lifetime_idx (sess_lifetime), PRIMARY KEY(sess_id)) DEFAULT CHARACTER SET utf8mb4 ENGINE = InnoDB |
||||
SQL); |
||||
$this->addSql(<<<'SQL' |
||||
ALTER TABLE nzine ADD CONSTRAINT FK_65025D9871FD5427 FOREIGN KEY (nzine_bot_id) REFERENCES nzine_bot (id) |
||||
SQL); |
||||
} |
||||
|
||||
public function down(Schema $schema): void |
||||
{ |
||||
// this down() migration is auto-generated, please modify it to your needs |
||||
$this->addSql(<<<'SQL' |
||||
ALTER TABLE nzine DROP FOREIGN KEY FK_65025D9871FD5427 |
||||
SQL); |
||||
$this->addSql(<<<'SQL' |
||||
DROP TABLE app_user |
||||
SQL); |
||||
$this->addSql(<<<'SQL' |
||||
DROP TABLE article |
||||
SQL); |
||||
$this->addSql(<<<'SQL' |
||||
DROP TABLE event |
||||
SQL); |
||||
$this->addSql(<<<'SQL' |
||||
DROP TABLE nzine |
||||
SQL); |
||||
$this->addSql(<<<'SQL' |
||||
DROP TABLE nzine_bot |
||||
SQL); |
||||
$this->addSql(<<<'SQL' |
||||
DROP TABLE sessions |
||||
SQL); |
||||
} |
||||
} |
||||
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace DoctrineMigrations; |
||||
|
||||
use Doctrine\DBAL\Schema\Schema; |
||||
use Doctrine\Migrations\AbstractMigration; |
||||
|
||||
/** |
||||
* Auto-generated Migration: Please modify to your needs! |
||||
*/ |
||||
final class Version20250729122617 extends AbstractMigration |
||||
{ |
||||
public function getDescription(): string |
||||
{ |
||||
return ''; |
||||
} |
||||
|
||||
public function up(Schema $schema): void |
||||
{ |
||||
// this up() migration is auto-generated, please modify it to your needs |
||||
$this->addSql('CREATE TABLE app_user (id INT NOT NULL, npub VARCHAR(255) NOT NULL, roles JSON DEFAULT NULL, UNIQUE INDEX UNIQ_88BDF3E95FB8BABB (npub), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4'); |
||||
$this->addSql('CREATE TABLE article (id INT NOT NULL, raw JSON DEFAULT NULL, event_id VARCHAR(225) DEFAULT NULL, slug LONGTEXT DEFAULT NULL, content LONGTEXT DEFAULT NULL, kind INT DEFAULT NULL, title LONGTEXT DEFAULT NULL, summary LONGTEXT DEFAULT NULL, pubkey VARCHAR(255) NOT NULL, created_at DATETIME DEFAULT NULL, sig VARCHAR(255) NOT NULL, image LONGTEXT DEFAULT NULL, published_at DATETIME DEFAULT NULL, topics JSON DEFAULT NULL, event_status INT DEFAULT NULL, current_places JSON DEFAULT NULL, rating_negative INT DEFAULT NULL, rating_positive INT DEFAULT NULL, PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4'); |
||||
$this->addSql('CREATE TABLE event (id VARCHAR(225) NOT NULL, event_id VARCHAR(225) DEFAULT NULL, kind INT NOT NULL, pubkey VARCHAR(255) NOT NULL, content LONGTEXT NOT NULL, created_at BIGINT NOT NULL, tags JSON NOT NULL, sig VARCHAR(255) NOT NULL, PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4'); |
||||
$this->addSql('CREATE TABLE sessions (sess_id VARBINARY(128) NOT NULL, sess_data LONGBLOB NOT NULL, sess_lifetime INT UNSIGNED NOT NULL, sess_time INT UNSIGNED NOT NULL, INDEX sess_lifetime_idx (sess_lifetime), PRIMARY KEY (sess_id)) DEFAULT CHARACTER SET utf8mb4 ENGINE = InnoDB'); |
||||
} |
||||
|
||||
public function down(Schema $schema): void |
||||
{ |
||||
// this down() migration is auto-generated, please modify it to your needs |
||||
$this->addSql('DROP TABLE app_user'); |
||||
$this->addSql('DROP TABLE article'); |
||||
$this->addSql('DROP TABLE event'); |
||||
$this->addSql('DROP TABLE sessions'); |
||||
} |
||||
} |
||||
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace DoctrineMigrations; |
||||
|
||||
use Doctrine\DBAL\Schema\Schema; |
||||
use Doctrine\Migrations\AbstractMigration; |
||||
|
||||
/** |
||||
* Auto-generated Migration: Please modify to your needs! |
||||
*/ |
||||
final class Version20250729122903 extends AbstractMigration |
||||
{ |
||||
public function getDescription(): string |
||||
{ |
||||
return ''; |
||||
} |
||||
|
||||
public function up(Schema $schema): void |
||||
{ |
||||
// this up() migration is auto-generated, please modify it to your needs |
||||
$this->addSql('ALTER TABLE app_user CHANGE id id INT AUTO_INCREMENT NOT NULL'); |
||||
$this->addSql('ALTER TABLE article CHANGE id id INT AUTO_INCREMENT NOT NULL'); |
||||
} |
||||
|
||||
public function down(Schema $schema): void |
||||
{ |
||||
// this down() migration is auto-generated, please modify it to your needs |
||||
$this->addSql('ALTER TABLE app_user CHANGE id id INT NOT NULL'); |
||||
$this->addSql('ALTER TABLE article CHANGE id id INT NOT NULL'); |
||||
} |
||||
} |
||||
@ -1,36 +0,0 @@
@@ -1,36 +0,0 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace App\Service; |
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; |
||||
use Symfony\Component\HttpFoundation\Response; |
||||
use Symfony\Component\Routing\Attribute\Route; |
||||
|
||||
class EncryptionService |
||||
{ |
||||
private string $encryptionKey; |
||||
|
||||
public function __construct(ParameterBagInterface $bag) |
||||
{ |
||||
// Retrieve the symmetric encryption key securely from Symfony Secrets |
||||
$this->encryptionKey = $bag->get('encryption_key'); |
||||
} |
||||
|
||||
public function encrypt(string $data): string |
||||
{ |
||||
return openssl_encrypt($data, 'aes-256-cbc', $this->encryptionKey, 0, $this->getIv()); |
||||
} |
||||
|
||||
public function decrypt(string $encryptedData): string |
||||
{ |
||||
return openssl_decrypt($encryptedData, 'aes-256-cbc', $this->encryptionKey, 0, $this->getIv()); |
||||
} |
||||
|
||||
private function getIv(): string |
||||
{ |
||||
return substr(hash('sha256', $this->encryptionKey), 0, 16); // AES-256 requires a 16-byte IV |
||||
} |
||||
} |
||||
Loading…
Reference in new issue