定制 double-star-systems/zxcvbn-symfony 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

double-star-systems/zxcvbn-symfony

Composer 安装命令:

composer require double-star-systems/zxcvbn-symfony

包简介

Password strength validator for Symfony framework. Based on Dropbox's zxcvbn project.

README 文档

README

Password strength constraint for Symfony validator component. Based on the zxcvbn project from Dropbox and @lowe, this is using zxcvbn-php under the hood for password strength estimation.

zxcvbn attempts to give sound password advice through pattern matching and conservative entropy calculations. It finds 10k common passwords, common American names and surnames, common English words, and common patterns like dates, repeats (aaa), sequences (abcd), and QWERTY patterns.

Installation

The library can be installed with Composer by adding it as a dependency to your composer.json file.

$ composer require double-star-systems/zxcvbn-symfony

Usage

The constrint can be attached to an entity field using an annotation.

use DoubleStarSystems\ZxcvbnSymfony\Constraint\PasswordStrength;

class User
{
    /**
     * @PasswordStrength(min_score=3, message="Custom message for weak password error")
     */
    private $password;
}

You may simply use the simpler @PasswordStrength(3) form for a minimum password score of 3, if you don't need a custom message.
More information on validation with Symfony validator can be found in the documentation.

Alternatively, the constraint can be added directly to form fields.

use DoubleStarSystems\ZxcvbnSymfony\Constraint\PasswordStrength;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('password', PasswordType::class, [
            'required' => true,
            'constraints' => [
                new PasswordStrength(['min_score' => 3]),
            ],
        ])
    ;
}

Score

The score is an integer from 0-4 (you can mentally represent it as a strength bar)

  • 0 too guessable: risky password. (guesses < 10^3)
  • 1 very guessable: protection from throttled online attacks. (guesses < 10^6)
  • 2 somewhat guessable: protection from unthrottled online attacks. (guesses < 10^8)
  • 3 safely unguessable: moderate protection from offline slow-hash scenario. (guesses < 10^10)
  • 4 very unguessable: strong protection from offline slow-hash scenario. (guesses >= 10^10)

License

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
See the complete license.

This project is a fork of Mathieu Darse's Password Strength Validator which is no longer in active development.

double-star-systems/zxcvbn-symfony 适用场景与选型建议

double-star-systems/zxcvbn-symfony 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 127 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 02 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 double-star-systems/zxcvbn-symfony 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MPL-2.0
  • 更新时间: 2022-02-13