nuwira/bandrek
Composer 安装命令:
composer require nuwira/bandrek
包简介
Bandrek is password recovery token generation using number as code for Laravel 5.4.x based.
README 文档
README
Bandrek is local word in Javanese that means a lock pick. We use lock pick to open a padlock if the key is lost.
Bandrek replaces Laravel's password recovery manager to provide code and token when requesting password recovery. This code can be used as token replacement if you are using REST-API to reset password without visiting web interface.
Bandrek generate 6 random numeric character as code. Bandrek is also creating 64 characters token that can be used in normal web page interface.
The scenario is when user request password recovery via REST-API, the user can send the credentials (e-mail and password) and the easy readable code to reset the password.
Installation
Bandrek only supports Laravel 5.4 and above. To install using Composer, just run this command below.
composer require nuwira/bandrek
Configuration
Config File
After installed, open config/app.php and find this line.
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class
Comment or remove it and add that line to override Laravel's password reset handling.
Nuwira\Bandrek\BandrekServiceProvider::class
Add Facade
This is optional. To add Facade, add config/app.php in the aliases section.
'Bandrek' => Nuwira\Bandrek\BandrekFacade::class,
If Facade is loaded, you can call these functions
Bandrek::getRandomCode($length = 6, $toString = true); Bandrek::generateToken(); Bandrek::getTokenFromCode($code); Bandrek::getCodeFromToken($token, $toString = true);
Model File
To be able to send reset password instruction e-mail, open app/User.php (the user model file) and find this line.
use Illuminate\Foundation\Auth\User as Authenticatable;
Replace that line with this.
use Nuwira\Bandrek\Auth\User as Authenticatable;
Using Custom Notification
Bandrek by default is using e-mail for notification. You can add or replace using your preferred method by extending abstract class Nuwira\Bandrek\Notification\BandrekNotification. The token and code are available in $this->code and $this->token in the notification class.
For example, if you want to send the code using Gammu SMS notification, just install and configure it.
To use SMS and e-mail for code sending, add function in your model that extends Nuwira\Bandrek\Auth\User and inject the notification.
Notification File: App\Notifications\ResetPassword.php
namespace App\Notifications; use Nuwira\Bandrek\Notification\BandrekNotification; use Illuminate\Notifications\Messages\MailMessage; use NotificationChannels\Gammu\GammuChannel; use NotificationChannels\Gammu\GammuMessage; class ResetPassword extends BandrekNotification { public function via($notifiable) { return ['mail', GammuChannel::class]; } public function toMail($notifiable) { return (new MailMessage) ->line('You are receiving this email because we received a password reset request for your account.') ->action('Reset Password', url(config('app.url').route('password.reset', $this->token, false))) ->line('If you did not request a password reset, no further action is required.'); } public function toGammu($notifiable) { return (new GammuMessage()) ->to($phoneNumber) ->content('To reset password, use this code: '.$this->code); } }
Model File: App\User.php
namespace App; use Nuwira\Bandrek\Auth\User as BaseUser; use App\Notifications\ResetPassword as ResetPasswordNotification; class User extends BaseUser { public function sendPasswordResetNotification($token) { $this->notify(new ResetPasswordNotification($token)); } }
License
The MIT License (MIT). Please see License File for more information.
nuwira/bandrek 适用场景与选型建议
nuwira/bandrek 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 853 次下载、GitHub Stars 达 3, 最近一次更新时间为 2017 年 07 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「password」 「laravel」 「nuwira」 「bandrek」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nuwira/bandrek 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nuwira/bandrek 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nuwira/bandrek 相关的其它包
同方向 / 同关键字的高下载量 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
Add a secure password generator to Signup Modal
Make a calculation so users can have a visual response to password input
统计信息
- 总下载量: 853
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 14
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-07-29