From 5f9b2cfa6aa8d660e710b0c86044285e0d55ba66 Mon Sep 17 00:00:00 2001 From: frank Date: Thu, 14 Nov 2024 15:28:44 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=A7=84=E8=8C=83=E5=BA=94=E7=94=A8=20name?= =?UTF-8?q?space?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AppStore/src/Command/CreateCommand.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/AppStore/src/Command/CreateCommand.php b/src/AppStore/src/Command/CreateCommand.php index 6d5cf75..afb8006 100644 --- a/src/AppStore/src/Command/CreateCommand.php +++ b/src/AppStore/src/Command/CreateCommand.php @@ -60,6 +60,13 @@ public function __invoke(): int return AbstractCommand::SUCCESS; } + public function createNamespace(string $path, string $name): string + { + $pluginPath = Str::replace(Plugin::PLUGIN_PATH . '/', '', $path); + list($orgName) = explode('/', $pluginPath); + return 'Plugin\\' . Str::studly($orgName) . '\\' . Str::studly($name); + } + public function createMineJson(string $path, string $name, PluginTypeEnum $pluginType): void { $output = new \stdClass(); @@ -74,7 +81,7 @@ public function createMineJson(string $path, string $name, PluginTypeEnum $plugi ], ]; if ($pluginType === PluginTypeEnum::Backend || $pluginType === PluginTypeEnum::Mix) { - $namespace = 'Plugin\\' . ucwords(str_replace('/', '\\', Str::studly($name))); + $namespace = $this->createNamespace($path, $name) ?? 'Plugin\\' . ucwords(str_replace('/', '\\', Str::studly($name))); $this->createInstallScript($namespace, $path); $this->createUninstallScript($namespace, $path); From 2d7fbd0b30d69b9543d836c3dfc81c8147e4a29c Mon Sep 17 00:00:00 2001 From: frank Date: Thu, 14 Nov 2024 15:46:15 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=A7=84=E8=8C=83=E5=BA=94=E7=94=A8=20name?= =?UTF-8?q?space?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AppStore/src/Command/CreateCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/AppStore/src/Command/CreateCommand.php b/src/AppStore/src/Command/CreateCommand.php index afb8006..7ef070b 100644 --- a/src/AppStore/src/Command/CreateCommand.php +++ b/src/AppStore/src/Command/CreateCommand.php @@ -69,8 +69,10 @@ public function createNamespace(string $path, string $name): string public function createMineJson(string $path, string $name, PluginTypeEnum $pluginType): void { + $pluginPath = Str::replace(Plugin::PLUGIN_PATH . '/', '', $path); + $output = new \stdClass(); - $output->name = $name; + $output->name = $pluginPath ?? $name; $output->version = '1.0.0'; $output->type = $pluginType->value; $output->description = $this->input->getOption('description') ?: 'This is a sample plugin'; From b8edb45a46018a83257d4e84877893691eefdaa8 Mon Sep 17 00:00:00 2001 From: frank Date: Wed, 4 Dec 2024 15:35:53 +0800 Subject: [PATCH 3/3] =?UTF-8?q?refactor:=20=E8=AE=A9token=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=9B=B4=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Jwt/AbstractJwt.php | 4 +++- src/Jwt/AccessTokenConstraint.php | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/Jwt/AccessTokenConstraint.php diff --git a/src/Jwt/AbstractJwt.php b/src/Jwt/AbstractJwt.php index 107bfcd..7f208ad 100644 --- a/src/Jwt/AbstractJwt.php +++ b/src/Jwt/AbstractJwt.php @@ -31,6 +31,7 @@ public function __construct( private readonly array $config, private readonly CacheManager $cacheManager, private readonly Clock $clock, + private readonly AccessTokenConstraint $accessTokenConstraint, private readonly RefreshTokenConstraint $refreshTokenConstraint ) {} @@ -72,7 +73,8 @@ public function parserRefreshToken(string $refreshToken): UnencryptedToken $this->clock, $this->clock->now()->diff($this->getRefreshExpireAt($this->clock->now())) ), - $this->getBlackListConstraint() + $this->getBlackListConstraint(), + $this->accessTokenConstraint ); } diff --git a/src/Jwt/AccessTokenConstraint.php b/src/Jwt/AccessTokenConstraint.php new file mode 100644 index 0000000..b2caaae --- /dev/null +++ b/src/Jwt/AccessTokenConstraint.php @@ -0,0 +1,27 @@ +isRelatedTo('refresh')) { + throw ConstraintViolation::error('Token is not a refresh token', $this); + } + } +}