From f94d5946028f86bdb75691d666fc3c637cd94fbe Mon Sep 17 00:00:00 2001 From: Apple Date: Thu, 4 Nov 2021 15:21:10 +0800 Subject: [PATCH] =?UTF-8?q?@1104-=E4=BF=AE=E6=94=B9=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E9=99=90=E9=A2=91=E4=B8=8A=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/Middleware/AuthenticateWithHeader.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Http/Middleware/AuthenticateWithHeader.php b/src/Http/Middleware/AuthenticateWithHeader.php index 4b4587b..e2800ae 100644 --- a/src/Http/Middleware/AuthenticateWithHeader.php +++ b/src/Http/Middleware/AuthenticateWithHeader.php @@ -27,6 +27,7 @@ use Discuz\Auth\Guest; use Discuz\Base\DzqLog; use Discuz\Cache\CacheManager; use Discuz\Common\Utils; +use Discuz\Contracts\Setting\SettingsRepository; use Illuminate\Support\Arr; use League\OAuth2\Server\CryptKey; use League\OAuth2\Server\ResourceServer; @@ -194,6 +195,12 @@ class AuthenticateWithHeader implements MiddlewareInterface return true; } $method = strtolower($method); + + if ($this->isAttachments($api, $method) || $this->isCoskey($api, $method)) { + $maxUploadNum = app()->make(SettingsRepository::class)->get('support_max_upload_attachment_num', 'default'); + $maxLimit = $maxUploadNum ? (int)$maxUploadNum : 20; + } + if (empty($userId)) { $key = 'api_limit_by_ip_' . md5($ip . $api . $method); } else { @@ -203,14 +210,14 @@ class AuthenticateWithHeader implements MiddlewareInterface return $this->setLimit($key, $method, 10, 10 * 60); } if ($this->isAttachments($api, $method)) { - return $this->setLimit($key, $method, 20, 5 * 60); + return $this->setLimit($key, $method, $maxLimit, 5 * 60); } if ($this->isPoll($api)) { return $this->setLimit($key, $method, 200, 60); } if ($this->isCoskey($api, $method)) { - return $this->setLimit($key, $method, 20, 30); + return $this->setLimit($key, $method, $maxLimit, 30); } if ($this->isPayOrder($api, $method)) { return $this->setLimit($key, $method, 3, 10); -- Gitee