secrecy/secrecy

This package is abandoned and no longer maintained. No replacement package was suggested.

A secret manager for php that supports a number of adapters

0.1.0 2020-02-13 21:40 UTC

This package is auto-updated.

Last update: 2021-07-01 00:12:18 UTC


README

CI Action codecov Scrutinizer Code Quality

Secrecy is a secret management abstraction that allows you to easily swap out different adapters based on configuration.

Goals

  • 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

Installation

 composer require secrecy/secrecy

Usage

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'));

Caching

The SecretManager and its adapters does not cache any data, this must be done at the framework integration layer.