mollie / magento2

Mollie Payments for Magento 2
https://www.mollie.com
Other
98 stars 50 forks source link

Not possible to store API key in env.php #618

Closed okolya closed 1 year ago

okolya commented 1 year ago

Describe the bug When API key is stored in env.php then validation throw the error after updating configuration

An API key must start with 'test_' or 'live_' and must be at least 30 characters long

Used versions

To Reproduce Steps to reproduce the behavior:

  1. add API key with CLI and store it in env.php bin/magento config:set --lock-env payment/mollie_general/apikey_test test_XXXXXXXXXXXXXXX
  2. value is encrypted in env.php and does not contains test_ string anymore
  3. update Magento config using CLI command bin/magento app:conf:import
  4. See error An API key must start with 'test_' or 'live_' and must be at least 30 characters long

Expected behavior It is possible to keep encrypted API key in env.php .

Frank-Magmodules commented 1 year ago

HI There @okolya , 

Thanks for opening this issue. Are there any more steps involved in this? We tried to reproduce this but on a fresh Magento 2 installation this seems to work fine.

norgeindian commented 1 year ago

We're facing the exact same issue and actually it should be reproducible exactly like @okolya wrote in my eyes.

Frank-Magmodules commented 1 year ago

Hello @norgeindian and @okolya, would it be possible for us to review the details with you to ensure that we have the correct information for debugging and, of course, resolving this issue? Your assistance would be greatly appreciated. If you are willing to help, please contact us directly so we can proceed debugging this together.

Frank-Magmodules commented 1 year ago

Hi there @okolya and @norgeindian , 

We wanted to let you know that we have made some changes to the logic in the affected part of the plugin, although we were not able to reproduce the issue directly.

We kindly request that you try out the latest release to check if the problem still persists. If you need any further assistance, please don't hesitate to let us know. We look forward to hearing back from you.

t-heuser commented 1 year ago

Hey, we also have the same problem and we're using the newest version v2.24.1. Just updated from v2.21.1 to it yesterday and since then we have the issue.

norgeindian commented 1 year ago

I just updated to 2.24.1 and for me, it works since then.

Frank-Magmodules commented 1 year ago

Hello @oneserv-heuser, I would like to inquire if this issue is still persisting for you. According to @norgeindian, the issue has been resolved with the latest release. Please let me know if the issue is still present so that we can investigate it further or if it has been resolved, we can proceed to close the issue.

t-heuser commented 1 year ago

Hi @Frank-Magmodules, we just updated to 2.25.0 and everything works as intended! Thank you.

Frank-Magmodules commented 1 year ago

Great, @oneserv-heuser! Thank you for confirming and being patient here. Closing this issue for now.

t-heuser commented 1 year ago

@Frank-Magmodules Unfortunately it's not working as I thought. On our local development systems everything was fine, so we thought that the error is gone. But as soon as we pushed the update to our test environment it broke. We're still getting the error that @okolya described when execting a grapqhl-request that includes mollie. The errror also occurs when testing the API-key in the adminhtml.

This is the output of the API-key test on our test env: image

This is the output of the test on our local dev env: image

As you can see we're using the same encrypted api key, on both environments they are written to the env.php and imported via the bin/magento app:config:import. With v2.21.1 everything was fine but as soon as updating to v2.24.1 or v2.25.0 the error occurs (on the test system).

Also have a look at the screenshot from the API-key test when using v2.21.1: image

As you can see the module is able to determine that the key starts with test or live. Since 2.24.0 (where u started to use the magento mechanism for encrypting and decrypting the api keys) the module is not able to decrypt the key as supposed. Even if the graphql requests are working you can see in my first screenshot that it says The current value starts with 0:3:T... which is the encrypted value.

norgeindian commented 1 year ago

@oneserv-heuser, we actually had similar issues in the beginning. But adding the keys again in the admin area and saving the configuration solved it in our case.

MarianNapi commented 1 year ago

@norgeindian

But adding the keys again in the admin area and saving the configuration solved it in our case.

As far as I know this also changes the hashed key in the env.php right? So you would have to update the new hash in every system

norgeindian commented 1 year ago

Well, as long as you have the stored keys in the env.php, you should not be able to adapt anything at all in the admin area, as far as I know. So what I did was, if I remember correctly, to comment out the keys in the env.php, saving them in the admin area, adding the keys again in the file and running setup:upgrade. Could you maybe try that process?