juniorfontenele/laravel-vault-client
最新稳定版本:1.0.0
Composer 安装命令:
composer require juniorfontenele/laravel-vault-client
包简介
A vault client for Laravel vault server.
README 文档
README
Laravel Vault Client is a client for Laravel Vault Server provided by juniorfontenele/laravel-vault-server package for secure key management, key rotation, JWT signing/validation, and secure user hash storage.
Installation
Install via composer:
composer require juniorfontenele/laravel-vault-client
Publish and run the migrations:
php artisan vault:install
Artisan Commands
php artisan vault:install— Publish and run the migrations.php artisan vault:provision {token}— Provision the client in Vault using the provision token.php artisan vault:rotate— Rotate the client's private key.
Usage Examples
Rotate Private Key
use JuniorFontenele\LaravelVaultClient\Facades\VaultClient; $newKey = VaultClient::rotateKey();
Get Public Key by Key ID
use JuniorFontenele\LaravelVaultClient\Facades\VaultClient; $publicKey = VaultClient::getPublicKey($kid);
Get User Hash
use JuniorFontenele\LaravelVaultClient\Facades\VaultClient; $hash = VaultClient::getHashForUser($userId);
Store User Password (hash will be generated)
use JuniorFontenele\LaravelVaultClient\Facades\VaultClient; VaultClient::storePasswordForUser($userId, $password);
Store User Hash (provide your own hash)
use JuniorFontenele\LaravelVaultClient\Facades\VaultClient; VaultClient::storeHashForUser($userId, $hash);
Delete User Hash
use JuniorFontenele\LaravelVaultClient\Facades\VaultClient; VaultClient::deleteHashForUser($userId);
Protecting Routes with JWT Middleware
You can protect your routes using the vault.jwt middleware:
use Illuminate\Support\Facades\Route; Route::middleware(['vault.jwt'])->group(function () { // Your protected routes here });
You may also pass scopes as optional parameters to the middleware:
Route::middleware(['vault.jwt:admin'])->get('/admin', ...);
Configuration
The configuration file config/vault.php will be published with all required options, such as client_id, url, issuer, TTLs, etc.
Testing
composer test
Credits
License
The MIT License (MIT). See License File for more information.
统计信息
- 总下载量: 15
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-19