From 655b74cf90220fd44dde064e97ea26ccb6a85d8a Mon Sep 17 00:00:00 2001 From: Janos Miko Date: Mon, 20 Mar 2023 09:17:46 +0100 Subject: [PATCH] add support for magento 2.4.6+ --disable-tfa --- CHANGELOG.md | 6 +++++ VERSION.txt | 2 +- internal/logic/bootstrapMagento2.go | 42 +++++++++++++++++++++-------- sonar-project.properties | 2 +- 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ec5b4ba..082e30c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.4.6] - 2023-03-20 + +### Added + +- Above Magento 2.4.6 when you run `reward bootstrap` with `--disable-tfa` flag Reward will also disable Adobe IMS. + ## [0.4.5] - 2023-03-08 ### Fixed diff --git a/VERSION.txt b/VERSION.txt index 04a04894..68aa5c5c 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -v0.4.5 \ No newline at end of file +v0.4.6 \ No newline at end of file diff --git a/internal/logic/bootstrapMagento2.go b/internal/logic/bootstrapMagento2.go index 7833e0fe..131e24f1 100644 --- a/internal/logic/bootstrapMagento2.go +++ b/internal/logic/bootstrapMagento2.go @@ -13,8 +13,12 @@ import ( // bootstrapMagento2 runs a full Magento 2 bootstrap process. func (c *bootstrapper) bootstrapMagento2() error { - if !util.AskForConfirmation(fmt.Sprintf("Would you like to bootstrap Magento v%s?", - c.magento2Version().String())) { + if !util.AskForConfirmation( + fmt.Sprintf( + "Would you like to bootstrap Magento v%s?", + c.magento2Version().String(), + ), + ) { return nil } @@ -148,8 +152,12 @@ func (c *bootstrapper) installMagento2(freshInstall bool) (string, error) { func (c *bootstrapper) installMagento2SetupInstall() error { log.Println("Running Magento setup:install...") - err := c.RunCmdEnvExec(fmt.Sprintf("bin/magento setup:install %s", - strings.Join(c.buildMagento2InstallCommand(), " "))) + err := c.RunCmdEnvExec( + fmt.Sprintf( + "bin/magento setup:install %s", + strings.Join(c.buildMagento2InstallCommand(), " "), + ), + ) if err != nil { return fmt.Errorf("cannot run bin/magento setup:install: %w", err) } @@ -252,12 +260,20 @@ func (c *bootstrapper) installMagento2ConfigureAdminUser() (string, error) { func (c *bootstrapper) installMagento2ConfigureTFA() error { minimumMagentoVersionForMFA := version.Must(version.NewVersion("2.4.0")) + // For Magento 2.4.6 and above, we need to disable the Adobe IMS module as well + minimumMagentoVersionForMFAAdminAdobeImsTwoFactorAuth := version.Must(version.NewVersion("2.4.6")) + if c.magento2Version().GreaterThan(minimumMagentoVersionForMFA) && c.MagentoDisableTFA() { log.Println("Disabling TFA for local development...") - err := c.RunCmdEnvExec("bin/magento module:disable Magento_TwoFactorAuth") + modules := "Magento_TwoFactorAuth" + if c.magento2Version().GreaterThanOrEqual(minimumMagentoVersionForMFAAdminAdobeImsTwoFactorAuth) { + modules += " Magento_AdminAdobeImsTwoFactorAuth" + } + + err := c.RunCmdEnvExec("bin/magento module:disable " + modules) if err != nil { - return fmt.Errorf("cannot run bin/magento module:disable Magento_TwoFactorAuth: %w", err) + return fmt.Errorf("cannot run bin/magento module:disable %v: %w", modules, err) } log.Println("...TFA disabled.") @@ -270,8 +286,9 @@ func (c *bootstrapper) installMagento2DeploySampleData(freshInstall bool) error if freshInstall && (c.WithSampleData() || c.FullBootstrap()) { log.Println("Installing sample data...") - err := c.RunCmdEnvExec("mkdir -p /var/www/html/var/composer_home/ && " + - "cp -va ~/.composer/auth.json /var/www/html/var/composer_home/auth.json", + err := c.RunCmdEnvExec( + "mkdir -p /var/www/html/var/composer_home/ && " + + "cp -va ~/.composer/auth.json /var/www/html/var/composer_home/auth.json", ) if err != nil { return fmt.Errorf("cannot copy auth.json: %w", err) @@ -316,7 +333,8 @@ func (c *bootstrapper) installMagento2ConfigureSearch() error { if c.magento2Version().GreaterThan(c.minimumMagento2VersionForSearch()) { err = c.RunCmdEnvExec( - fmt.Sprintf("bin/magento config:set --lock-env catalog/search/engine %s", + fmt.Sprintf( + "bin/magento config:set --lock-env catalog/search/engine %s", searchEngine, ), ) @@ -474,7 +492,8 @@ func (c *bootstrapper) buildMagento2InstallCommand() []string { // Redis configuration if c.ServiceEnabled("redis") { - magentoCmdParams = append(magentoCmdParams, + magentoCmdParams = append( + magentoCmdParams, "--session-save=redis", "--session-save-redis-host=redis", "--session-save-redis-port=6379", @@ -500,7 +519,8 @@ func (c *bootstrapper) buildMagento2InstallCommand() []string { // RabbitMQ configuration if c.ServiceEnabled("rabbitmq") { - magentoCmdParams = append(magentoCmdParams, + magentoCmdParams = append( + magentoCmdParams, "--amqp-host=rabbitmq", "--amqp-port=5672", "--amqp-user=guest", diff --git a/sonar-project.properties b/sonar-project.properties index 333aba94..2cd2397c 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -3,7 +3,7 @@ sonar.organization=rewardenv # This is the name and version displayed in the SonarCloud UI. sonar.projectName=reward -sonar.projectVersion=0.4.5 +sonar.projectVersion=0.4.6 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. #sonar.sources=.