定制 paradisesecurity/secrets-manager 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

paradisesecurity/secrets-manager

Composer 安装命令:

composer require paradisesecurity/secrets-manager

包简介

Secrets management in PHP applications.

README 文档

README

A modern, flexible secrets management library for PHP applications with a fluent builder API and multiple storage backends.

License PHP Version

Features

  • Fluent Builder API - Intuitive, chainable methods for configuration
  • Multiple Storage Backends - File-based and environment-based key storage
  • Secure Encryption - Built on Halite/libsodium for authenticated encryption
  • Vault Management - Organize secrets into isolated vaults
  • Key Rotation - Generate and manage cryptographic keys with ease
  • File & Message Encryption - Encrypt data of any size
  • Zero Configuration - Sensible defaults with full customization

Installation

composer require paradisesecurity/secrets-manager

Quick Start

Basic Usage

use ParadiseSecurity\Component\SecretsManager\Builder\SecretsManagerBuilder;
use ParadiseSecurity\Component\SecretsManager\Key\Key;
use ParagonIE\HiddenString\HiddenString;

// Create authentication key
$authKey = new Key(
    new HiddenString('your-secure-auth-key'),
    'symmetric_authentication_key',
    'halite',
    '5.0.0'
);

// Build the secrets manager
$secretsManager = SecretsManagerBuilder::create()
    ->withAuthKey($authKey)
    ->withPaths('/path/to/project')
    ->withDefaultVault('production')
    ->configureStorage(fn($builder) => 
        $builder
            ->useMasterKeyStorage('env')
            ->withEnvFile('.env')
    )
    ->build();

// Create a vault
$secretsManager->newVault('production');

// Store secrets
$secretsManager->set('database_password', 'super_secret_password');
$secretsManager->set('api_key', 'sk-1234567890abcdef');

// Retrieve secrets
$dbPassword = $secretsManager->get('database_password');
$apiKey = $secretsManager->get('api_key');

Advanced Configuration

$secretsManager = SecretsManagerBuilder::create()
    ->withAuthKey($authKey)
    ->withKeyringName('production-keyring')
    ->withDefaultVault('app-secrets')
    ->withPaths('/var/www/project', '/var/www/project/config/secrets')
    ->configureEncryption(fn($builder) => 
        $builder->useAdapter('halite')
    )
    ->configureStorage(fn($builder) => 
        $builder
            ->useMasterKeyStorage('env')
            ->withEnvFile('.env.production')
    )
    ->configureVault(fn($builder) => 
        $builder->withCache(true, 'secrets-cache')
    )
    ->build();

Architecture

The Secrets Manager is built around a modular architecture with independent builders:

  • EncryptionBuilder - Configure encryption adapters and key generation
  • StorageBuilder - Manage filesystem paths and key storage mechanisms
  • VaultBuilder - Configure vault adapters with optional caching
  • KeyManagerBuilder - Coordinate key generation and management
  • SecretsManagerBuilder - Orchestrate all components into a unified API

Each builder can be used independently or composed together for full functionality.

Storage Options

File-Based Storage

Keys are stored as encrypted files in the filesystem:

$builder->configureStorage(fn($b) => 
    $b->useMasterKeyStorage('file')
);

Environment-Based Storage

Keys are stored in .env files for easy deployment:

$builder->configureStorage(fn($b) => 
    $b->useMasterKeyStorage('env')
      ->withEnvFile('.env.secrets')
);

Documentation

Comprehensive documentation is available in the docs folder:

Requirements

Development Status

⚠️ This library is currently in active development. APIs may change before the first stable release. Not recommended for production use yet.

Testing

composer install
vendor/bin/phpunit

Security

If you discover any security vulnerabilities, please email security@paradisesecurity.work instead of using the issue tracker.

License

This component is open-sourced software licensed under the MIT license.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Credits

Paradise Security - Building secure, decoupled PHP components with the highest quality code.

Paradise Security

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-01