fkrfld/azure-key-vault 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

fkrfld/azure-key-vault

Composer 安装命令:

composer require fkrfld/azure-key-vault

包简介

Allow secrets to be easily fetched from an Azure Key Vault from within a Laravel application

README 文档

README

Overview

This package allows secrets to be fetched from, or set in, an Azure Key Vault, with an interface similar to env() and config().

Installation

Require this package with composer:

composer require insites-consulting/azure-key-vault

The package should be discovered by Laravel on installation.

The following environment variables must be set, if the package's default configuration is used:

  • AZURE_AD_CLIENT_ID the UUID of the service principal which will be used to access the vault. This service principal needs "Get Secret" permission on that vault.
  • AZURE_AD_CLIENT_SECRET the shared secret for that service principal.
  • AZURE_AD_TENANT_ID the UUID for the tenant under which that service principal exists.
  • AZURE_KEY_VAULT_NAME the name of the key vault (used as a subdomain in its hostname; e.g. fred in fred.vault.azure.net).

This package publishes its configuration to vault.php. This can be done with:

php artisan vendor:publish --provider='Fkrfld\AzureKeyVault\ServiceProvider'

The configuration entries are as follows:

  • tenant_id the tenant UUID
  • client_id the service principal UUID
  • client_secret the service principal shared secret
  • vault the vault name

Usage

This package provides a facade called Vault, with three methods Vault::secret(), Vault::setSecret() and Vault::setVault(), as well as a global helper function secret().

To fetch a secret called 'apikey':

$secret = Vault::secret('apikey');

If the secret does not exist, null will be returned, unless a different default value is specified, as here:

$other_secret = Vault::secret('otherkey', 'default-value');

If there is an error, an Fkrfld\AzureKeyVault\AzureKeyVaultException will be thrown. Its message will be set to the body of the error response from Azure, and its code will be set to the HTTP status of that response.

The global helper function behaves identically to the facade method:

$secret = secret('apikey');
$other_secret = secret('otherkey', 'default-key');

To set a secret called 'apikey' to the value 'longsecretvalue':

Vault::setSecret('apikey', 'longsecretvalue');

This method is void, but will throw an Fkrfld\AzureKeyVault\AzureKeyVaultException on error, in the same manner as Vault::secret().

In order to work with multiple vaults, use Vault::setVault() to change the vault name used:

$secret = secret('apikey');
Vault::setVault('other-vault');
$other_secret = secret('apikey');

This is persistent: the newly set vault will remain until Vault::setVault() is called again.

Calling Vault::setVault() with no argument will reset the vault name to that set in the config file:

$other_secret = secret('apikey');
Vault::setVault();
$secret = secret('apikey');

fkrfld/azure-key-vault 适用场景与选型建议

fkrfld/azure-key-vault 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 fkrfld/azure-key-vault 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2025-06-20