定制 blackcube/powshield 二次开发

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

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

blackcube/powshield

最新稳定版本:1.0.0

Composer 安装命令:

composer require blackcube/powshield

包简介

Blackcube POW Shield for Yii2

README 文档

README

Installation

The preferred way to install this extension is through composer.

composer require blackcube/powshield

Configuration

Add the following code to your configuration file:

return [
    // ...
    'modules' => [
        // ...
        'powshield' => [
            'class' => 'blackcube\powshield\Module',
            'key' => 'your-secret-key',
            'algorithm' => 'SHA-256', // SHA-256, SHA-384, SHA-512
            'minIterations' => 1000, // change iterations to make the process slower
            'maxIterations' => 100000,
            'saltLength' => 12, // change salt length to make the process slower
            'antiReplay' => true, // enable anti-replay mechanism, needs app to have cache component
            'antiReplayTimeout' => 300, // duration of the anti-replay mechanism
            'timeValidity' => 300, // duration of the challenge validity
        ],
    ],
    'bootstrap' => [
        // ...
        'powshield'
    ],
];

This sets up the module and:

  1. activate api routes:
  • /powshield/generate-challenge to generate a challenge
  • /powshield/verify-solution to check a solution
  1. activate the validator:
  • powshield to validate a solution in a model

Usage

Client side

You can use the following libraries to generate and check the solution:

Once solution is generated, you should send it to the server

Server side

You can use the following code to validate a solution:

class MyModel extends yii\base\Model
{
    public $captchaSolution;
    public $name;

    public function rules()
    {
        return [
            [['captchaSolution', 'name'], 'required'],
            ['captchaSolution', 'powshield'],
        ];
    }
}

If the solution is not valid, the model will have an error on captchaSolution.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2024-06-22