wesmiler hace 5 años
padre
commit
369b164820

+ 9 - 17
app/Controller/Api/CommonController.php

@@ -14,7 +14,10 @@ declare(strict_types=1);
 namespace App\Controller\Api;
 
 use App\Model\User;
+use App\Service\CaptchService;
 use Hyperf\HttpServer\Annotation\AutoController;
+use Hyperf\HttpServer\Annotation\RequestMapping;
+use Hyperf\RateLimit\Annotation\RateLimit;
 
 /**
  * Class LotteryController
@@ -24,25 +27,14 @@ use Hyperf\HttpServer\Annotation\AutoController;
 class CommonController extends BaseController
 {
 
+    /**
+     * 获取图形验证码
+     * @RequestMapping(path="get_captcha", methods="get,post")
+     * @RateLimit(create=1, capacity=3)
+     */
     public function verifyCode()
     {
-        $redis = $this->container->get(\Hyperf\Redis\Redis::class);
-
-        $config = new \EasySwoole\VerifyCode\Conf();
-        $code = new \EasySwoole\VerifyCode\VerifyCode($config);
-
-        //重写验证码
-        // $img_code = mt_rand(1000,9999);
-        // $result = $code->DrawCode($img_code);
-
-        //系统验证码
-        $result = $code->DrawCode();
-        $img_code = $result->getImageCode();
-
-        //写入缓存 用于其他方法验证 并且设置过期时间
-        $redis->set('codes:'.session_id(), $img_code, 180);
-
-        return $result->getImageByte();
+        return CaptchService::makeCode();
 
     }
 }

+ 1 - 1
app/Exception/Handler/AppExceptionHandler.php

