feat(auth): implement authorization for Docker and server management

- Added authorization checks in Livewire components related to Docker and server management to ensure only authorized users can create, update, and manage Docker instances and server settings.
- Introduced new policies for StandaloneDocker and SwarmDocker to define access control rules based on user roles and team associations.
- Updated AuthServiceProvider to register the new policies, enhancing security and access control for Docker functionalities and server management operations.
This commit is contained in:
Andras Bacsai
2025-08-22 14:04:25 +02:00
parent 6c75e89303
commit 6772cfe603
13 changed files with 244 additions and 28 deletions

View File

@@ -8,10 +8,13 @@ use App\Actions\Proxy\StopProxy;
use App\Jobs\RestartProxyJob;
use App\Models\Server;
use App\Services\ProxyDashboardCacheService;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Livewire\Component;
class Navbar extends Component
{
use AuthorizesRequests;
public Server $server;
public bool $isChecking = false;
@@ -57,6 +60,7 @@ class Navbar extends Component
public function restart()
{
try {
$this->authorize('manageProxy', $this->server);
RestartProxyJob::dispatch($this->server);
} catch (\Throwable $e) {
return handleError($e, $this);
@@ -66,6 +70,7 @@ class Navbar extends Component
public function checkProxy()
{
try {
$this->authorize('manageProxy', $this->server);
CheckProxy::run($this->server, true);
$this->dispatch('startProxy')->self();
} catch (\Throwable $e) {
@@ -76,6 +81,7 @@ class Navbar extends Component
public function startProxy()
{
try {
$this->authorize('manageProxy', $this->server);
$activity = StartProxy::run($this->server, force: true);
$this->dispatch('activityMonitor', $activity->id);
} catch (\Throwable $e) {
@@ -86,6 +92,7 @@ class Navbar extends Component
public function stop(bool $forceStop = true)
{
try {
$this->authorize('manageProxy', $this->server);
StopProxy::dispatch($this->server, $forceStop);
} catch (\Throwable $e) {
return handleError($e, $this);