From 1294167edff39e7bedbbcbe4133f752d9b93db2b Mon Sep 17 00:00:00 2001 From: Ambroise Maupate Date: Fri, 15 Sep 2023 15:52:01 +0200 Subject: [PATCH] fix(User): Removed deprecated User salt column --- .env | 7 ---- docker-compose.yml | 11 +----- .../migrations/Version20230915134833.php | 31 ++++++++++++++++ lib/RoadizCoreBundle/src/Entity/User.php | 36 +++---------------- .../src/Exception/EmptySaltException.php | 12 ------- .../src/Repository/EntityRepository.php | 1 - 6 files changed, 37 insertions(+), 61 deletions(-) create mode 100644 lib/RoadizCoreBundle/migrations/Version20230915134833.php delete mode 100644 lib/RoadizCoreBundle/src/Exception/EmptySaltException.php diff --git a/.env b/.env index a44bd1fc..e7b49a30 100644 --- a/.env +++ b/.env @@ -70,13 +70,6 @@ IR_DRIVER=gd MESSENGER_TRANSPORT_DSN=redis://redis:6379/messages ###< symfony/messenger ### -# blackfire.io -BLACKFIRE_LOG_LEVEL=4 -BLACKFIRE_SERVER_ID= -BLACKFIRE_SERVER_TOKEN= -BLACKFIRE_CLIENT_ID= -BLACKFIRE_CLIENT_TOKEN= - TRUSTED_PROXIES=127.0.0.1,172.19.0.1,172.19.0.2,REMOTE_ADDR ###> sentry/sentry-symfony ### diff --git a/docker-compose.yml b/docker-compose.yml index a2aa1221..8e4fd89a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -52,6 +52,7 @@ services: environment: MYSQL_RANDOM_ROOT_PASSWORD: 1 MYSQL_DATABASE: db_name + MYSQL_HOST: db MYSQL_USER: db_user MYSQL_PASSWORD: db_password links: @@ -197,16 +198,6 @@ services: - "traefik.http.routers.${APP_NAMESPACE}_secure.tls=true" - "traefik.http.routers.${APP_NAMESPACE}_secure.service=${APP_NAMESPACE}" - blackfire: - image: blackfire/blackfire - environment: - # Exposes BLACKFIRE_* environment variables from the host - BLACKFIRE_LOG_LEVEL: ${BLACKFIRE_LOG_LEVEL} - BLACKFIRE_SERVER_ID: ${BLACKFIRE_SERVER_ID} - BLACKFIRE_SERVER_TOKEN: ${BLACKFIRE_SERVER_TOKEN} - BLACKFIRE_CLIENT_ID: ${BLACKFIRE_CLIENT_ID} - BLACKFIRE_CLIENT_TOKEN: ${BLACKFIRE_CLIENT_TOKEN} - mailer: image: mailhog/mailhog ports: diff --git a/lib/RoadizCoreBundle/migrations/Version20230915134833.php b/lib/RoadizCoreBundle/migrations/Version20230915134833.php new file mode 100644 index 00000000..0697ebf3 --- /dev/null +++ b/lib/RoadizCoreBundle/migrations/Version20230915134833.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE users DROP salt'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE users ADD salt VARCHAR(64) NOT NULL'); + } +} diff --git a/lib/RoadizCoreBundle/src/Entity/User.php b/lib/RoadizCoreBundle/src/Entity/User.php index c70f1556..094d7e82 100644 --- a/lib/RoadizCoreBundle/src/Entity/User.php +++ b/lib/RoadizCoreBundle/src/Entity/User.php @@ -10,16 +10,15 @@ use JMS\Serializer\Annotation as Serializer; use Rollerworks\Component\PasswordStrength\Validator\Constraints\PasswordStrength; use RZ\Roadiz\Core\AbstractEntities\AbstractHuman; +use RZ\Roadiz\CoreBundle\Form\Constraint\ValidFacebookName; use RZ\Roadiz\CoreBundle\Repository\UserRepository; use RZ\Roadiz\CoreBundle\Security\User\AdvancedUserInterface; -use RZ\Roadiz\Random\SaltGenerator; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Security\Core\User\EquatableInterface; use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Serializer\Annotation as SymfonySerializer; use Symfony\Component\Validator\Constraints as Assert; -use RZ\Roadiz\CoreBundle\Form\Constraint\ValidFacebookName; #[ ORM\Entity(repositoryClass: UserRepository::class), @@ -121,15 +120,6 @@ class User extends AbstractHuman implements UserInterface, AdvancedUserInterface #[Assert\Length(max: 200)] private string $username = ''; - /** - * The salt to use for hashing. - */ - #[ORM\Column(name: 'salt', type: 'string', length: 64)] - #[SymfonySerializer\Ignore] - #[Serializer\Exclude] - #[Assert\Length(max: 64)] - private string $salt = ''; - /** * Encrypted password. */ @@ -239,9 +229,6 @@ public function __construct() $this->groups = new ArrayCollection(); $this->sendCreationConfirmationEmail(false); $this->initAbstractDateTimed(); - - $saltGenerator = new SaltGenerator(); - $this->setSalt($saltGenerator->generateSalt()); } /** @@ -361,17 +348,7 @@ public function setPictureUrl(?string $pictureUrl): User */ public function getSalt(): ?string { - return $this->salt; - } - - /** - * @param string $salt - * @return $this - */ - public function setSalt(string $salt): User - { - $this->salt = $salt; - return $this; + return null; } /** @@ -881,8 +858,8 @@ public function __serialize(): array { return [ $this->password, - $this->salt, $this->username, + $this->getSalt(), $this->enabled, $this->id, $this->email, @@ -898,10 +875,11 @@ public function __serialize(): array public function __unserialize(array $data): void { + $salt = null; [ $this->password, - $this->salt, $this->username, + $salt, $this->enabled, $this->id, $this->email, @@ -968,10 +946,6 @@ public function isEqualTo(UserInterface $user): bool return false; } - if ($this->getSalt() !== $user->getSalt()) { - return false; - } - if ($this->getUsername() !== $user->getUsername()) { return false; } diff --git a/lib/RoadizCoreBundle/src/Exception/EmptySaltException.php b/lib/RoadizCoreBundle/src/Exception/EmptySaltException.php deleted file mode 100644 index 8ebc655b..00000000 --- a/lib/RoadizCoreBundle/src/Exception/EmptySaltException.php +++ /dev/null @@ -1,12 +0,0 @@ -