nerd4ever/vault-php 问题修复 & 功能扩展

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

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

nerd4ever/vault-php

Composer 安装命令:

composer require nerd4ever/vault-php

包简介

PHP library for Vault

README 文档

README

Tests

PHP Client Library for the Hashicorp Vault Service. This Client follows the Request and Response Data equal to the Hashicorp Vault Client Documentation.

Feel free to open Pull Requests to add improvements or missing functionality.

Installation

Composer

composer require mittwald/vault-php

Implemented Functionality:

  • Auth
    • User/Password
    • Token
    • Kubernetes
  • Secret Engines
    • Transit Engine
      • Encrypt/Decrypt
      • Update Key Config
      • Create Key
      • Delete Key
      • List Keys

Basic Usage

// setting up independent http client 
$httpClient = new Client();

// setting up vault auth provider
$auth = new Token('foo');

// creating the vault request client
$client = new VaultClient(
    $httpClient,
    $auth,
    'http://127.0.0.1:8200'
);

// selecting the desired secret engine
// e.g. Transit Secret Engine
$api = new Transit($client);

// calling specific endpoint
$response = $api->listKeys();

//reading results
var_dump($response->getKeys());
//...
//...
//Profit...

VaultClient

public function __construct(
    HttpClient $httpClient,
    AuthenticationProviderInterface $authProvider,
    string $apiHost
)

HttpClient takes every PSR-18 compliant HTTP Client Adapter like "php-http/curl-client": "^1.7"

AuthenticationProviderInterface Authentication Provider from /authentication/provider/*

$apiHost Hashicorp Vault REST Endpoint URL

Bulk Requests

Using Bulk Requests also requires to iterate through the Response and calling hasErrors within the MetaData of each Bulk Item to ensure it was processed successfully.

Exceptions

Calling library methods will throw exceptions, indicating where ever invalid data was provided or HTTP errors occurred or Vault Generic Endpoint Errors are encountered.

VaultException

Generic Root Exception where every exception in this library extends from.

VaultHttpException

Exception will thrown when something inside the HTTP handling will cause an error.

VaultAuthenticationException

Will be thrown when API Endpoint Authentication fails.

VaultResponseException

Will be thrown on 5xx status code errors.

InvalidRouteException

Calling an Invalid/Non Existing/Disabled Vault API Endpoint will throw this Exception.

InvalidDataException

Exception indicates a failed server payload validation.

KeyNameNotFoundException

Will be thrown when trying to request an API Endpoint where the Key Name - that is indicated within the url - will not exist.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-03-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固