yebor974/filament-renew-password
Composer 安装命令:
composer require yebor974/filament-renew-password
包简介
Package for manage renew password according to the last renew or other criteria
README 文档
README
The Filament Renew Password Plugin enhances Filament by prompting users to renew their passwords based on specified criteria.
Two default renewal processes are implemented:
- Recurring Renewal
- Force Renewal
You are free to add your own renewal criteria.
Installation
- Install the package using the composer command:
✅ Filament v4 and v5 compatibility are available in version 3.x of this plugin.
composer require yebor974/filament-renew-password✅ If you are using Filament v3, please install version 2.x:
composer require yebor974/filament-renew-password:^2.0
- Publish and run the migration, which adds new columns
last_renew_password_atandforce_renew_passwordto the users table.
php artisan vendor:publish --tag="filament-renew-password-migrations"
php artisan migrate
Alternatively, if you don't want to publish the migrations or already have columns in your database for such case, you can skip this step and customize the column name by using any of the configuration methods described in the Configuration section below.
- Optionally, you can publish translations files with:
php artisan vendor:publish --tag="filament-renew-password-translations"
- Register the plugin in your panel provider:
use Yebor974\Filament\RenewPassword\RenewPasswordPlugin; public function panel(Panel $panel): Panel { return $panel ->plugin(new RenewPasswordPlugin()); }
Configuration
Filament Renew Password Plugin is designed to work out of the box with minimal configuration. However, you can customize the plugin by publishing the configuration file, changing the environment variables or using the plugin object to override the default settings.
Renewal Processes
Two configurations are available and can be used simultaneously.
- Recurring renew process
By default, recurring renewal process is disabled.
To activate recurring renewal process, you have to call passwordExpiresIn and define the number of days of recurring:
RenewPasswordPlugin::make() ->passwordExpiresIn(days: 30)
This activation automatically manages a last renewal timestamp column named last_renew_password_at. You can customize it with the timestampColumn function:
RenewPasswordPlugin::make() ->passwordExpiresIn(days: 30) ->timestampColumn('your_custom_timestamp_column')
- Force renew process
The force renewal process can be useful for example when an administrator creates a user. You can send a temporary password to the new user and force them to renew their password at the first login.
By default, force renewal process is disabled.
To activate it, you have to call forceRenewPassword function:
RenewPasswordPlugin::make() ->forceRenewPassword()
This activation automatically manages a force renew boolean column named force_renew_password. If you want to customize it, you can define with second param:
RenewPasswordPlugin::make() ->forceRenewPassword(forceRenewColumn: 'your_custom_boolean_force_column')
If you dont want the recurring renewal process but only want the force renewal process with also timestamp column you can add it with:
RenewPasswordPlugin::make() ->forceRenewPassword() ->timestampColumn('your_custom_timestamp_column')
You can of course use both process with this configuration:
RenewPasswordPlugin::make() ->passwordExpiresIn(days: 30) ->forceRenewPassword()
And with columns customization:
RenewPasswordPlugin::make() ->passwordExpiresIn(days: 30) ->forceRenewPassword(forceRenewColumn: 'your_custom_boolean_force_column') ->timestampColumn('your_custom_timestamp_column')
Custom Renew Page
By default, RenewPassword simple page is used to ask user to renew it. You can custom it with:
RenewPasswordPlugin::make() ->renewPage(CustomRenewPassword::class)
Route URI
'password/renew' is the default route URI when being asked to change passwords. For translation purposes, you may want to customize this. You can do this with the following configuration:
RenewPasswordPlugin::make() ->routeUri('wachtwoord/vernieuwen')
Usage
Implement the RenewPasswordContract on your Authentication Model (User) and define the criteria for prompting password renewal in the needRenewPassword function.
- Default Trait
You can use the RenewPassword trait on your Authentication Model (User).
class User extends Authenticatable implements RenewPasswordContract { use RenewPassword; }
This trait manages recurring renew if activated and/or force renew if activated:
public function needRenewPassword(): bool { $plugin = RenewPasswordPlugin::get(); return ( !is_null($plugin->getPasswordExpiresIn()) && Carbon::parse($this->{$plugin->getTimestampColumn()})->addDays($plugin->getPasswordExpiresIn()) < now() ) || ( $plugin->getForceRenewPassword() && $this->{$plugin->getForceRenewColumn()} ); }
- Custom criteria
You can make your own criteria by implement needRenewPassword function on your Authentication Model (User).
In this case, you will certainly need to customize the RenewPassword simple page described above.
yebor974/filament-renew-password 适用场景与选型建议
yebor974/filament-renew-password 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 99.17k 次下载、GitHub Stars 达 44, 最近一次更新时间为 2024 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「password」 「laravel」 「renew」 「filament」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 yebor974/filament-renew-password 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 yebor974/filament-renew-password 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 yebor974/filament-renew-password 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
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
Get User Data with the result code of a apple sign in button
Add a secure password generator to Signup Modal
统计信息
- 总下载量: 99.17k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 44
- 点击次数: 18
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-01-04