fix(api): require deploy ability for Hostinger setup options

Require deploy permission when setting a post-install script or extra SSH keys, document the 403 response, and cover both denial and allowed deployment cases.
This commit is contained in:
Andras Bacsai
2026-10-19 00:02:52 +02:00
parent e3d4411ff2
commit 0fb816bcb5
4 changed files with 61 additions and 0 deletions
@@ -122,6 +122,7 @@ class HostingerController extends Controller
responses: [
new OA\Response(response: 201, description: 'Hostinger VPS purchased and linked to a Coolify server.'),
new OA\Response(response: 401, ref: '#/components/responses/401'),
new OA\Response(response: 403, description: 'The token needs the deploy ability to set post_install_script_id or public_key_ids.'),
new OA\Response(response: 422, description: 'Validation failed.'),
new OA\Response(response: 429, description: 'Hostinger rate limit exceeded.'),
]
@@ -182,6 +183,10 @@ class HostingerController extends Controller
], 422);
}
if ($request->filled('post_install_script_id') || $request->array('public_key_ids')) {
abort_unless($request->user()->tokenCan('deploy') || $request->user()->tokenCan('root'), 403, 'Missing required permissions: deploy');
}
$team = Team::find($teamId);
if (Team::serverLimitReached($team)) {
return response()->json(['message' => 'Server limit reached for your subscription.'], 400);