承接 lukasjankowski/laravel-safepass 相关项目开发

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

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

lukasjankowski/laravel-safepass

Composer 安装命令:

composer require lukasjankowski/laravel-safepass

包简介

A laravel 5 password validation package for checking if passwords are really secure

README 文档

README

Laravel-Safepass for Laravel 5

This package allows you to check the given password based on Zxcvbn and use it to validate its strength / entropy.

Note: Depending on how heavy the load on your application is, it might be wiser to use something else as the checks can be quite expensive on computing time.

The why

I got tired of solutions using some arbitrary regex to validate that the password contains at least one uppercase character, lowercase character, digit etc. Those requirements are not safe, not to mention that they advocate the exact opposite of what you were trying to accomplish.

See: xkcd or codinghorror for explanations.

This package uses - as mentioned above - https://github.com/bjeavons/zxcvbn-php/ as a means to calculate the passwords entropy and estimated cracking time. It will then go ahead and convert that value to a percentage in order to make writing rules more convenient.

The percentage is based off 10^8 seconds.

  • So 100% is ~ 3 years,
  • 50% would be ~ 1.5 years,
  • 10% would be ~ 115 days etc.

The default value is 50%.

Installation

Require via composer:

composer require lukasjankowski/laravel-safepass

Include the service provider within your config/app.php.

'providers' => [
    // ...
    LukasJankowski\SafePass\SafePassServiceProvider::class
];

Usage

Simply add the safepass as a rule to your request validation.

Examples:

 public function create(Request $request)
    {
        $this->validate(
            $request,
            [
                'name' => 'required|min:4',
                'password' => 'required|safepass',
            ]
        );
        
        return 'Created.';
    }

If you want to override the standard of 50% you can add a parameter to the rule:

 public function create(Request $request)
    {
        $this->validate(
            $request,
            [
                'name' => 'required|min:4',
                'password' => 'required|safepass:100', // In percent
            ]
        );
        
        return 'Created.';
    }

The default error message is:

    'safepass' => 'The password you entered is easily guessable. Please use a more complex one.'

which you can override just like you would with other rules.

TODO

  • Unit tests

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-08-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固