TappNetwork / laravel-aws-secrets-manager

Manage environment secrets using AWS Secrets Manager.
MIT License
33 stars 20 forks source link

APP_KEY being nullified when cached #24

Closed therecluse26 closed 2 years ago

therecluse26 commented 2 years ago

Hi, when I implement this package, my app encryption key gets nullified when caching (the APP_KEY variable is set properly in .env). It appears, however that other keys in my .env file are still working, just that specific one is failing.

This is before adding the package (after caching)

successful_encryption_no_library

This is after installing the package and caching again (note the successful test environment variable) unsuccessful_encryption_with_library

therecluse26 commented 2 years ago

Nevermind, I noticed that this is being intentionally overwritten in the library code under the variables-config block of the configuration. Commenting out the APP_KEY line fixed it. This should maybe be called out in the README, because I'm assuming I'm not the only one who would run into this, particularly when using it on a multi-instance application.

In config/aws-secrets-manager.php

'variables-config' => [
  // This is what was nullifying the APP_KEY before.
  // I'm assuming the idea is that you'd have a shared encryption key stored in Secrets Manager.
  // This doesn't work for every app architecture, so it would be helpful to document.
  //
  // 'APP_KEY' => 'app.key',
],