-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(*): Encrypt enrollment key and fix composer conflict (#7)
* fix(cache): Add crowdsec/magento-symfony-cache possible dependency to avoid composer conflicts * test(end to end): Update tests for m2.3.7 * feat(enrollment): Encrypt enrollment key in database
- Loading branch information
1 parent
4dcff60
commit d2f6ee5
Showing
9 changed files
with
115 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CrowdSec\Engine\Setup\Patch\Data; | ||
|
||
use Magento\Framework\Setup\Patch\DataPatchInterface; | ||
use Magento\Framework\Encryption\EncryptorInterface; | ||
use Magento\Framework\Setup\ModuleDataSetupInterface; | ||
use CrowdSec\Engine\Helper\Config; | ||
|
||
class EncryptEnrollmentKey implements DataPatchInterface | ||
{ | ||
/** | ||
* @var EncryptorInterface | ||
*/ | ||
private $encryptor; | ||
|
||
/** | ||
* @var ModuleDataSetupInterface | ||
*/ | ||
private $moduleDataSetup; | ||
|
||
/** | ||
* Constructor method. | ||
* | ||
* @param EncryptorInterface $encryptor | ||
* @param ModuleDataSetupInterface $moduleDataSetup | ||
*/ | ||
public function __construct( | ||
EncryptorInterface $encryptor, | ||
ModuleDataSetupInterface $moduleDataSetup | ||
) { | ||
$this->encryptor = $encryptor; | ||
$this->moduleDataSetup = $moduleDataSetup; | ||
} | ||
|
||
/** | ||
* Apply patch. | ||
* | ||
* @return void | ||
*/ | ||
public function apply() | ||
{ | ||
$bouncerKeyPath = Config::XML_PATH_ENROLLMENT_KEY; | ||
$configTable = $this->moduleDataSetup->getTable('core_config_data'); | ||
$select = $this->moduleDataSetup->getConnection()->select() | ||
->from($configTable) | ||
->where('path = ?', $bouncerKeyPath); | ||
$config = $this->moduleDataSetup->getConnection()->fetchAll($select); | ||
if (!empty($config)) { | ||
$value = $config[0]['value'] ?? ''; | ||
if ($value) { | ||
$this->moduleDataSetup->getConnection()->update( | ||
$configTable, | ||
['value' => $this->encryptor->encrypt($value)], | ||
['path = ?' => $bouncerKeyPath] | ||
); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Retrieve dependencies. | ||
* | ||
* @return array|string[] | ||
*/ | ||
public static function getDependencies() | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* Retrieve aliases | ||
* | ||
* @return array|string[] | ||
*/ | ||
public function getAliases() | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters