Upgrade to Laravel 9 (#4413)

Co-authored-by: DaneEveritt <dane@daneeveritt.com>
This commit is contained in:
Matthew Penner 2022-10-14 10:59:20 -06:00 committed by GitHub
parent 95e15d2c8a
commit cbcf62086f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
573 changed files with 4387 additions and 9411 deletions

View file

@ -7,6 +7,7 @@ use Carbon\CarbonImmutable;
use Illuminate\Support\Str;
use Pterodactyl\Models\Node;
use Pterodactyl\Models\User;
use Lcobucci\JWT\Token\Plain;
use Lcobucci\JWT\Configuration;
use Lcobucci\JWT\Signer\Hmac\Sha256;
use Lcobucci\JWT\Signer\Key\InMemory;
@ -18,19 +19,14 @@ class NodeJWTService
private ?User $user = null;
/**
* @var \DateTimeImmutable|null
*/
private $expiresAt;
private ?DateTimeImmutable $expiresAt;
private ?string $subject = null;
/**
* Set the claims to include in this JWT.
*
* @return $this
*/
public function setClaims(array $claims)
public function setClaims(array $claims): self
{
$this->claims = $claims;
@ -48,20 +44,14 @@ class NodeJWTService
return $this;
}
/**
* @return $this
*/
public function setExpiresAt(DateTimeImmutable $date)
public function setExpiresAt(DateTimeImmutable $date): self
{
$this->expiresAt = $date;
return $this;
}
/**
* @return $this
*/
public function setSubject(string $subject)
public function setSubject(string $subject): self
{
$this->subject = $subject;
@ -70,12 +60,8 @@ class NodeJWTService
/**
* Generate a new JWT for a given node.
*
* @param string|null $identifiedBy
*
* @return \Lcobucci\JWT\Token\Plain
*/
public function handle(Node $node, string $identifiedBy, string $algo = 'md5')
public function handle(Node $node, ?string $identifiedBy, string $algo = 'md5'): Plain
{
$identifier = hash($algo, $identifiedBy);
$config = Configuration::forSymmetricSigner(new Sha256(), InMemory::plainText($node->getDecryptedKey()));
@ -112,7 +98,7 @@ class NodeJWTService
}
return $builder
->withClaim('unique_id', Str::random(16))
->withClaim('unique_id', Str::random())
->getToken($config->signer(), $config->signingKey());
}
}