From e3f7f72fb6094eeb2540fc7a0e52ce6223880095 Mon Sep 17 00:00:00 2001 From: lujunyi Date: Thu, 20 Apr 2023 17:26:21 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=88=B0=E6=94=AF?= =?UTF-8?q?=E6=8C=81hyperf3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 14 +++++++------- src/Aspect/AuthAspect.php | 31 ++++++++++--------------------- src/Guards/JwtGuard.php | 2 +- src/Guards/SessionGuard.php | 2 +- 4 files changed, 19 insertions(+), 30 deletions(-) diff --git a/composer.json b/composer.json index 448783e..16d7879 100644 --- a/composer.json +++ b/composer.json @@ -31,13 +31,13 @@ "require": { "php": ">=7.3", "ext-swoole": ">=4.5", - "hyperf-ext/hashing": "~2.2.0", - "hyperf/command": "~2.2.0", - "hyperf/config": "~2.2.0", - "hyperf/database": "~2.2.0", - "hyperf/db-connection": "~2.2.0", - "hyperf/di": "~2.2.0", - "hyperf/framework": "~2.2.0" + "hyperf-ext/hashing": "~3.0.0", + "hyperf/command": "~3.0.0", + "hyperf/config": "~3.0.0", + "hyperf/database": "~3.0.0", + "hyperf/db-connection": "~3.0.0", + "hyperf/di": "~3.0.0", + "hyperf/framework": "~3.0.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.0", diff --git a/src/Aspect/AuthAspect.php b/src/Aspect/AuthAspect.php index f782838..53fb881 100644 --- a/src/Aspect/AuthAspect.php +++ b/src/Aspect/AuthAspect.php @@ -1,6 +1,6 @@ getAnnotationMetadata(); - $authAnnotation = $annotation->class[Auth::class] ?? $annotation->method[Auth::class]; - $guards = empty($authAnnotation->guards) ? [null] : $authAnnotation->guards; $passable = $authAnnotation->passable; - foreach ($guards as $name) { $guard = $this->auth->guard($name); - - if (! $guard->user() instanceof AuthenticatableInterface and ! $passable) { + if (!$guard->user() instanceof AuthenticatableInterface and !$passable) { throw new AuthenticationException('Unauthenticated.', $guards); } } - return $proceedingJoinPoint->process(); } -} +} \ No newline at end of file diff --git a/src/Guards/JwtGuard.php b/src/Guards/JwtGuard.php index a3cf275..5bc7bd7 100644 --- a/src/Guards/JwtGuard.php +++ b/src/Guards/JwtGuard.php @@ -12,7 +12,7 @@ use BadMethodCallException; use Hyperf\HttpServer\Contract\RequestInterface; -use Hyperf\Utils\Traits\Macroable; +use Hyperf\Macroable\Macroable; use HyperfExt\Auth\Contracts\AuthenticatableInterface; use HyperfExt\Auth\Contracts\StatelessGuardInterface; use HyperfExt\Auth\Contracts\UserProviderInterface; diff --git a/src/Guards/SessionGuard.php b/src/Guards/SessionGuard.php index aab78b4..007a0d8 100644 --- a/src/Guards/SessionGuard.php +++ b/src/Guards/SessionGuard.php @@ -13,7 +13,7 @@ use Hyperf\Contract\SessionInterface; use Hyperf\HttpMessage\Cookie\Cookie; use Hyperf\Utils\Str; -use Hyperf\Utils\Traits\Macroable; +use Hyperf\Macroable\Macroable; use HyperfExt\Auth\Contracts\AuthenticatableInterface; use HyperfExt\Auth\Contracts\StatefulGuardInterface; use HyperfExt\Auth\Contracts\SupportsBasicAuthInterface; From 4a20340fe6afcbc358bfb266744a0c7bbc78a485 Mon Sep 17 00:00:00 2001 From: lujunyi Date: Thu, 20 Apr 2023 17:35:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=88=B0=E6=94=AF?= =?UTF-8?q?=E6=8C=81hyperf3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 16d7879..fe67677 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ } }, "require": { - "php": ">=7.3", + "php": ">=8.0", "ext-swoole": ">=4.5", "hyperf-ext/hashing": "~3.0.0", "hyperf/command": "~3.0.0", @@ -41,7 +41,7 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.0", - "hyperf/testing": "~2.2.0", + "hyperf/testing": "~3.0.0", "phpstan/phpstan": "^0.12", "swoole/ide-helper": "dev-master", "mockery/mockery": "^1.0"