Ecrypted Secrets Management
Description
Encryption based feature to manage secrets.
Steps
1. Generate keys to encrypt/decrypt secret
Uses libsodium[fn:libsodium] and public key cryptography.
php bin/console secrets:generate-keys
2. Upload private key
Upload the private key to your remote server using SSH or any other safe means and store it in the same config/secrets/ directory.
3. Create a new secret to store the contents
php bin/console secrets:set DATABASE_URL
[OK] Secret “DATABASE_URL” encrypted in “config/secrets/dev/”
you can commit it.
Using secret
Use this new secret as any other normal env var in your configuration files and Symfony will decrypt the value transparently when needed.
config/packages/doctrine.yaml
doctrine:
dbal:
url: “%env(DATABASE_URL)%”
# …
Footnotes
[fn:libsodium]https://download.libsodium.org/doc/