承接 selfsimilar/laravel-d7-password 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

selfsimilar/laravel-d7-password

Composer 安装命令:

composer require selfsimilar/laravel-d7-password

包简介

Laravel package that checks and creates Drupal 7 password hashes

README 文档

README

Build Status

This Laravel 8 package provides an easy way to create and check against Drupal 7 password hashes. Drupal is not required.

Installation

Step 1: Composer

Begin by installing this package through Composer. Edit your project's composer.json file to require selfsimilar/laravel-d7-password.

"require": {
  "selfsimilar/laravel-d7-password": "~0.1.2"
}

Next, update Composer from the Terminal:

composer update

Step 2: Register Laravel Service Provider

Once this operation completes, the final step is to register the service provider.

  • Laravel 5-8.x: Open config/app.php, and add a new item to the providers array
'Selfsimilar\D7Password\D7PasswordProvider'

Usage

Add a use statement for the D7Password facade

use Selfsimilar\D7Password\Facades\D7Password;

make() - Create Password Hash

Similar to the Drupal user_hash_password() function

$hashed_password = D7Password::make('plain-text-password');

check() - Check Password Hash

Similar to the Drupal user_check_password() function

$password = 'plain-text-password';
$d7_hashed_password = '$S$B7TRc6vrwCfjgKLZLgmN.dmPo6msZR.';

if ( D7Password::check($password, $d7_hashed_password) ) {
    // Password success!
} else {
    // Password failed :(
}

Dependency Injection

I used a facade above to simplify the documentation. If you'd prefer not to use the facade, you can inject the following interface: Selfsimilar\D7Password\Contracts\D7Password.

Recommendations

While you could in principle register and use the D7PasswordHasher as the default hasher and leave the passwords alone, you can also update the passwords to the better and more secure Laravel default Bcrypt algorithm. When authenticating, first check using the default hasher, and if that fails, check again with the Drupal 7 Hasher. If that succeeds, simply update the password hash for future logins.

As an example, assuming you have a fresh Laravel 8 application using Fortify (or Jetstream which uses Fortify), make the following changes to app/Providers/FortifyServiceProvider.php.

Import the following:

use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Selfsimilar\D7Password\Facades\D7Password as D7Hash;

Add this to the boot() method:

Fortify::authenticateUsing(function (Request $request) {
  $user = User::where('email', $request->email)->first();

  if ($user) {
    if (Hash::check($request->password, $user->password)) {
      return $user;
    }
    else {
      if (D7Hash::check($request->password, $user->password)) {
        $user->update(['password' => Hash::make($request->password)]);
        return $user;
      }
    }
  }
});

selfsimilar/laravel-d7-password 适用场景与选型建议

selfsimilar/laravel-d7-password 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.67k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2020 年 11 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「password」 「drupal」 「hashing」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 selfsimilar/laravel-d7-password 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 selfsimilar/laravel-d7-password 我们能提供哪些服务?
定制开发 / 二次开发

基于 selfsimilar/laravel-d7-password 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4.67k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-11-03