diontech/laravel-vault 问题修复 & 功能扩展

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

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

diontech/laravel-vault

Composer 安装命令:

composer require diontech/laravel-vault

包简介

Building vaults and decrypted/encryped secrets. Using specfic keys per vault (or per secret if you want to) is implemented. Vaults can be a standalone or related to your app`s models.

README 文档

README

Latest Version run-tests GitHub last commit GitHub issues Packagist Downloads License Twitter Follow

about Vault

With Vault, you can create vaults as application standalones or related to a model in your app, for example every user can have personal vaults. Each vault can contain secrets. Instead of using the default decrypt/encrypt functions, Vault will protect secrets using the keys you will choose. For example, an user can define its 'magic secret password' and must provide it every time he wants to have access to a secret. The way you will handle this is dependant to your case.

Vault will handle the key length internally and make sure, the length is 16 or 32, dependant to the cipher you will use (AES-128-CBC = 16, AES-256-CBC = 32). So you can choose the secret key you will want to.

releases / laravel support

  • laravel 8: v1.1.x
  • laravel 9: v1.2.x

installation

composer require diontech/laravel-vault
php artisan migrate

usage

//creating a vault without a related model
$vault = \DionTech\Vault\Models\Vault::create([
    'name' => 'application vault'
]);

//use default APP_KEY, adding secret
\DionTech\Vault\Support\Facades\Vault::open($vault)->add("facaded_secret", "AN_API_KEY");

//use default APP_KEY, overwrite secret
\DionTech\Vault\Support\Facades\Vault::open($vault)->overwrite("facaded_secret", "AN_API_KEY_overwritten");

//use default APP_KEY, get secret
\DionTech\Vault\Support\Facades\Vault::open($vault)->get("facaded_secret");


//use own key, adding secret
\DionTech\Vault\Support\Facades\Vault::open($vault)->useKey("DO_NOT_FORGETT_IT")->add("facaded_secret", "AN_API_KEY");

//use own key, overwrite secret
\DionTech\Vault\Support\Facades\Vault::open($vault)->useKey("DO_NOT_FORGETT_IT")->overwrite("facaded_secret", "AN_API_KEY_overwritten");

//use own key, get secret
\DionTech\Vault\Support\Facades\Vault::open($vault)->useKey("DO_NOT_FORGETT_IT")->get("facaded_secret");
//adding a vault using the polymorphic relation
//at your model, add morphMany relation, for example at User:

use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
    //...
    
    public function vaults()
    {
        return $this->morphMany(\DionTech\Vault\Models\Vault::class, 'vaultable');
    }
}


//now add a vault at an $user instance later
$user = User::first();

$user->vaults()->create([
    'name' => 'personal'
]);

//now you will have access to the methods like using a facade when you will use the related model based vaults(), starting with open()

$user->vaults()->first()->add("AN_API_KEY", "this-is-the-sensible-value");
$user->vaults()->first()->overwrite("AN_API_KEY", "this-is-the-sensible-value-overwritten");
$user->vaults()->first()->get("AN_API_KEY");

There are now a few new options more now of how to write the code:

Vault::open("a vault name")->add("facaded_secret", "simple value"); //will create the vault

or when want a relational based vault:

$user = User::first(); 
Vault::setContext($user)->open("personal")->add('bad_password_storing_itself', '12345678'); //will create a vault in relation to the user

So vaults are created or loaded (when already exists) when you only type a string.

changing the KeyService hash alogorithm

You can publish the config file - after that, you can change the algo at config/vault.php; default is set to sha512. Supported are listed at https://www.php.net/manual/de/function.hash-hmac-algos.php.

diontech/laravel-vault 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 11
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-06-05