An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
Restrict upgrade-status endpoint to authenticated root team members
Andras Bacsai3cc416a8069e
diff --git a/app/Http/Controllers/Api/OtherController.php b/app/Http/Controllers/Api/OtherController.phpindex 27b0fc3feb..a0d5c6e564 100644--- a/app/Http/Controllers/Api/OtherController.php+++ b/app/Http/Controllers/Api/OtherController.php@@ -189,9 +189,12 @@ class OtherController extends Controller#[OA\Get(summary: 'Upgrade Status',- description: 'Get the current upgrade status. Returns the step and message from the upgrade process.',+ description: 'Get the current upgrade status. Returns the step and message from the upgrade process. Only available to root team members.',path: '/upgrade-status',operationId: 'upgrade-status',+ security: [+ ['bearerAuth' => []],+ ],responses: [new OA\Response(response: 200,@@ -204,6 +207,19 @@ class OtherController extends Controllernew OA\Property(property: 'message', type: 'string', example: 'Pulling Docker images'),])),+ new OA\Response(+ response: 401,+ ref: '#/components/responses/401',+ ),+ new OA\Response(+ response: 403,+ description: 'You are not allowed to view upgrade status.',+ content: new OA\JsonContent(+ type: 'object',+ properties: [+ new OA\Property(property: 'message', type: 'string', example: 'You are not allowed to view upgrade status.'),+ ]+ )),new OA\Response(response: 400,ref: '#/components/responses/400',@@ -212,6 +228,12 @@ class OtherController extends Controller)]public function upgradeStatus(Request $request){+ // Only root team members can view upgrade status+ $user = auth()->user();+ if (! $user || $user->currentTeam()->id !== 0) {+ return response()->json(['message' => 'You are not allowed to view upgrade status.'], 403);+ }+$statusFile = '/data/coolify/source/.upgrade-status';if (! file_exists($statusFile)) {diff --git a/resources/views/livewire/upgrade.blade.php b/resources/views/livewire/upgrade.blade.phpindex f379f24a96..6d4e0a5291 100644--- a/resources/views/livewire/upgrade.blade.php+++ b/resources/views/livewire/upgrade.blade.php@@ -286,11 +286,17 @@// Poll upgrade status API for real progressthis.checkUpgradeStatusInterval = setInterval(() => {- fetch('/api/upgrade-status')+ fetch('/api/upgrade-status', {+ credentials: 'same-origin',+ headers: {+ 'Accept': 'application/json',+ }+ }).then(response => {if (response.ok) {return response.json();}+ // Auth errors (401/403) or service down - switch to health checkthrow new Error('Service unavailable');}).then(data => {diff --git a/routes/api.php b/routes/api.phpindex 745a835347..3453bdd090 100644--- a/routes/api.php+++ b/routes/api.php@@ -19,11 +19,21 @@ use App\Models\Server;use Illuminate\Support\Facades\Route;Route::get('/health', [OtherController::class, 'healthcheck']);-Route::get('/upgrade-status', [OtherController::class, 'upgradeStatus']);Route::group(['prefix' => 'v1',], function () {Route::get('/health', [OtherController::class, 'healthcheck']);+});++Route::group([+ 'middleware' => ['auth:sanctum'],+], function () {+ Route::get('/upgrade-status', [OtherController::class, 'upgradeStatus']);+});+Route::group([+ 'middleware' => ['auth:sanctum'],+ 'prefix' => 'v1',+], function () {Route::get('/upgrade-status', [OtherController::class, 'upgradeStatus']);});