mirror of
https://github.com/tiennm99/coolify.git
synced 2026-08-21 04:24:23 +00:00
refactor(auth): enforce authorization checks across livewire components
Add authorization checks to multiple Livewire components to ensure users have proper permissions before performing sensitive operations. This includes: - Adding AuthorizesRequests trait to components handling deployments, backups, services, and configuration uploads - Enforcing 'deploy', 'update', and 'manageBackups' authorization checks - Adding instance admin check for system upgrade operations - Improving database queries with team ownership scope - Moving backup trigger from component to button with new backupNow() method
This commit is contained in:
@@ -4,12 +4,15 @@ namespace App\Livewire\Project\Service;
|
||||
|
||||
use App\Models\Service;
|
||||
use App\Support\ValidationPatterns;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Livewire\Component;
|
||||
|
||||
class StackForm extends Component
|
||||
{
|
||||
use AuthorizesRequests;
|
||||
|
||||
public Service $service;
|
||||
|
||||
public Collection $fields;
|
||||
@@ -128,14 +131,20 @@ class StackForm extends Component
|
||||
|
||||
public function instantSave()
|
||||
{
|
||||
$this->syncData(true);
|
||||
$this->service->save();
|
||||
$this->dispatch('success', 'Service settings saved.');
|
||||
try {
|
||||
$this->authorize('update', $this->service);
|
||||
$this->syncData(true);
|
||||
$this->service->save();
|
||||
$this->dispatch('success', 'Service settings saved.');
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
|
||||
public function submit($notify = true)
|
||||
{
|
||||
try {
|
||||
$this->authorize('update', $this->service);
|
||||
$this->validate();
|
||||
$this->syncData(true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user