cbenjafield/laravel-password-manager
Composer 安装命令:
composer require cbenjafield/laravel-password-manager
包简介
A simple password manager package for Laravel.
README 文档
README
Laravel Password Manager
A really simple Laravel package to encrypt and decrypt passwords in storage.
Installation
Composer:
composer require cbenjafield/laravel-password-manager
After installation, publish the config:
php artisan vendor:publish --provider="Benjafield\LaravelPasswordManager\PasswordServiceProvider" --tag="config"
Add a 16 character long key to your .env file. Also, if you would like to change the passwords table name, you may specify that too.
PASSWORDS_KEY="Your 16 Character Long String Here" PASSWORDS_TABLE="optional_password_table_name"
If you would like to generate a key for the .env file, you can use the following Artisan command:
php artisan passwords:generate-key
You can then copy the generated key to your .env file.
Then, publish the database migrations:
php artisan vendor:publish --provider="Benjafield\LaravelPasswordManager\PasswordServiceProvider" --tag="migrations"
Run the migrations:
php artisan migrate
Usage
Encrypting a password
You can make use of dependency injection:
<?php namespace App\Http\Controllers; use Benjafield\LaravelPasswordManager\PasswordManager; use Illuminate\Http\Request; class PasswordController extends Controller { public function store(Request $request, PasswordManager $passwords) { $request->validate([ 'name' => ['required', 'string', 'max:255'], 'password' => ['required', 'string', 'max:255'], ]); $password = $passwords->encrypt($request->name, $request->password); // Call the save method to store the password in the database. $password->save(); return response($password->password, 201); } }
Or you can use the facade:
use Benjafield\LaravelPasswordManager\Facades\PasswordsFacade; $password = PasswordsFacade::encrypt($request->name, $request->password); // Call the save method to store the password in the database. $password->save();
Decrypting a password
To decrypt a password, you need to retrieve the dynamic key used to encrypt it in the first place.
use Benjafield\LaravelPasswordManager\PasswordManager; use Benjafield\LaravelPasswordManager\Password; public function show(int $id, PasswordManager $passwords) { // Retrieve the password from the database. $password = Password::findOrFail($id); // Decrypt the password back into the original string. $decrypted = $passwords->decrypt($password->dynamic, $password->password); }
Caveats
This package doesn't handle authentication or middlewares involved in protecting the encryption or decryption of passwords - you will need to handle this yourself.
Licence
The MIT Licence (MIT). Please refer to Licence File for more information.
cbenjafield/laravel-password-manager 适用场景与选型建议
cbenjafield/laravel-password-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 112 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 08 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「password manager」 「cbenjafield」 「laravel-password-manager」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cbenjafield/laravel-password-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cbenjafield/laravel-password-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cbenjafield/laravel-password-manager 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
The PHP class PasswordGenerator serves as a password generator to create memorable passwords like the keychain of macOS ≤ 10.14 did.
Laravel middleware to restrict a site or specific routes using HTTP basic authentication
High-level cryptographic primitives and security utilities for Maatify systems including password hashing, reversible encryption, HKDF key derivation, and key rotation.
A library for reading KeePass 2.x databases
Add a secure password generator to Signup Modal
统计信息
- 总下载量: 112
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-08-11
