Skip to content

Commit 1564f38

Browse files
authored
Merge branch 'develop' into enhancement/wings-improved-server-loading
2 parents 0c12b78 + 2532a73 commit 1564f38

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

app/Http/Middleware/Api/Daemon/DaemonAuthenticate.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Symfony\Component\HttpKernel\Exception\HttpException;
99
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
1010
use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
11+
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
1112
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
1213

1314
class DaemonAuthenticate
@@ -64,15 +65,21 @@ public function handle(Request $request, Closure $next)
6465
);
6566
}
6667

67-
[$identifier, $token] = explode('.', $bearer);
68+
$parts = explode('.', $bearer);
69+
// Ensure that all of the correct parts are provided in the header.
70+
if (count($parts) !== 2 || empty($parts[0]) || empty($parts[1])) {
71+
throw new BadRequestHttpException(
72+
'The Authorization headed provided was not in a valid format.',
73+
);
74+
}
6875

6976
try {
7077
/** @var \Pterodactyl\Models\Node $node */
7178
$node = $this->repository->findFirstWhere([
72-
'daemon_token_id' => $identifier,
79+
'daemon_token_id' => $parts[0],
7380
]);
7481

75-
if (hash_equals((string) $this->encrypter->decrypt($node->daemon_token), $token)) {
82+
if (hash_equals((string) $this->encrypter->decrypt($node->daemon_token), $parts[1])) {
7683
$request->attributes->set('node', $node);
7784

7885
return $next($request);

0 commit comments

Comments
 (0)