Skip to content

Save encrypt values in the ENV file instead of plain text

Notifications You must be signed in to change notification settings

Rah1x/laravel-encrypted-env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 

Repository files navigation

laravel / encrypted-env

Save encrypt values in the ENV file instead of plain text

https://blog.fortrabbit.com/how-to-keep-a-secret

Case:

Encrypt values in the ENV file as it could potentially expose the server (as they are in plain text)

STEPS:

  1. new file: config/enc.php (holds enc keys)

  2. Create a new artisian command for encryption called “encrypt_this” at app/console/commands/ $> artisan make:command encrypt_this

  3. Get individual cyphers for all / specific env vars (as per need) via the new command; replace them in env file. For example $> php artisan encrypt 'xyz'

  4. Create a decrypt function env2() at **bootstrap/envApp.php **

  5. bootstrap/app.php (at the top): require_once 'envApp.php';

  6. change the env() calls for these specific env keys to the new method env2() instead.

About

Save encrypt values in the ENV file instead of plain text

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published