定制 itk-dev/vault-bundle 二次开发

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

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

itk-dev/vault-bundle

Composer 安装命令:

composer require itk-dev/vault-bundle

包简介

Symfony bundle for HashiCorp Vault

README 文档

README

Github Release PHP Version Build Status Read License Package downloads on Packagist

This bundle enables Symfony sites to interact with HashiCorp Vault using the "approle" authentication method. It allows fetching secrets and provides the capability for local caching of both access tokens and the secrets themselves.

The bundle offers a services wrapper for the PHP library itk-dev/vault-library. Additionally, it includes an environment variable processor, enabling the retrieval of secrets directly in .env files at runtime.

Install

composer require itk-dev/vault-bundle --no-scripts

Note

We use --no-scripts since the bundle config may not yet have been created.

Setup

Create a configuration file at config/packages/itkdev_vault.yaml and add the three referenced variables to .env with placeholder values. Then add the actual values to .env.local.

itkdev_vault:
  role_id: '%env(VAULT_ROLE_ID)%'
  secret_id: '%env(VAULT_SECRET_ID)%'
  url: '%env(VAULT_URL)%'

Usage

Use the service by simply injecting the service named Vault from the namespace ItkDev\VaultBundle\Service. Use the login function to fetch a token and then use the acquired token in the getSecret or getSecrets functions.

To use the environment variable processor, use the following format to specify what to retrieve from the vault:

MY_SECRET=<PATH>:<SECRET>:<KEY>:<VERSION>:<EXPIRE>
  • Path: The secret engine path (e.g. prod, stg, test)
  • Secret: Name of the secret in the engine (eg. itksites, dokk1)
  • Key: The secret key that should be fetched (eg. OIDC, pretix-api-key)
  • Version: Optional, fetch a specific version of the secret.
  • Expire: Optional, the number of seconds to cache the secret.

When the variable have been defined, the next step is to activate the processor on the variable in config/services.yaml using the vault keyword.

parameters:
  $myOtherSecret: '%env(vault:MY_OTHER_SECRET)%'

App\Command\TestCommand:
  arguments:
    $secret: '%env(vault:MY_SECRET)%'

CLI support

This bundle also comes with two CLI commands to help debug configuration and to check that you fetch the expected data from the vault. Use the --help option to Symfony console to see the options available for the commands.

  • itkdev:vault:login
  • itkdev:vault:secret

Developing

See details on contributing in the contributing docs.

itk-dev/vault-bundle 适用场景与选型建议

itk-dev/vault-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.89k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 10 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 itk-dev/vault-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 itk-dev/vault-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 itk-dev/vault-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-08