vaultPHP
2.1.0
hashicorp保管庫服務的PHP客戶庫。該客戶端遵循與Hashicorp Vault客戶端文檔相等的請求和響應數據。
請隨時打開拉動請求以添加改進或缺少功能。
composer require mittwald/vault-php
// 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... public function __construct(
HttpClient $ httpClient ,
AuthenticationProviderInterface $ authProvider ,
string $ apiHost
) HttpClient採用每個符合PSR-18的HTTP "php-http/curl-client": "^1.7"
來自/authentication/provider/* Authentication ProviderFace AuthenticationProviderInterface Authentication提供商
$apiHost HASHICORP VAULT REST端點URL
使用批量請求還需要通過響應和每個批量項目的MetaData撥打hasErrors進行迭代,以確保成功處理。
呼叫庫方法將拋出異常,表明在提供無效的數據或發生HTTP錯誤或遇到Vault Generic端點錯誤的位置。
VaultException
通用根異常,此庫中的每個異常都從。
VaultHttpException
當HTTP處理中的某些內容會導致錯誤時,將會拋出異常。
VaultAuthenticationException
當API端點身份驗證失敗時,將拋出。
VaultResponseException
將在5xx狀態代碼錯誤上拋出。
InvalidRouteException
調用無效/非現有/禁用的Vault API端點將引發此異常。
InvalidDataException
異常表示失敗的服務器有效負載驗證。
KeyNameNotFoundException
當嘗試請求API端點時,將被拋棄,其中關鍵名稱(在URL中指示)將不存在。