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:
- activate api routes:
/powshield/generate-challengeto generate a challenge/powshield/verify-solutionto check a solution
- activate the validator:
powshieldto validate a solution in a model
Usage
Client side
You can use the following libraries to generate and check the solution:
- @blackcube/aurelia2-powshield Aurelia 2 powshield
- @blackcube/vanilla-powshield VanillaJS powshield
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
其他信息
- 授权协议: proprietary
- 更新时间: 2024-06-22