Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store config re-encrypt encrypted values on save #1223

Closed
bgkavinga opened this issue May 1, 2015 · 3 comments
Closed

Store config re-encrypt encrypted values on save #1223

bgkavinga opened this issue May 1, 2015 · 3 comments
Labels
bug report Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Progress: needs update

Comments

@bgkavinga
Copy link

I have created a store config with backend type obscure

<field id="password" translate="label" type="obscure" sortOrder="6" showInDefault="1" showInWebsite="1" showInStore="1">
    <label>Password</label>
     <comment>
              <![CDATA[In Sandbox mode, use your Sandbox password.]]>
      </comment>
       <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
</field>

There are some other configs on the same section. Each time I save this section it encrypt the old value. Since the old value is already encrypted it is encrypting encrypted value. No way to decrypt and get original data. According to my investigations the problem lies in the following code snippet in Magento\Config\Model\Config\Backend\Encrypted

/**
     * Encrypt value before saving
     *
     * @return void
     */
    public function beforeSave()
    {
        $value = (string)$this->getValue();
        // don't change value, if an obscured value came
        if (preg_match('/^\*+$/', $this->getValue())) {
            $value = $this->getOldValue();
        }
        if (!empty($value)) {
            $encrypted = $this->_encryptor->encrypt($value);
            if ($encrypted) {
                $this->setValue($encrypted);
            }
        }
    }
@anupdugar anupdugar added the PS label May 1, 2015
@anupdugar anupdugar self-assigned this May 1, 2015
@bgkavinga
Copy link
Author

Hello, Any update on this ? Is this true for you or it's happening just for me ? Am I doing any thing wrong here ?
Thanks
BG

@anupdugar
Copy link
Contributor

@bgkavinga Thanks for reporting this issue. After investigation it seems that the value is getting encrypted again, even if you don't make any changes, like you pointed out.
We have created a ticket internally - MAGETWO-36930 to track and fix this issue.

@anupdugar anupdugar added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report labels May 4, 2015
anupdugar added a commit that referenced this issue May 22, 2015
…ave #1223

- Fix to make sure values are not encrypted if not changed
- Removed re-encrypting values
- Added integration test
anupdugar added a commit that referenced this issue May 22, 2015
anupdugar added a commit that referenced this issue May 22, 2015
anupdugar added a commit that referenced this issue May 22, 2015
…ave #1223

- Removed unnecessary if condition since encrypted value is checked for empty earlier
@vpelipenko
Copy link
Contributor

@bgkavinga, fix is available from 0.74.0-beta10. If you still face with it, please, let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Progress: needs update
Projects
None yet
Development

No branches or pull requests

3 participants