File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
app/Http/Middleware/Api/Daemon Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 88use Symfony \Component \HttpKernel \Exception \HttpException ;
99use Pterodactyl \Contracts \Repository \NodeRepositoryInterface ;
1010use Pterodactyl \Exceptions \Repository \RecordNotFoundException ;
11+ use Symfony \Component \HttpKernel \Exception \BadRequestHttpException ;
1112use Symfony \Component \HttpKernel \Exception \AccessDeniedHttpException ;
1213
1314class 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 );
You can’t perform that action at this time.
0 commit comments