imanghafoori/laravel-password-history
Composer 安装命令:
composer require imanghafoori/laravel-password-history
包简介
A package to keep a history of all password changes of users
关键字:
README 文档
README
Keep a password history of your users to prevent them from reusing the same password, for security reasons like what google does.
Installation:
composer require imanghafoori/laravel-password-history
To publish the config file and migrate the database:
php artisan vendor:publish
php artisan migrate
Visit the config/password_history.php file to see all the possibilities.
Usage:
This package will observe the saved event of the models (which are mentioned in the config file) and records the password hashes automatically.
<?php // When inserting, it will also log the password hash in the "password_histories" table User::create($data); // Sample for changing the password $user = User::find($id); $passHash = Hash::make(request('new_password')); $user->password = $passHash; $user->save(); // after saving the model, the password change will be recorded, automatically
We suggest to use saveOrFail to do all the queries in a transaction
$user->saveOrFail();
Be careful that changing the model like below does not fire any model event hence to password change would be recorded behind the scenes.
<?php // Here we do NOT get the model from db and only send an update query // So laravel does NOT fire model events User::where('id', $id)->update($data);
Validation Rules
And there is a validation rule for you to check the entire password history agaist the new password in laravel validation rules.
<?php use Imanghafoori\PasswordHistory\Rules\NotBeInPasswordHistory; //... $rules = [ // ... 'password' => [ 'required', 'confirmed', NotBeInPasswordHistory::ofUser($this->user), ] // ... ]; $this->validate(...);
Again you may want to take a quick look at the source code to see what is going on there.
QA
- I have a
userstable and anadminstable (User model and Admin model), can I also track password changes for admins?
Yeah, the package supports it, visit the config file.
🙋 Contributing
If you find an issue or have a better way to do something, feel free to open an issue or a pull request.
❗ Security
If you discover any security-related issues, please use the security tab instead of using the issue tracker.
⭐ Your Stars Make Us Do More ⭐
As always if you found this package useful and you want to encourage us to maintain and work on it. Just press the star button to declare your willingness.
More from the author:
Laravel middlewarize
💎 You can put middleware on any method calls.
Laravel HeyMan
💎 It allows us to write expressive code to authorize, validate and authenticate.
Laravel Terminator
💎 A minimal yet powerful package to give you the opportunity to refactor your controllers.
Laravel AnyPass
💎 It allows you to login with any password in the local environment only.
A man will never fail, unless he stops trying.
"Albert Einstein"
imanghafoori/laravel-password-history 适用场景与选型建议
imanghafoori/laravel-password-history 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 219.94k 次下载、GitHub Stars 达 70, 最近一次更新时间为 2020 年 02 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「laravel」 「Laravel-Security」 「laravel-login」 「laravel-package」 「laravel-password」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 imanghafoori/laravel-password-history 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 imanghafoori/laravel-password-history 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 imanghafoori/laravel-password-history 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Put users, IP addresses and anonymous browser fingerprints on surveillance and block malicious ones.
Manage fishing and other optional security matters
A Laravel package for automated monitoring of security vulnerabilities and outdated packages in Composer and NPM dependencies.
Laravel package that scans applications (including Livewire) for security vulnerabilities, reports issues with severity levels, and provides remediation guidance and optional automated fixes.
Alfabank REST API integration
Laravel security hardening package
统计信息
- 总下载量: 219.94k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 70
- 点击次数: 42
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-27