From 74fbe888fc77f328d6c7f23659858e07fece1d66 Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 20 Sep 2023 18:56:22 +0400 Subject: [PATCH] feat: Creation of dynamic property Casdoor\Auth\AuthConfig::$jwtPublicKey is deprecated (#37) * fix: Creation of dynamic property Casdoor\Auth\AuthConfig::$jwtPublicKey is deprecated * #38 Rename Casdoor\Auth\AuthConfig::$jwtPublicKey to certificate --- README.md | 4 ++-- composer.json | 2 +- src/Auth/Application.php | 4 ++-- src/Auth/AuthConfig.php | 6 +++--- src/Auth/Jwt.php | 2 +- src/Auth/User.php | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4b9b32b..9e96702 100644 --- a/README.md +++ b/README.md @@ -64,10 +64,10 @@ public function initConfig() $endpoint = 'http://127.0.0.1:8000'; $clientId = 'c64b12723aefb65a88ce'; $clientSecret = 'c0c9d483a87332751b2564635765d71c9f6a2e83'; - $jwtSecret = file_get_contents(dirname(__FILE__) . '/public_key.pem'); + $certificate = file_get_contents(dirname(__FILE__) . '/public_key.pem'); $organizationName = 'built-in'; $applicationName = 'testApp'; - User::initConfig($endpoint, $clientId, $clientSecret, $jwtSecret, $organizationName, $applicationName); + User::initConfig($endpoint, $clientId, $clientSecret, $certificate, $organizationName, $applicationName); } ``` diff --git a/composer.json b/composer.json index 246f36a..905fce9 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "authn" ], "require": { - "php": ">=7.1.0", + "php": ">=7.4.0", "guzzlehttp/guzzle": "^7.3", "league/oauth2-client": "^2.6" }, diff --git a/src/Auth/Application.php b/src/Auth/Application.php index 219622b..dffb200 100644 --- a/src/Auth/Application.php +++ b/src/Auth/Application.php @@ -45,9 +45,9 @@ class Application public array $signupItems ; public static $authConfig; - public static function initConfig(string $endpoint, string $clientId, string $clientSecret, string $jwtSecret, string $organizationName, string $applicationName): void + public static function initConfig(string $endpoint, string $clientId, string $clientSecret, string $certificate, string $organizationName, string $applicationName): void { - self::$authConfig = new AuthConfig($endpoint, $clientId, $clientSecret, $jwtSecret, $organizationName, $applicationName); + self::$authConfig = new AuthConfig($endpoint, $clientId, $clientSecret, $certificate, $organizationName, $applicationName); } public function __construct(AuthConfig $authConfig) diff --git a/src/Auth/AuthConfig.php b/src/Auth/AuthConfig.php index 2976054..4c36341 100644 --- a/src/Auth/AuthConfig.php +++ b/src/Auth/AuthConfig.php @@ -30,7 +30,7 @@ class AuthConfig /** * @var string */ - public $JwtPublicKey; + public $certificate; /** * @var string @@ -42,12 +42,12 @@ class AuthConfig */ public $applicationName; - public function __construct(string $endpoint, string $clientId, string $clientSecret, string $jwtPublicKey, string $organizationName, string $applicationName) + public function __construct(string $endpoint, string $clientId, string $clientSecret, string $certificate, string $organizationName, string $applicationName) { $this->endpoint = $endpoint; $this->clientId = $clientId; $this->clientSecret = $clientSecret; - $this->jwtPublicKey = $jwtPublicKey; + $this->certificate = $certificate; $this->organizationName = $organizationName; $this->applicationName = $applicationName; } diff --git a/src/Auth/Jwt.php b/src/Auth/Jwt.php index 03620c8..a8f11ad 100644 --- a/src/Auth/Jwt.php +++ b/src/Auth/Jwt.php @@ -24,7 +24,7 @@ class Jwt */ private function getKey(AuthConfig $authConfig) { - $key = openssl_pkey_get_public($authConfig->jwtPublicKey); + $key = openssl_pkey_get_public($authConfig->certificate); if (is_bool($key)) { throw new CasdoorException('Cannot verify signature'); diff --git a/src/Auth/User.php b/src/Auth/User.php index a8d112a..3fe5ddb 100644 --- a/src/Auth/User.php +++ b/src/Auth/User.php @@ -290,9 +290,9 @@ class User public static $authConfig; - public static function initConfig(string $endpoint, string $clientId, string $clientSecret, string $jwtSecret, string $organizationName, string $applicationName): void + public static function initConfig(string $endpoint, string $clientId, string $clientSecret, string $certificate, string $organizationName, string $applicationName): void { - self::$authConfig = new AuthConfig($endpoint, $clientId, $clientSecret, $jwtSecret, $organizationName, $applicationName); + self::$authConfig = new AuthConfig($endpoint, $clientId, $clientSecret, $certificate, $organizationName, $applicationName); } public static function getUsers(): array