jblab/password-validator-bundle
Composer 安装命令:
composer require jblab/password-validator-bundle
包简介
Validates a password based on certain criteria.
README 文档
README
Password Validator Bundle is a Symfony package to help you validate passwords against customizable criteria with ease.
Installation
Applications that use Symfony Flex
Open a command console, enter your project directory and execute:
composer require jblab/password-validator-bundle
Applications that don't use Symfony Flex
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
composer require jblab/password-validator-bundle
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php file of your project:
// config/bundles.php return [ // ... Jblab\PasswordValidatorBundle\JblabPasswordValidatorBundle::class => ['all' => true], ];
Usage
This bundle provides a single service for validating passwords, which
you can autowire by using the PasswordValidatorInterface type-hint:
// src/Controller/SomeController.php use Jblab\PasswordValidatorBundle\PasswordValidatorInterface; // ... class SomeController { public function __construct(private readonly PasswordValidatorInterface $passwordValidator) { } public function index() { $password = 'StrongPass1!'; $isValid = $this->passwordValidator->validate($password); if (!$isValid) { // Handle invalid password, e.g., return error response } // Continue with your logic for valid passwords } }
You can also access this service directly using the id
jblab_password_validator.password_validator.
Configuration
To customize password validation criteria, add the configuration file config/packages/jblab_password_validator.yaml
with the following options (default values shown):
# config/packages/jblab_password_validator.yaml jblab_password_validator: # Minimum password length. minimum_length: 8 # Maximum password length. maximum_length: 64 # Whether or not to require a special character. require_special_character: true # Whether or not to require a uppercase letter. require_uppercase: true # Whether or not to require a lowercase letter. require_lowercase: true # Whether or not to require a number. require_number: true # String containing all valid special characters special_character_set: '!@#$%^&*()_+-=[]{}|''' # String containing all invalid characters excluded_character_set: null
Contributing
We love contributions! If you have an idea for a feature, feel free to open an issue or, better yet, submit a pull request. We welcome participation, whether you're submitting code, reporting bugs, or asking questions. Check out the contribution guidelines to get started.
License
This bundle is released under the Apache 2.0 License. Feel free to use it in your projects.
jblab/password-validator-bundle 适用场景与选型建议
jblab/password-validator-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 136 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 05 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 jblab/password-validator-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jblab/password-validator-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 136
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2020-05-11