承接 violet88/silverstripe-vault 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

violet88/silverstripe-vault

最新稳定版本:v2.0.0

Composer 安装命令:

composer require violet88/silverstripe-vault

包简介

A SilverStripe module for encrypting and decrypting data using the HashiCorp Vault API

README 文档

README

This module provides a way to store sensitive data securely using the Vault service (specifically the Transit API).

Requirements

Installation

Install the module using composer.

composer require violet88/silverstripe-vault

Configuration

Vault

The module requires transit to be enabled on the Vault server. The following policy can be used to enable transit.

path "transit/*" {
    capabilities = ["create", "read", "update", "delete", "list", "sudo"]
}

The transit engine can be enabled using the following command.

vault secrets enable transit

SilverStripe

Configuration File

The module requires a Vault server to be configured. The server can be configured in the vault.yml file.

---
name: vault
---
Violet88/VaultModule/VaultClient:
    vault_token: # Vault Authorization Token
    vault_url: # Vault URL
    vault_transit_path: # Transit Path, defaults to 'transit'

Additionally, a default key can be configured in the vault.yml file.

Violet88/VaultModule/VaultKey:
    name: # Key Name
    type: # Key Type, e.g. aes256-gcm96

If no key is configured, the module will use the following defaults.

Violet88/VaultModule/VaultKey:
    name: "silverstripe"
    type: "aes256-gcm96"

Keys will be created automatically if they do not exist, be sure to set Vault permissions accordingly.

Environment Variables

Along with the vault.yml file, the module supports the following environment variables.

VAULT_TOKEN="s.1234567890abcdef"
VAULT_URL="https://vault.example.com"
VAULT_TRANSIT_PATH="transit"

Setting these environment variables will override the corresponding values set in the vault.yml file.

Usage

The module provides an Encrypted field type that automatically encrypts and decrypts data when it is saved and retrieved from the database.

<?php

class MyDataObject extends DataObject
{
    private static $db = [
        'MyEncryptedField' => 'Encrypted',
    ];
}

The datatype supports automatic casting, to use it simply pass the cast type as well as any of it's parameters.

<?php

class MyDataObject extends DataObject
{
    private static $db = [
        'MyEncryptedIntegerField' => 'Encrypted("Int")',
        'MyEncryptedEnumField' => 'Encrypted("Enum", "value1,value2,value3")',
    ];
}

Filtering

The module provides an EncryptedSearch that can be used to filter data by encrypted fields. Keep in mind that the filter will only return exact matches.

<?php

class MyDataObject extends DataObject
{
    private static $searchable_fields = [
        'MyEncryptedField' => 'EncryptedSearch',
    ];
}

Tasks

The module provides tasks for encrypting and decrypting all data and rotating the default key.

# Encrypt all data
vendor/bin/sake dev/tasks/EncryptDBTask
# Decrypt all data
vendor/bin/sake dev/tasks/DecryptDBTask
# Rotate keys
vendor/bin/sake dev/tasks/RotateKeyTask

Disclaimers

  • Violet88 is not responsible for any loss of data or other damages caused by the use of this module. Use at your own risk.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2024-01-02