Download the PHP package polokij/laravel-vault-env without Composer
On this page you can find all versions of the php package polokij/laravel-vault-env. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download polokij/laravel-vault-env
More information about polokij/laravel-vault-env
Files in polokij/laravel-vault-env
Package laravel-vault-env
Short Description Hashicorp Vault client for Laravel with possibility set the env variables from Vault secret dynamically
License MIT
Informations about the package laravel-vault-env
Laravel Hashicorp. Vault API client
This package provide the base features for Hashicorp Vault API.
Motivation
Developing my multi-tenant application using Laravel I've faced with lacking of the package which could fetch the env variables from vault and apply it on bootstrapping the application. Here it bref implementation of the required features:
- Vault API Client + Service + Facade
- artisan command to unseal the vault
- artisan command for create the secret engine
- Laravel bootstraper which apply the env variables fetched from Vault
Requirements
- Laravel 9+
- PHP 8+
Installation
Adding composer package
composer require polokij/laravel-vault-env
Setting up the .env variables
VAULT_ADDR=http://vault:8200
# Required is no VAULT_ADDR specified
VAULT_HOST=vault
VAULT_PORT=8200
VAULT_SCHEME=https
# The storage engine thich will be used by default kv2 or secrets, or whatewhere
VAULT_DEFAULT_ENGINE=kv2
# The prefix will be added to each key on put/get requests
VAULT_KEY_PREFIX=TenantRootPath
VAULT_TOKEN=
Publishing the config
php artisan vendor:publish --provider="LaravelVault\VaultServiceProvider"
Usage
- Unseal Vault using json
php artisan vault:unseal -f secret/file.json
- Unseal Vault using key as command arguments
php artisan vault:unseal $key
- Check the seal status
php artisan vault:unseal -s
- Create new secret storage
php artisan vault:storage create new_storage_name
- Access to Secrets
Bootstrap the application with dynamic env variables
Example for Multi-tenant application:
bootstrap/app.php `
Alternative way
To enable this feature override the array of bootstrappers on app/Console/Kernel.php and app/Http/Kernel.php files app/Console/Kernel.php
app/Http/Kernel.php
Performance
Under investigation ))
TODO
- [ ] Tests implementation
- [ ] Refactor the VaultClient to separate the methods by entrypoints to simplify the project development
License
The MIT License (MIT). Please see License File for more information.