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

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

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from

Conversation

leonardosahon
Copy link

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

corneliusyaovi and others added 8 commits November 22, 2022 15:04
Improve environment variable file detection on installation via composer
Performance Optimization and  Feature Update
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.
@leonardosahon leonardosahon changed the base branch from master to dev February 1, 2024 18:55
Copy link

gitguardian bot commented Feb 1, 2024

⚠️ 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 e8dfd50 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!

@Abraham-Flutterwave
Copy link
Contributor

Abraham-Flutterwave commented Feb 1, 2024

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.

@leonardosahon
Copy link
Author

leonardosahon commented Feb 2, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants