Secrecy is a secret management abstraction that allows you to easily swap out different adapters based on configuration.
- Promote explicit separation of configuration data and sensitive credentials
- Provide support for popular secret management services
- Provide seamless integration with popular frameworks
- Make it easy to manage your application secrets
composer require secrecy/secrecy
Below is an example of using the JsonFileAdapter
create a secrets.json
file in the root of your project
{
"secrets" : {
"DB_USER": "root",
"DB_PASSWORD": "f4x3!33s@",
"API_KEY": "SOME_SUPER_SECRET_KEY"
}
}
require 'vendor/autoload.php';
use Secrecy\SecretManager;
use Secrecy\Adapter\JsonFileAdapter;
$secretManager = new SecretManager(
new JsonFileAdapter(__DIR__.'/secrets.json')
);
// Get a list of all secrets
print_r($secretManager->list());
// Retrieve a single by name
print_r($secretManager->get('API_KEY'));
// Update an existing secret
print_r($secretManager->update('DB_USER', 'app_user'));
// Create a new secret
print_r($secretManager->create('APP_SECRET', 'SHH'));
The SecretManager
and its adapters does not cache any data, this must be done at the framework integration layer.