code-pros/password-policy 问题修复 & 功能扩展

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

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

code-pros/password-policy

最新稳定版本:1.0.0

Composer 安装命令:

composer require code-pros/password-policy

包简介

Create a password policy and validate strings against it

README 文档

README

Create a Password Policy and validate passwords against it.

Useful for when a user is creating/updating their password.

Installation

Use Composer to manage your dependencies:

composer require code-pros/password-policy

Example

/**
 * Setup a password policy
 * This policy is from OWASP's security cheat sheet.  Look it up for good reading!
 *
 * Must match 3/4 of the following
 * - Lowercase character
 * - Uppercase character
 * - Special character
 * - Digit
 * Must match all of the following
 * - between 10 and 128 characters
 * - no consecutive characters more than twice
 */
$childPolicy = \CodePros\PasswordPolicy\Builder::create()
        ->addMustRule(new \CodePros\PasswordPolicy\Rules\Characters\Lowercase(1))
        ->addMustRule(new \CodePros\PasswordPolicy\Rules\Characters\Uppercase(1))
        ->addMustRule(new \CodePros\PasswordPolicy\Rules\Characters\Digit(1))
        ->addMustRule(new \CodePros\PasswordPolicy\Rules\Characters\Special(1))
        ->pctRulesMustPass(75)
        ->build();

$policy = \CodePros\PasswordPolicy\Builder::create()
        ->addMustRule(new \CodePros\PasswordPolicy\Rules\Characters\Length(10, 128))
        ->addMustNotRule(new \CodePros\PasswordPolicy\Rules\ConsecutiveCharacters(3))
        ->mustPassPolicy($childPolicy)
        ->build();

/**
 * Validate a password
 */
$valid = $policy->validate('user supplied password');

/**
 * Get back a list of rules and whether the last validation passed each.
 */
$messages = $policy->getDetailedStatus();

Development

Development Process

  1. Make your changes.
  2. Test with PHPUnit.

Build Process

  1. Choose a new version number according to semver.
  2. Summarize your changes in CHANGELOG with the new version number.
  3. Create a git tag with the version number.
  4. Push the changes and tag.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-06-18