feat(api): require POST for state-changing endpoints

Make start/stop/restart, deploy, enable/disable, and server validate
POST-only, with GET returning 405. Server validate accepts optional
install and uses ValidateAndInstallServerJob. Update OpenAPI and tests.
This commit is contained in:
Andras Bacsai
2026-07-19 11:42:04 +02:00
parent e2c2180f4f
commit 0633b543ee
16 changed files with 297 additions and 605 deletions
+10 -2
View File
@@ -3,12 +3,20 @@
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use OpenApi\Attributes as OA;
class OtherController extends Controller
{
public function post_required(): JsonResponse
{
return response()
->json(['message' => 'This endpoint has changed to a POST request.'], 405)
->header('Allow', 'POST');
}
#[OA\Get(
summary: 'Version',
description: 'Get Coolify version.',
@@ -41,7 +49,7 @@ class OtherController extends Controller
return response(config('constants.coolify.version'));
}
#[OA\Get(
#[OA\Post(
summary: 'Enable API',
description: 'Enable API (only with root permissions).',
path: '/enable',
@@ -97,7 +105,7 @@ class OtherController extends Controller
return response()->json(['message' => 'API enabled.'], 200);
}
#[OA\Get(
#[OA\Post(
summary: 'Disable API',
description: 'Disable API (only with root permissions).',
path: '/disable',