mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-18 22:33:44 +02:00
Update JWT library to support PHP 8; bumps minimum PHP version for Pterodactyl to 7.4
This commit is contained in:
@@ -3,12 +3,12 @@
|
||||
namespace Pterodactyl\Services\Nodes;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Lcobucci\JWT\Builder;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Support\Str;
|
||||
use Lcobucci\JWT\Signer\Key;
|
||||
use Pterodactyl\Models\Node;
|
||||
use Lcobucci\JWT\Configuration;
|
||||
use Lcobucci\JWT\Signer\Hmac\Sha256;
|
||||
use Lcobucci\JWT\Signer\Key\InMemory;
|
||||
|
||||
class NodeJWTService
|
||||
{
|
||||
@@ -68,15 +68,15 @@ class NodeJWTService
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @param string|null $identifiedBy
|
||||
* @param string $algo
|
||||
* @return \Lcobucci\JWT\Token
|
||||
* @return \Lcobucci\JWT\Token\Plain
|
||||
*/
|
||||
public function handle(Node $node, string $identifiedBy, string $algo = 'md5')
|
||||
{
|
||||
$signer = new Sha256;
|
||||
|
||||
$identifier = hash($algo, $identifiedBy);
|
||||
$config = Configuration::forSymmetricSigner(new Sha256, InMemory::plainText($node->getDecryptedKey()));
|
||||
|
||||
$builder = (new Builder)->issuedBy(config('app.url'))
|
||||
$builder = $config->builder()
|
||||
->issuedBy(config('app.url'))
|
||||
->permittedFor($node->getConnectionAddress())
|
||||
->identifiedBy($identifier)
|
||||
->withHeader('jti', $identifier)
|
||||
@@ -97,6 +97,6 @@ class NodeJWTService
|
||||
|
||||
return $builder
|
||||
->withClaim('unique_id', Str::random(16))
|
||||
->getToken($signer, new Key($node->getDecryptedKey()));
|
||||
->getToken($config->signer(), $config->signingKey());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user