Path: blob/1.0-develop/app/Http/Middleware/Api/Client/RequireClientApiKey.php
10277 views
<?php12namespace Pterodactyl\Http\Middleware\Api\Client;34use Illuminate\Http\Request;5use Pterodactyl\Models\ApiKey;6use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;78class RequireClientApiKey9{10/**11* Blocks a request to the Client API endpoints if the user is providing an API token12* that was created for the application API.13*/14public function handle(Request $request, \Closure $next): mixed15{16$token = $request->user()->currentAccessToken();1718if ($token instanceof ApiKey && $token->key_type === ApiKey::TYPE_APPLICATION) { // @phpstan-ignore instanceof.alwaysTrue19throw new AccessDeniedHttpException('You are attempting to use an application API key on an endpoint that requires a client API key.');20}2122return $next($request);23}24}252627