org_heigl/password-middleware 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

org_heigl/password-middleware

Composer 安装命令:

composer require org_heigl/password-middleware

包简介

A middleware to handle passwords securely

README 文档

README

Whenever you are handling passwords you should as soon as possible convert the plaintext that is sent over-the-wire into something that can not leak the cleartext-password.

For that purpose I built a Password-ValueObject that can replace the password and allows you to safely handle it fore whatever need you have.

What is missing in the ValueObject though is the possibility to actually get the password from the request and convert it directly. This is what this middleware does. It intercepts the request, converts every parameter that is configured into a password-ValueObject and replaces the plaintext password in the request.

This will only work for form-parameters that were sent via POST request. You should never ever send passwords or other sensitive information via GET parameters as they will be recorded in the servers access logs!!!

Installation

Do I really need to describe this?

$ composer install org_heigl/password-middleware

Usage

use Org_Heigl\PasswordMiddleware\PasswordMiddleware;
use Slim\App;

$app = new App();
$app->add(new PasswordMiddleware('password', 'password-verification'));

Now you can use this in your controller:

class Controller
{
    public function handle($request, $response): ServerResponse
    {
        /** @var \Org_Heigl\Password\Password $password */
        $password = $request->getParsedBody()['password'];
        $passwordVerification = $request->getParsedBody()['password-verification'];
        if ($password == $passwordVerification) {
            throw new RuntimeException('Passwords do not match');
        }
    }
}

Caveat: Currently only fields in the first level of the parsed body are available! So if you nest parameters this will currently not work! This is one of the next features that will be implemented!

Caveat: Currently the raw body will not be modified! So the clear text password will always be in the raw request stream! This is also one of the next things on the list!

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固