diff --git a/app/Http/Api/Controllers/Controller.php b/app/Http/Api/Controllers/Controller.php index 60c3dac3..74d227b9 100644 --- a/app/Http/Api/Controllers/Controller.php +++ b/app/Http/Api/Controllers/Controller.php @@ -30,8 +30,6 @@ class Controller extends \Phalcon\Mvc\Controller $this->setCors(); } - $this->checkRateLimit(); - return true; } diff --git a/app/Http/Home/Controllers/Controller.php b/app/Http/Home/Controllers/Controller.php index 8ceeeb3f..43cac9a0 100644 --- a/app/Http/Home/Controllers/Controller.php +++ b/app/Http/Home/Controllers/Controller.php @@ -77,8 +77,6 @@ class Controller extends \Phalcon\Mvc\Controller $this->checkCsrfToken(); } - $this->checkRateLimit(); - return true; } diff --git a/app/Http/Home/Controllers/LayerController.php b/app/Http/Home/Controllers/LayerController.php index 18f58473..0c1ca60f 100644 --- a/app/Http/Home/Controllers/LayerController.php +++ b/app/Http/Home/Controllers/LayerController.php @@ -37,8 +37,6 @@ class LayerController extends \Phalcon\Mvc\Controller $this->checkCsrfToken(); } - $this->checkRateLimit(); - return true; } diff --git a/app/Services/Logic/Order/OrderConfirm.php b/app/Services/Logic/Order/OrderConfirm.php index 06882b11..57a85041 100644 --- a/app/Services/Logic/Order/OrderConfirm.php +++ b/app/Services/Logic/Order/OrderConfirm.php @@ -121,7 +121,6 @@ class OrderConfirm extends LogicService 'lesson_count' => $course->lesson_count, 'study_expiry' => $course->study_expiry, 'refund_expiry' => $course->refund_expiry, - 'origin_price' => $course->origin_price, 'market_price' => $course->market_price, 'vip_price' => $course->vip_price, ]; diff --git a/app/Services/Throttle.php b/app/Services/Throttle.php deleted file mode 100644 index 77bc8cbc..00000000 --- a/app/Services/Throttle.php +++ /dev/null @@ -1,65 +0,0 @@ -getConfig(); - - if (!$config->path('throttle.enabled')) { - return true; - } - - $cache = $this->getCache(); - - $sign = $this->getRequestSignature(); - - $cacheKey = $this->getCacheKey($sign); - - if ($cache->ttl($cacheKey) < 1) { - $cache->save($cacheKey, 0, $config->path('throttle.lifetime')); - } - - $rateLimit = $cache->get($cacheKey); - - if ($rateLimit >= $config->path('throttle.rate_limit')) { - return false; - } - - $cache->increment($cacheKey, 1); - - return true; - } - - protected function getRequestSignature() - { - $authUser = $this->getAuthUser(); - - if (!empty($authUser['id'])) { - return md5($authUser['id']); - } - - $httpHost = $this->request->getHttpHost(); - $clientAddress = $this->request->getClientAddress(); - - if ($httpHost && $clientAddress) { - return md5($httpHost . '|' . $clientAddress); - } - - throw new \RuntimeException('Unable to generate request signature'); - } - - protected function getCacheKey($sign) - { - return "throttle:{$sign}"; - } - -} diff --git a/app/Traits/Security.php b/app/Traits/Security.php index 7934d654..d0b14b6b 100644 --- a/app/Traits/Security.php +++ b/app/Traits/Security.php @@ -28,13 +28,6 @@ trait Security $validator->checkHttpReferer(); } - public function checkRateLimit() - { - $validator = new SecurityValidator(); - - $validator->checkRateLimit(); - } - public function isNotSafeRequest() { /** diff --git a/app/Validators/Security.php b/app/Validators/Security.php index 411077db..45c6f7fb 100644 --- a/app/Validators/Security.php +++ b/app/Validators/Security.php @@ -8,9 +8,7 @@ namespace App\Validators; use App\Exceptions\BadRequest as BadRequestException; -use App\Exceptions\ServiceUnavailable as ServiceUnavailableException; use App\Library\CsrfToken as CsrfTokenService; -use App\Services\Throttle as ThrottleService; class Security extends Validator { @@ -53,17 +51,6 @@ class Security extends Validator } } - public function checkRateLimit() - { - $service = new ThrottleService(); - - $result = $service->checkRateLimit(); - - if (!$result) { - throw new ServiceUnavailableException('security.too_many_requests'); - } - } - protected function getCsrfWhitelist() { return []; diff --git a/config/config.default.php b/config/config.default.php index 901157a4..38926da4 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -147,21 +147,6 @@ $config['cors']['allow_headers'] = '*'; */ $config['cors']['allow_methods'] = ['GET', 'POST', 'OPTIONS']; -/** - * 限流开启 - */ -$config['throttle']['enabled'] = true; - -/** - * 有效期(秒) - */ -$config['throttle']['lifetime'] = 60; - -/** - * 限流频率 - */ -$config['throttle']['rate_limit'] = 60; - /** * 客户端ping服务端间隔(秒) */ diff --git a/config/errors.php b/config/errors.php index 74a3e970..207c509d 100644 --- a/config/errors.php +++ b/config/errors.php @@ -22,7 +22,6 @@ $error['sys.unknown_error'] = '未知错误'; /** * 安全相关 */ -$error['security.too_many_requests'] = '请求过于频繁'; $error['security.invalid_csrf_token'] = '无效的CSRF令牌'; $error['security.invalid_http_referer'] = '无效请求来源';