0

Is there any way to set the database information in the app/etc/env.php in encrypted form

For examples

  array (
          'indexer' => 
          array (
            'host' => 'localhost',
            'dbname' => 'dbname',
            'username' => 'encryptedUserName',
            'password' => 'encryptedUserpassword',
            'active' => '1',
            'persistent' => NULL,
          ),
          'default' => 
          array (
            'host' => 'localhost',
             'dbname' => 'dbname',
            'username' => 'encryptedUserName',
            'password' => 'encryptedUserpassword',
            'active' => '1',
          ),
        ),

Thank You!

Abbas

0

Solution 1

We need to implement the following steps

Step 1:

Set the value in the encrypted form in app/etc/env.php

Step 2:

Override the class vendor/magento/framework/App/ResourceConnection.php and decrypt the values in the function getConnectionByName

Solution 2:

Set the values using base64_decode.

array (
        'host' => 'localhost',
        'dbname' => 'databasename',
        'username' => base64_decode('encoded user name'),
        'password' => base64_decode('encoded password'),
        'active' => '1',
        'persistent' => NULL,
      ),
| improve this answer | |
  • The above mentioned steps to override ResourceConnection is not working, have you tried in your system, if yes can you share that code ? – Keyur Patel Mar 29 '19 at 13:45
  • Yes I have tried and it is working. – Abbas Apr 1 '19 at 7:28
  • It's not working for me, it's showing error in adapter class of zend framework. vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php – Keyur Patel Apr 1 '19 at 9:12
  • Can you share customized codebase ? – Keyur Patel Apr 1 '19 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.