Skip to content

Commit

Permalink
feat: Creation of dynamic property Casdoor\Auth\AuthConfig::$jwtPubli…
Browse files Browse the repository at this point in the history
…cKey is deprecated (#37)

* fix: Creation of dynamic property Casdoor\Auth\AuthConfig::$jwtPublicKey is deprecated

* #38 Rename Casdoor\Auth\AuthConfig::$jwtPublicKey to certificate
  • Loading branch information
netandreus committed Sep 20, 2023
1 parent aae072a commit 74fbe88
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
```

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"authn"
],
"require": {
"php": ">=7.1.0",
"php": ">=7.4.0",
"guzzlehttp/guzzle": "^7.3",
"league/oauth2-client": "^2.6"
},
Expand Down
4 changes: 2 additions & 2 deletions src/Auth/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/Auth/AuthConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AuthConfig
/**
* @var string
*/
public $JwtPublicKey;
public $certificate;

/**
* @var string
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Auth/Jwt.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions src/Auth/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 74fbe88

Please sign in to comment.