@@ -33,7 +33,7 @@ class AppExceptionHandler extends ExceptionHandler
     public function handle(Throwable $throwable, ResponseInterface $response)
     {
         // 如果是授权异常
-        if ($throwable instanceof TokenValidException) {
+        if ($throwable instanceof TokenValidException || $throwable instanceof TokenValidException) {
             // 格式化输出
             $message = $throwable->getMessage();
             $message = is_numeric($message)? __('api.'.$message) : $message;

+ 54 - 0
app/Service/CaptchaService.php

@@ -0,0 +1,54 @@
+<?php
+
+declare (strict_types=1);
+namespace App\Service;
+
+/**
+ * 验证码服务
+ */
+class CaptchaService
+{
+    /**
+     * 生成验证码
+     * @param $scene  场景
+     * @param $dataType 返回类型:1-常用图片流对象,2-base图片地址(API接口使用)
+     */
+    public static function makeCode($scene='default', $dataType=1){
+
+        $redis = $this->container->get(\Hyperf\Redis\Redis::class);
+        $config = new \EasySwoole\VerifyCode\Conf();
+        $code = new \EasySwoole\VerifyCode\VerifyCode($config);
+
+        //系统验证码
+        $result = $code->DrawCode();
+
+        // 获取自定义配置
+        $config = config('verify_code.'.$scene);
+        $isNoise = isset($config['noise'])? $config['noise'] : false;
+        if($isNoise){
+            $result->setUseNoise();
+        }
+
+        $img_code = $result->getImageCode();
+
+        //写入缓存 用于其他方法验证 并且设置过期时间
+        $expire = isset($config['expire'])? intval($config['expire']) : 0;
+        $redis->set("codes:{$scene}_".session_id(), $img_code, $expire? $expire : 180);
+
+        // 返回类型
+        if($dataType == 2){
+            return ['url'=> $result->getImageBase64(), 'scene'=> $scene];
+        }else{
+            return $result->getImageByte();
+        }
+    }
+
+    /**
+     * 验证码校验
+     */
+    public static function checkCode($code, $scene='default'){
+        $redis = $this->container->get(\Hyperf\Redis\Redis::class);
+        $cacheCode = $redis->get("codes:{$scene}_".session_id());
+        return $cacheCode == $code? true : false;
+    }
+}

+ 2 - 1
composer.json

@@ -39,7 +39,8 @@
         "hyperf/resource": "^2.0",
         "hyperf/translation": "^2.0",
         "phper666/jwt-auth": "^3.0",
-        "easyswoole/verifycode": "3.x"
+        "easyswoole/verifycode": "3.x",
+        "hyperf/rate-limit": "^2.0"
     },
     "require-dev": {
         "swoole/ide-helper": "^4.5",

+ 292 - 1
composer.lock

@@ -4,9 +4,75 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "9348052da358d39ddc01851902b8ecd3",
+    "content-hash": "33da82c3177ff2b2d3dc91b22d7c96a6",
     "packages": [
         {
+            "name": "bandwidth-throttle/token-bucket",
+            "version": "2.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/bandwidth-throttle/token-bucket.git",
+                "reference": "a0c31a4d0fbcf0c1a68c895fc91bf71455bcec08"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/bandwidth-throttle/token-bucket/zipball/a0c31a4d0fbcf0c1a68c895fc91bf71455bcec08",
+                "reference": "a0c31a4d0fbcf0c1a68c895fc91bf71455bcec08",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "ext-bcmath": "*",
+                "malkusch/lock": "^1",
+                "php": ">=5.6"
+            },
+            "require-dev": {
+                "ext-redis": "^2.2.4|^3",
+                "mikey179/vfsstream": "^1.5.0",
+                "php-mock/php-mock-phpunit": "^1",
+                "phpunit/phpunit": "^5",
+                "predis/predis": "^1"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "bandwidthThrottle\\tokenBucket\\": "classes/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "WTFPL"
+            ],
+            "authors": [
+                {
+                    "name": "Markus Malkusch",
+                    "email": "markus@malkusch.de",
+                    "homepage": "http://markus.malkusch.de",
+                    "role": "Developer"
+                }
+            ],
+            "description": "Implementation of the Token Bucket algorithm.",
+            "homepage": "https://github.com/bandwidth-throttle/token-bucket",
+            "keywords": [
+                "bandwidth",
+                "rate limit",
+                "rate limiting",
+                "throttle",
+                "throttling",
+                "token bucket"
+            ],
+            "support": {
+                "issues": "https://github.com/bandwidth-throttle/token-bucket/issues",
+                "source": "https://github.com/bandwidth-throttle/token-bucket/tree/master"
+            },
+            "time": "2017-10-13T19:09:01+00:00"
+        },
+        {
             "name": "doctrine/annotations",
             "version": "1.11.1",
             "source": {
@@ -2552,6 +2618,83 @@
             "time": "2020-09-24T10:56:15+00:00"
         },
         {
+            "name": "hyperf/rate-limit",
+            "version": "v2.0.12",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/hyperf/rate-limit.git",
+                "reference": "35af075274dcd41d5914409a788fa1e278bcfdaf"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/hyperf/rate-limit/zipball/35af075274dcd41d5914409a788fa1e278bcfdaf",
+                "reference": "35af075274dcd41d5914409a788fa1e278bcfdaf",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "bandwidth-throttle/token-bucket": "^2.0",
+                "hyperf/utils": "~2.0.0",
+                "php": ">=7.2",
+                "psr/container": "^1.0",
+                "psr/simple-cache": "^1.0"
+            },
+            "require-dev": {
+                "friendsofphp/php-cs-fixer": "^2.9",
+                "hyperf/contract": "~2.0.0",
+                "hyperf/di": "~2.0.0",
+                "hyperf/http-server": "~2.0.0",
+                "hyperf/redis": "~2.0.0",
+                "malukenho/docheader": "^0.1.6",
+                "mockery/mockery": "^1.0",
+                "phpunit/phpunit": "^7.0.0"
+            },
+            "suggest": {
+                "hyperf/contract": "Required to use annotations.",
+                "hyperf/di": "Required to use annotations.",
+                "hyperf/http-server": "Required to use annotations.",
+                "hyperf/redis": "Required to use RedisStorage."
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "2.0-dev"
+                },
+                "hyperf": {
+                    "config": "Hyperf\\RateLimit\\ConfigProvider"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Hyperf\\RateLimit\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "description": "A rate limiter implemented for Hyperf or other coroutine framework",
+            "homepage": "https://hyperf.io",
+            "keywords": [
+                "hyperf",
+                "php",
+                "rate-limiter",
+                "token-bucket"
+            ],
+            "support": {
+                "docs": "https://hyperf.wiki",
+                "issues": "https://github.com/hyperf/hyperf/issues",
+                "pull-request": "https://github.com/hyperf/hyperf/pulls",
+                "source": "https://github.com/hyperf/hyperf"
+            },
+            "time": "2020-09-14T04:43:30+00:00"
+        },
+        {
             "name": "hyperf/redis",
             "version": "v2.0.18",
             "source": {
@@ -3579,6 +3722,94 @@
             "time": "2020-08-20T13:22:28+00:00"
         },
         {
+            "name": "malkusch/lock",
+            "version": "v1.4",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/php-lock/lock.git",
+                "reference": "96cd2d82180fc87bd8ad45aac25486f82d9fbf4b"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/php-lock/lock/zipball/96cd2d82180fc87bd8ad45aac25486f82d9fbf4b",
+                "reference": "96cd2d82180fc87bd8ad45aac25486f82d9fbf4b",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "paragonie/random_compat": "^1|^2",
+                "php": ">=5.6",
+                "psr/log": "^1"
+            },
+            "require-dev": {
+                "eloquent/liberator": "^2.0",
+                "ext-memcached": "*",
+                "ext-pcntl": "*",
+                "ext-pdo_mysql": "*",
+                "ext-pdo_sqlite": "*",
+                "ext-redis": "*",
+                "johnkary/phpunit-speedtrap": "^1.0",
+                "kriswallsmith/spork": "^0.3",
+                "mikey179/vfsstream": "^1.5.0",
+                "php-mock/php-mock-phpunit": "^1",
+                "phpunit/phpunit": "^5",
+                "predis/predis": "~1.0",
+                "squizlabs/php_codesniffer": "^3.2"
+            },
+            "suggest": {
+                "ext-pnctl": "Enables locking with flock without busy waiting in CLI scripts"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "malkusch\\lock\\": "classes/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "WTFPL"
+            ],
+            "authors": [
+                {
+                    "name": "Markus Malkusch",
+                    "email": "markus@malkusch.de",
+                    "homepage": "http://markus.malkusch.de",
+                    "role": "Developer"
+                },
+                {
+                    "name": "Willem Stuursma-Ruwen",
+                    "email": "willem@stuursma.name",
+                    "role": "Developer"
+                }
+            ],
+            "description": "Mutex library for exclusive code execution.",
+            "homepage": "https://github.com/malkusch/lock",
+            "keywords": [
+                "advisory locks",
+                "cas",
+                "flock",
+                "lock",
+                "locking",
+                "memcache",
+                "mutex",
+                "mysql",
+                "postgresql",
+                "redis",
+                "redlock",
+                "semaphore"
+            ],
+            "support": {
+                "issues": "https://github.com/php-lock/lock/issues",
+                "source": "https://github.com/php-lock/lock/tree/v1.4"
+            },
+            "time": "2018-07-07T18:43:25+00:00"
+        },
+        {
             "name": "markrogoyski/math-php",
             "version": "v0.49.0",
             "source": {
@@ -4096,6 +4327,66 @@
             "time": "2020-05-18T22:20:46+00:00"
         },
         {
+            "name": "paragonie/random_compat",
+            "version": "v2.0.19",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/paragonie/random_compat.git",
+                "reference": "446fc9faa5c2a9ddf65eb7121c0af7e857295241"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/paragonie/random_compat/zipball/446fc9faa5c2a9ddf65eb7121c0af7e857295241",
+                "reference": "446fc9faa5c2a9ddf65eb7121c0af7e857295241",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "php": ">=5.2.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "4.*|5.*"
+            },
+            "suggest": {
+                "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
+            },
+            "type": "library",
+            "autoload": {
+                "files": [
+                    "lib/random.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Paragon Initiative Enterprises",
+                    "email": "security@paragonie.com",
+                    "homepage": "https://paragonie.com"
+                }
+            ],
+            "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
+            "keywords": [
+                "csprng",
+                "polyfill",
+                "pseudorandom",
+                "random"
+            ],
+            "support": {
+                "email": "info@paragonie.com",
+                "issues": "https://github.com/paragonie/random_compat/issues",
+                "source": "https://github.com/paragonie/random_compat"
+            },
+            "time": "2020-10-15T10:06:57+00:00"
+        },
+        {
             "name": "phpdocumentor/reflection-common",
             "version": "2.2.0",
             "source": {

+ 19 - 0
config/autoload/verify_code.php

@@ -0,0 +1,19 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * 验证码配置
+ * @link     https://www.hyperf.io
+ * @document https://hyperf.wiki
+ * @contact  group@hyperf.io
+ * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
+ */
+return [
+    'default' => [
+        'expire'=> 180,  // 有效时间
+        'curve' => true,  // 混淆曲线
+        'noise' => true,  // 噪点
+        'backColor' => '#ecf2f4', // 背景颜色
+        'fontColors'=> ['#2c3e50', '#c0392b', '#16a085', '#c0392b', '#8e44ad', '#303f9f', '#f57c00', '#795548'] // 字体颜色
+    ],
+];

+ 4 - 11
config/routes.php

@@ -13,16 +13,9 @@ use Hyperf\HttpServer\Router\Router;
 
 Router::addRoute(['GET', 'POST', 'HEAD'], '/', 'App\Controller\IndexController@index');
 
+// 验证码
+Router::addRoute(['GET', 'POST', 'HEAD'], '/api/get_captcha', 'App\Controller\CommonController@verifyCode');
+
 Router::get('/favicon.ico', function () {
     return '';
-});
-
-
-/*  自定义路由  */
-/*Router::addGroup('/api/', function ()  {
-    // 彩种数据
-    Router::post('lottery/test', 'App\Controller\LotteryController@test');
-
-
-//});
-},['middleware'=>[\App\Middleware\Auth\TokenMiddleware::class]]);*/
+});

+ 36 - 0
vendor/composer/InstalledVersions.php

@@ -24,6 +24,15 @@ private static $installed = array (
   ),
   'versions' => 
   array (
+    'bandwidth-throttle/token-bucket' => 
+    array (
+      'pretty_version' => '2.0.0',
+      'version' => '2.0.0.0',
+      'aliases' => 
+      array (
+      ),
+      'reference' => 'a0c31a4d0fbcf0c1a68c895fc91bf71455bcec08',
+    ),
     'composer/semver' => 
     array (
       'pretty_version' => '3.2.2',
@@ -416,6 +425,15 @@ private static $installed = array (
       ),
       'reference' => '125f0320c3f265629ff153b59a9ed4eb267ba514',
     ),
+    'hyperf/rate-limit' => 
+    array (
+      'pretty_version' => 'v2.0.12',
+      'version' => '2.0.12.0',
+      'aliases' => 
+      array (
+      ),
+      'reference' => '35af075274dcd41d5914409a788fa1e278bcfdaf',
+    ),
     'hyperf/redis' => 
     array (
       'pretty_version' => 'v2.0.18',
@@ -567,6 +585,15 @@ private static $installed = array (
       ),
       'reference' => 'c1123697f6a2ec29162b82f170dd4a491f524773',
     ),
+    'malkusch/lock' => 
+    array (
+      'pretty_version' => 'v1.4',
+      'version' => '1.4.0.0',
+      'aliases' => 
+      array (
+      ),
+      'reference' => '96cd2d82180fc87bd8ad45aac25486f82d9fbf4b',
+    ),
     'markrogoyski/math-php' => 
     array (
       'pretty_version' => 'v0.49.0',
@@ -656,6 +683,15 @@ private static $installed = array (
       ),
       'reference' => '4e49ac5f4088c52fa01ab2eb09e72e2af6d62a05',
     ),
+    'paragonie/random_compat' => 
+    array (
+      'pretty_version' => 'v2.0.19',
+      'version' => '2.0.19.0',
+      'aliases' => 
+      array (
+      ),
+      'reference' => '446fc9faa5c2a9ddf65eb7121c0af7e857295241',
+    ),
     'phar-io/manifest' => 
     array (
       'pretty_version' => '1.0.3',

+ 1 - 0
vendor/composer/autoload_files.php

@@ -28,6 +28,7 @@ return array(
     '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
     '870c221a18597bfcd5ed576d0fb64a19' => $vendorDir . '/opentracing/opentracing/src/OpenTracing/Tags.php',
     'd25d883add1ecab0d3a9ffec57f0f183' => $vendorDir . '/opentracing/opentracing/src/OpenTracing/Formats.php',
+    '5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php',
     '198ca788260cba849b8d9061ef2afeb7' => $vendorDir . '/openzipkin/zipkin/src/Zipkin/Propagation/Id.php',
     '1078d5a0858ccde97f683b735c9f5473' => $vendorDir . '/openzipkin/zipkin/src/Zipkin/Timestamp.php',
     '948c9b6b6a769d2db468357f07afb9ed' => $vendorDir . '/openzipkin/zipkin/src/Zipkin/Kind.php',

+ 3 - 0
vendor/composer/autoload_psr4.php

@@ -7,6 +7,8 @@ $baseDir = dirname($vendorDir);
 
 return array(
     'phpDocumentor\\Reflection\\' => array($vendorDir . '/phpdocumentor/reflection-common/src', $vendorDir . '/phpdocumentor/reflection-docblock/src', $vendorDir . '/phpdocumentor/type-resolver/src'),
+    'malkusch\\lock\\' => array($vendorDir . '/malkusch/lock/classes'),
+    'bandwidthThrottle\\tokenBucket\\' => array($vendorDir . '/bandwidth-throttle/token-bucket/classes'),
     'Zipkin\\' => array($vendorDir . '/openzipkin/zipkin/src/Zipkin'),
     'ZipkinOpenTracing\\' => array($vendorDir . '/jcchavezs/zipkin-opentracing/src/ZipkinOpenTracing'),
     'Webmozart\\Assert\\' => array($vendorDir . '/webmozart/assert/src'),
@@ -61,6 +63,7 @@ return array(
     'Hyperf\\RpcClient\\' => array($vendorDir . '/hyperf/rpc-client/src'),
     'Hyperf\\Resource\\' => array($vendorDir . '/hyperf/resource/src'),
     'Hyperf\\Redis\\' => array($vendorDir . '/hyperf/redis/src'),
+    'Hyperf\\RateLimit\\' => array($vendorDir . '/hyperf/rate-limit/src'),
     'Hyperf\\Process\\' => array($vendorDir . '/hyperf/process/src'),
     'Hyperf\\Pool\\' => array($vendorDir . '/hyperf/pool/src'),
     'Hyperf\\Paginator\\' => array($vendorDir . '/hyperf/paginator/src'),

+ 22 - 0
vendor/composer/autoload_static.php

@@ -29,6 +29,7 @@ class ComposerStaticInit9622285a5a7446d42ea979e0e2b28dd5
         '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
         '870c221a18597bfcd5ed576d0fb64a19' => __DIR__ . '/..' . '/opentracing/opentracing/src/OpenTracing/Tags.php',
         'd25d883add1ecab0d3a9ffec57f0f183' => __DIR__ . '/..' . '/opentracing/opentracing/src/OpenTracing/Formats.php',
+        '5255c38a0faeba867671b61dfda6d864' => __DIR__ . '/..' . '/paragonie/random_compat/lib/random.php',
         '198ca788260cba849b8d9061ef2afeb7' => __DIR__ . '/..' . '/openzipkin/zipkin/src/Zipkin/Propagation/Id.php',
         '1078d5a0858ccde97f683b735c9f5473' => __DIR__ . '/..' . '/openzipkin/zipkin/src/Zipkin/Timestamp.php',
         '948c9b6b6a769d2db468357f07afb9ed' => __DIR__ . '/..' . '/openzipkin/zipkin/src/Zipkin/Kind.php',
@@ -44,6 +45,14 @@ class ComposerStaticInit9622285a5a7446d42ea979e0e2b28dd5
         array (
             'phpDocumentor\\Reflection\\' => 25,
         ),
+        'm' => 
+        array (
+            'malkusch\\lock\\' => 14,
+        ),
+        'b' => 
+        array (
+            'bandwidthThrottle\\tokenBucket\\' => 30,
+        ),
         'Z' => 
         array (
             'Zipkin\\' => 7,
@@ -124,6 +133,7 @@ class ComposerStaticInit9622285a5a7446d42ea979e0e2b28dd5
             'Hyperf\\RpcClient\\' => 17,
             'Hyperf\\Resource\\' => 16,
             'Hyperf\\Redis\\' => 13,
+            'Hyperf\\RateLimit\\' => 17,
             'Hyperf\\Process\\' => 15,
             'Hyperf\\Pool\\' => 12,
             'Hyperf\\Paginator\\' => 17,
@@ -198,6 +208,14 @@ class ComposerStaticInit9622285a5a7446d42ea979e0e2b28dd5
             1 => __DIR__ . '/..' . '/phpdocumentor/reflection-docblock/src',
             2 => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src',
         ),
+        'malkusch\\lock\\' => 
+        array (
+            0 => __DIR__ . '/..' . '/malkusch/lock/classes',
+        ),
+        'bandwidthThrottle\\tokenBucket\\' => 
+        array (
+            0 => __DIR__ . '/..' . '/bandwidth-throttle/token-bucket/classes',
+        ),
         'Zipkin\\' => 
         array (
             0 => __DIR__ . '/..' . '/openzipkin/zipkin/src/Zipkin',
@@ -415,6 +433,10 @@ class ComposerStaticInit9622285a5a7446d42ea979e0e2b28dd5
         array (
             0 => __DIR__ . '/..' . '/hyperf/redis/src',
         ),
+        'Hyperf\\RateLimit\\' => 
+        array (
+            0 => __DIR__ . '/..' . '/hyperf/rate-limit/src',
+        ),
         'Hyperf\\Process\\' => 
         array (
             0 => __DIR__ . '/..' . '/hyperf/process/src',

+ 303 - 0
vendor/composer/installed.json

@@ -1,6 +1,75 @@
 {
     "packages": [
         {
+            "name": "bandwidth-throttle/token-bucket",
+            "version": "2.0.0",
+            "version_normalized": "2.0.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/bandwidth-throttle/token-bucket.git",
+                "reference": "a0c31a4d0fbcf0c1a68c895fc91bf71455bcec08"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/bandwidth-throttle/token-bucket/zipball/a0c31a4d0fbcf0c1a68c895fc91bf71455bcec08",
+                "reference": "a0c31a4d0fbcf0c1a68c895fc91bf71455bcec08",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "ext-bcmath": "*",
+                "malkusch/lock": "^1",
+                "php": ">=5.6"
+            },
+            "require-dev": {
+                "ext-redis": "^2.2.4|^3",
+                "mikey179/vfsstream": "^1.5.0",
+                "php-mock/php-mock-phpunit": "^1",
+                "phpunit/phpunit": "^5",
+                "predis/predis": "^1"
+            },
+            "time": "2017-10-13T19:09:01+00:00",
+            "type": "library",
+            "installation-source": "dist",
+            "autoload": {
+                "psr-4": {
+                    "bandwidthThrottle\\tokenBucket\\": "classes/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "WTFPL"
+            ],
+            "authors": [
+                {
+                    "name": "Markus Malkusch",
+                    "email": "markus@malkusch.de",
+                    "homepage": "http://markus.malkusch.de",
+                    "role": "Developer"
+                }
+            ],
+            "description": "Implementation of the Token Bucket algorithm.",
+            "homepage": "https://github.com/bandwidth-throttle/token-bucket",
+            "keywords": [
+                "bandwidth",
+                "rate limit",
+                "rate limiting",
+                "throttle",
+                "throttling",
+                "token bucket"
+            ],
+            "support": {
+                "issues": "https://github.com/bandwidth-throttle/token-bucket/issues",
+                "source": "https://github.com/bandwidth-throttle/token-bucket/tree/master"
+            },
+            "install-path": "../bandwidth-throttle/token-bucket"
+        },
+        {
             "name": "composer/semver",
             "version": "3.2.2",
             "version_normalized": "3.2.2.0",
@@ -3056,6 +3125,86 @@
             "install-path": "../hyperf/process"
         },
         {
+            "name": "hyperf/rate-limit",
+            "version": "v2.0.12",
+            "version_normalized": "2.0.12.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/hyperf/rate-limit.git",
+                "reference": "35af075274dcd41d5914409a788fa1e278bcfdaf"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/hyperf/rate-limit/zipball/35af075274dcd41d5914409a788fa1e278bcfdaf",
+                "reference": "35af075274dcd41d5914409a788fa1e278bcfdaf",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "bandwidth-throttle/token-bucket": "^2.0",
+                "hyperf/utils": "~2.0.0",
+                "php": ">=7.2",
+                "psr/container": "^1.0",
+                "psr/simple-cache": "^1.0"
+            },
+            "require-dev": {
+                "friendsofphp/php-cs-fixer": "^2.9",
+                "hyperf/contract": "~2.0.0",
+                "hyperf/di": "~2.0.0",
+                "hyperf/http-server": "~2.0.0",
+                "hyperf/redis": "~2.0.0",
+                "malukenho/docheader": "^0.1.6",
+                "mockery/mockery": "^1.0",
+                "phpunit/phpunit": "^7.0.0"
+            },
+            "suggest": {
+                "hyperf/contract": "Required to use annotations.",
+                "hyperf/di": "Required to use annotations.",
+                "hyperf/http-server": "Required to use annotations.",
+                "hyperf/redis": "Required to use RedisStorage."
+            },
+            "time": "2020-09-14T04:43:30+00:00",
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "2.0-dev"
+                },
+                "hyperf": {
+                    "config": "Hyperf\\RateLimit\\ConfigProvider"
+                }
+            },
+            "installation-source": "dist",
+            "autoload": {
+                "psr-4": {
+                    "Hyperf\\RateLimit\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "description": "A rate limiter implemented for Hyperf or other coroutine framework",
+            "homepage": "https://hyperf.io",
+            "keywords": [
+                "hyperf",
+                "php",
+                "rate-limiter",
+                "token-bucket"
+            ],
+            "support": {
+                "docs": "https://hyperf.wiki",
+                "issues": "https://github.com/hyperf/hyperf/issues",
+                "pull-request": "https://github.com/hyperf/hyperf/pulls",
+                "source": "https://github.com/hyperf/hyperf"
+            },
+            "install-path": "../hyperf/rate-limit"
+        },
+        {
             "name": "hyperf/redis",
             "version": "v2.0.18",
             "version_normalized": "2.0.18.0",
@@ -4194,6 +4343,97 @@
             "install-path": "../lcobucci/jwt"
         },
         {
+            "name": "malkusch/lock",
+            "version": "v1.4",
+            "version_normalized": "1.4.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/php-lock/lock.git",
+                "reference": "96cd2d82180fc87bd8ad45aac25486f82d9fbf4b"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/php-lock/lock/zipball/96cd2d82180fc87bd8ad45aac25486f82d9fbf4b",
+                "reference": "96cd2d82180fc87bd8ad45aac25486f82d9fbf4b",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "paragonie/random_compat": "^1|^2",
+                "php": ">=5.6",
+                "psr/log": "^1"
+            },
+            "require-dev": {
+                "eloquent/liberator": "^2.0",
+                "ext-memcached": "*",
+                "ext-pcntl": "*",
+                "ext-pdo_mysql": "*",
+                "ext-pdo_sqlite": "*",
+                "ext-redis": "*",
+                "johnkary/phpunit-speedtrap": "^1.0",
+                "kriswallsmith/spork": "^0.3",
+                "mikey179/vfsstream": "^1.5.0",
+                "php-mock/php-mock-phpunit": "^1",
+                "phpunit/phpunit": "^5",
+                "predis/predis": "~1.0",
+                "squizlabs/php_codesniffer": "^3.2"
+            },
+            "suggest": {
+                "ext-pnctl": "Enables locking with flock without busy waiting in CLI scripts"
+            },
+            "time": "2018-07-07T18:43:25+00:00",
+            "type": "library",
+            "installation-source": "dist",
+            "autoload": {
+                "psr-4": {
+                    "malkusch\\lock\\": "classes/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "WTFPL"
+            ],
+            "authors": [
+                {
+                    "name": "Markus Malkusch",
+                    "email": "markus@malkusch.de",
+                    "homepage": "http://markus.malkusch.de",
+                    "role": "Developer"
+                },
+                {
+                    "name": "Willem Stuursma-Ruwen",
+                    "email": "willem@stuursma.name",
+                    "role": "Developer"
+                }
+            ],
+            "description": "Mutex library for exclusive code execution.",
+            "homepage": "https://github.com/malkusch/lock",
+            "keywords": [
+                "advisory locks",
+                "cas",
+                "flock",
+                "lock",
+                "locking",
+                "memcache",
+                "mutex",
+                "mysql",
+                "postgresql",
+                "redis",
+                "redlock",
+                "semaphore"
+            ],
+            "support": {
+                "issues": "https://github.com/php-lock/lock/issues",
+                "source": "https://github.com/php-lock/lock/tree/v1.4"
+            },
+            "install-path": "../malkusch/lock"
+        },
+        {
             "name": "markrogoyski/math-php",
             "version": "v0.49.0",
             "version_normalized": "0.49.0.0",
@@ -4877,6 +5117,69 @@
             "install-path": "../openzipkin/zipkin"
         },
         {
+            "name": "paragonie/random_compat",
+            "version": "v2.0.19",
+            "version_normalized": "2.0.19.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/paragonie/random_compat.git",
+                "reference": "446fc9faa5c2a9ddf65eb7121c0af7e857295241"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/paragonie/random_compat/zipball/446fc9faa5c2a9ddf65eb7121c0af7e857295241",
+                "reference": "446fc9faa5c2a9ddf65eb7121c0af7e857295241",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "php": ">=5.2.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "4.*|5.*"
+            },
+            "suggest": {
+                "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
+            },
+            "time": "2020-10-15T10:06:57+00:00",
+            "type": "library",
+            "installation-source": "dist",
+            "autoload": {
+                "files": [
+                    "lib/random.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Paragon Initiative Enterprises",
+                    "email": "security@paragonie.com",
+                    "homepage": "https://paragonie.com"
+                }
+            ],
+            "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
+            "keywords": [
+                "csprng",
+                "polyfill",
+                "pseudorandom",
+                "random"
+            ],
+            "support": {
+                "email": "info@paragonie.com",
+                "issues": "https://github.com/paragonie/random_compat/issues",
+                "source": "https://github.com/paragonie/random_compat"
+            },
+            "install-path": "../paragonie/random_compat"
+        },
+        {
             "name": "phar-io/manifest",
             "version": "1.0.3",
             "version_normalized": "1.0.3.0",

+ 36 - 0
vendor/composer/installed.php

@@ -11,6 +11,15 @@
   ),
   'versions' => 
   array (
+    'bandwidth-throttle/token-bucket' => 
+    array (
+      'pretty_version' => '2.0.0',
+      'version' => '2.0.0.0',
+      'aliases' => 
+      array (
+      ),
+      'reference' => 'a0c31a4d0fbcf0c1a68c895fc91bf71455bcec08',
+    ),
     'composer/semver' => 
     array (
       'pretty_version' => '3.2.2',
@@ -403,6 +412,15 @@
       ),
       'reference' => '125f0320c3f265629ff153b59a9ed4eb267ba514',
     ),
+    'hyperf/rate-limit' => 
+    array (
+      'pretty_version' => 'v2.0.12',
+      'version' => '2.0.12.0',
+      'aliases' => 
+      array (
+      ),
+      'reference' => '35af075274dcd41d5914409a788fa1e278bcfdaf',
+    ),
     'hyperf/redis' => 
     array (
       'pretty_version' => 'v2.0.18',
@@ -554,6 +572,15 @@
       ),
       'reference' => 'c1123697f6a2ec29162b82f170dd4a491f524773',
     ),
+    'malkusch/lock' => 
+    array (
+      'pretty_version' => 'v1.4',
+      'version' => '1.4.0.0',
+      'aliases' => 
+      array (
+      ),
+      'reference' => '96cd2d82180fc87bd8ad45aac25486f82d9fbf4b',
+    ),
     'markrogoyski/math-php' => 
     array (
       'pretty_version' => 'v0.49.0',
@@ -643,6 +670,15 @@
       ),
       'reference' => '4e49ac5f4088c52fa01ab2eb09e72e2af6d62a05',
     ),
+    'paragonie/random_compat' => 
+    array (
+      'pretty_version' => 'v2.0.19',
+      'version' => '2.0.19.0',
+      'aliases' => 
+      array (
+      ),
+      'reference' => '446fc9faa5c2a9ddf65eb7121c0af7e857295241',
+    ),
     'phar-io/manifest' => 
     array (
       'pretty_version' => '1.0.3',