PHP icon indicating copy to clipboard operation
PHP copied to clipboard

Fixed Flutterwave sdk: ENCRYPTION_KEY environment variable missing, after creating a custom environmental variable and bootstraping.

Open leonardosahon opened this issue 1 year ago • 3 comments

When a custom env variable is created, the bootstrap method was still trying to find the default env keys.

With this new addition, if a user has used the PackageConfig::setUp method already to set their custom env variables, bootstrap would not have assume self::$config is not set again.

Version: flutterwavedev/flutterwave-v3 : 1.0.6

Error Message Screenshot 2024-02-01 at 7 46 42 PM

This has already been done from my code. Screenshot 2024-02-01 at 7 47 10 PM

leonardosahon avatar Feb 01 '24 18:02 leonardosahon

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
4465424 Triggered Generic High Entropy Secret e8dfd50fa8c697d475b134aea101f2682519bb3b assets/js/v3.js View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

gitguardian[bot] avatar Feb 01 '24 18:02 gitguardian[bot]

Hi @leonardosahon

if you are using composer, the implementation should work just fine.

use \Flutterwave\Flutterwave;

use \Flutterwave\Config\PackageConfig;

$myConfig = PackageConfig::setUp(
    'FLWSECK_TEST-XXXXXXXXXXXXXXXXXXXXXXXXXXX-X',
    'FLWPUBK_TEST-XXXXXXXXXXXXXXXXXXXXXXXXXXX-X',
    'FLWSECK_XXXXXXXXXXXXXXX',
    'staging'
); 

Flutterwave::bootstrap($myConfig);

Unless you are calling Flutterwave::bootstrap() again before or after it.

Abraham-Flutterwave avatar Feb 01 '24 22:02 Abraham-Flutterwave

Hi @leonardosahon

if you are using composer, the implementation should work just fine.

use \Flutterwave\Flutterwave;

use \Flutterwave\Config\PackageConfig;

$myConfig = PackageConfig::setUp(
    'FLWSECK_TEST-XXXXXXXXXXXXXXXXXXXXXXXXXXX-X',
    'FLWPUBK_TEST-XXXXXXXXXXXXXXXXXXXXXXXXXXX-X',
    'FLWSECK_XXXXXXXXXXXXXXX',
    'staging'
); 

Flutterwave::bootstrap($myConfig);

Unless you are calling Flutterwave::bootstrap() again before or after it.

These are my environmental variables:

FLUTTERWAVE_PUBLIC_KEY FLUTTERWAVE_SECRET_KEY FLUTTERWAVE_ENCRYPTION_KEY

If you check the screenshot, immediately after here:

Flutterwave::bootstrap(
      PackageConfig::setUp(
          $_ENV['FLUTTERWAVE_SECRET_KEY'],
          $_ENV['FLUTTERWAVE_PUBLIC_KEY'],
          $_ENV['FLUTTERWAVE_ENCRYPTION_KEY'],
          LayConfig::$ENV_IS_DEV ? "staging" : "production",
      )
  );

The next thing is new PaymentController, which calls Flutterwave::bootstrap() again, this time with an empty parameter, thereby rendering $config empty, meanwhile self::$config contains a value already.

This new call attempts to go back to the .env file, meanwhile, the values have been supplied through the PackageConfig::setUp already.

leonardosahon avatar Feb 02 '24 00:02 leonardosahon