From 955171e180033a00bc1a5820c4b2bf8c4b43b571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 11 Sep 2020 20:06:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- System/Jwt/Jwt.php | 39 +++++++++++------------------------ System/Process/Leafleting.php | 29 -------------------------- System/Process/System.php | 12 ----------- System/Process/config.php | 13 ------------ composer.json | 3 ++- 5 files changed, 14 insertions(+), 82 deletions(-) delete mode 100644 System/Process/Leafleting.php delete mode 100644 System/Process/System.php delete mode 100644 System/Process/config.php diff --git a/System/Jwt/Jwt.php b/System/Jwt/Jwt.php index 8243dfd2..37cb64c4 100644 --- a/System/Jwt/Jwt.php +++ b/System/Jwt/Jwt.php @@ -64,9 +64,6 @@ kIHG5j+Qga2CgXqI2Y5URXGz5XlsNbMNFUrnWcbpqEbW5O6/BgHLLSDEyQgwbygN mlAZUEjsoaT9vjvjGTxl3uCm0TX5KTgtSJIt2kA1tYVjQef+/iZTHxY= -----END RSA PRIVATE KEY-----'; - /** @var Jwt */ - private static $instance; - /** * @throws ConfigException @@ -106,16 +103,6 @@ mlAZUEjsoaT9vjvjGTxl3uCm0TX5KTgtSJIt2kA1tYVjQef+/iZTHxY= $this->private = $privateKey; } - /** - * @return Jwt - */ - private static function getInstance() - { - if (!(static::$instance instanceof Jwt)) { - static::$instance = new Jwt(); - } - return static::$instance; - } /** * @param int|string $unionId @@ -272,7 +259,7 @@ mlAZUEjsoaT9vjvjGTxl3uCm0TX5KTgtSJIt2kA1tYVjQef+/iZTHxY= * @return string * @throws Exception */ - private function authKey($_source, $token) + private function authKey(string $_source, string $token) { $source = $this->getSource(); if (!empty($_source)) $source = $_source; @@ -297,7 +284,7 @@ mlAZUEjsoaT9vjvjGTxl3uCm0TX5KTgtSJIt2kA1tYVjQef+/iZTHxY= * * @return string */ - private function token($user, $param = [], $requestTime = NULL) + private function token(int $user, $param = [], $requestTime = NULL) { $str = ''; @@ -319,7 +306,7 @@ mlAZUEjsoaT9vjvjGTxl3uCm0TX5KTgtSJIt2kA1tYVjQef+/iZTHxY= * @return mixed * 将字符串替换成指定格式 */ - private function preg($str) + private function preg(string $str) { $preg = '/(\w{10})(\w{3})(\w{4})(\w{9})(\w{6})/'; return preg_replace($preg, '$1-$2-$3-$4-$5', $str); @@ -328,9 +315,9 @@ mlAZUEjsoaT9vjvjGTxl3uCm0TX5KTgtSJIt2kA1tYVjQef+/iZTHxY= /** * @param int $user * @return string[] - * @throws + * @throws Exception */ - public function clear($user) + public function clear(int $user) { $this->user = $user; $redis = $this->getRedis(); @@ -353,9 +340,9 @@ mlAZUEjsoaT9vjvjGTxl3uCm0TX5KTgtSJIt2kA1tYVjQef+/iZTHxY= * @param array $data * @param int $user * @return bool - * @throws + * @throws AuthException */ - public function check($data, $user) + public function check(array $data, int $user) { $this->data = $data; $this->user = $user; @@ -382,16 +369,13 @@ mlAZUEjsoaT9vjvjGTxl3uCm0TX5KTgtSJIt2kA1tYVjQef+/iZTHxY= $this->data = request()->headers->getHeaders(); $model = $this->getUserModel(); if (empty($model)) { - return '授权信息已过期!'; -// throw new AuthException('授权信息已过期!'); + throw new AuthException('授权信息已过期!'); } if (!isset($model['user'])) { - return '授权信息错误!'; -// throw new AuthException('授权信息错误!'); + throw new AuthException('授权信息错误!'); } if (!$this->check($this->data, $model['user'])) { - return '授权信息不合法!'; -// throw new AuthException('授权信息不合法!'); + throw new AuthException('授权信息不合法!'); } $this->expireRefresh(); @@ -400,11 +384,12 @@ mlAZUEjsoaT9vjvjGTxl3uCm0TX5KTgtSJIt2kA1tYVjQef+/iZTHxY= /** * @param array $header + * @return false|mixed * @throws Exception */ public static function checkAuth(array $header = []) { - $instance = static::getInstance(); + $instance = Snowflake::app()->getJwt(); if (empty($header)) { $header = request()->headers->getHeaders(); } diff --git a/System/Process/Leafleting.php b/System/Process/Leafleting.php deleted file mode 100644 index 3486adf0..00000000 --- a/System/Process/Leafleting.php +++ /dev/null @@ -1,29 +0,0 @@ -read()); - }); - } - -} diff --git a/System/Process/System.php b/System/Process/System.php deleted file mode 100644 index 885c418a..00000000 --- a/System/Process/System.php +++ /dev/null @@ -1,12 +0,0 @@ - [ - 'Leafleting' => Leafleting::class, - 'inotify' => ServerInotify::class, - ] - -]; diff --git a/composer.json b/composer.json index 1cb10470..15a78187 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,8 @@ "ext-xml": "*", "ext-memcached": "*", "ext-inotify": "*", - "ext-curl": "*" + "ext-curl": "*", + "ext-openssl": "*" }, "autoload": { "psr-4": {