mawuekom/laravel-password-history
Composer 安装命令:
composer require mawuekom/laravel-password-history
包简介
Allows you to store users password history
README 文档
README
This package allows to store users password history and check if the user can use the same for updating or not. Then, you can tell your users when they will be going to create a new password for their accounts if they can use an already used password or not.
Installation
You can install the package via composer:
composer require mawuekom/laravel-password-history
Usage
Once install, go to config/app.php to add PasswordHistoryServiceProvider in providers array
Laravel 5.5 and up Uses package auto discovery feature, no need to edit the config/app.php file.
'providers' => [ ... Mawuekom\PasswordHistory\PasswordHistoryServiceProvider::class, ],
php artisan vendor:publish --tag=password-history
Or you can publish config
php artisan vendor:publish --tag=password-history --config
Configuration
- You can change connection for models, models path and there is also a handy pretend feature.
- There are many configurable options which have been extended to be able to configured via
.envfile variables. - Editing the configuration file directly may not needed because of this.
- See config file: password-history.php.
<?php /* * You can place your custom package configuration in here. */ return [ /** * Password histories config */ 'enable' => true, 'model' => Mawuekom\PasswordHistory\Models\PasswordHistory::class, 'checker' => false, 'number_to_check' => 3, 'name' => 'Password History', 'resource_name' => 'password_history', 'table' => [ 'name' => env('PASSWORD_HISTORY_PASSWORD_HISTORIES_DATABASE_TABLE', 'password_histories'), 'primary_key' => env('PASSWORD_HISTORY_PASSWORD_HISTORIES_DATABASE_TABLE_PRIMARY_KEY', 'id'), 'user_foreign_key' => env('PASSWORD_HISTORY_PASSWORD_HISTORIES_DATABASE_TABLE_USER_FOREIGN_KEY', 'user_id'), ], /** * Users config */ 'user' => [ 'model' => App\Models\User::class, 'name' => 'User', 'resource_name' => 'user', 'table' => [ 'name' => env('PASSWORD_HISTORY_USERS_DATABASE_TABLE', 'users'), 'primary_key' => env('PASSWORD_HISTORY_USERS_DATABASE_TABLE_PRIMARY_KEY', 'id'), ], ], /* |-------------------------------------------------------------------------- | Add uuid support |-------------------------------------------------------------------------- */ 'uuids' => [ 'enable' => true, 'column' => '_id' ], ];
To allow your users to use password histries, add HasPasswordHistory trait in your User Model.
<?php namespace App\Models; ... use Mawuekom\PasswordHistory\Traits\HasPasswordHistory; ... class User extends Authenticatable { use HasPasswordHistory; ... }
PasswordHistoryChecker is a service that help you implement the fact that an user can not use recently used passwords for creating a new one. If he do so, it will be notify that :
Your new password can not be the same as any of your recent passwords. Please choose a new password.
$user = User::create([ 'name' => 'Toto', 'email' => 'toto@gmail.com', 'password' => 'toto1234', ]); $user ->updatePasswordHistory();
$user = User::find(1); PasswordHistoryChecker::validatePassword($user, $new_password);
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Report bug
Contact me on Twitter @ephraimseddor
License
The MIT License (MIT). Please see License File for more information.
mawuekom/laravel-password-history 适用场景与选型建议
mawuekom/laravel-password-history 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 157 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 08 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「password-history」 「laravel-password-history」 「mawuekom」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mawuekom/laravel-password-history 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mawuekom/laravel-password-history 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mawuekom/laravel-password-history 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A small package for implements a password history
Easily sanitize your form data
Easily work with UUIDs in your Laravel models
Laravel package to make easy search on Eloquent model
Flexible Flash notifications for Laravel
Keep a password history of your users to prevent them from reusing the same password like Facebook, Google
统计信息
- 总下载量: 157
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 15
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-08-12