fix(security): implement authorization checks for terminal access management
This commit is contained in:
parent
12c7e28a48
commit
6cd3bc0461
1 changed files with 7 additions and 1 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
use App\Models\InstanceSettings;
|
use App\Models\InstanceSettings;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Livewire\Attributes\Validate;
|
use Livewire\Attributes\Validate;
|
||||||
|
|
@ -11,6 +12,8 @@
|
||||||
|
|
||||||
class TerminalAccess extends Component
|
class TerminalAccess extends Component
|
||||||
{
|
{
|
||||||
|
use AuthorizesRequests;
|
||||||
|
|
||||||
public Server $server;
|
public Server $server;
|
||||||
|
|
||||||
public array $parameters = [];
|
public array $parameters = [];
|
||||||
|
|
@ -22,6 +25,7 @@ public function mount(string $server_uuid)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->server = Server::ownedByCurrentTeam()->whereUuid($server_uuid)->firstOrFail();
|
$this->server = Server::ownedByCurrentTeam()->whereUuid($server_uuid)->firstOrFail();
|
||||||
|
$this->authorize('update', $this->server);
|
||||||
$this->parameters = get_route_parameters();
|
$this->parameters = get_route_parameters();
|
||||||
$this->syncData();
|
$this->syncData();
|
||||||
|
|
||||||
|
|
@ -33,6 +37,8 @@ public function mount(string $server_uuid)
|
||||||
public function toggleTerminal($password)
|
public function toggleTerminal($password)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
$this->authorize('update', $this->server);
|
||||||
|
|
||||||
// Check if user is admin or owner
|
// Check if user is admin or owner
|
||||||
if (! auth()->user()->isAdmin()) {
|
if (! auth()->user()->isAdmin()) {
|
||||||
throw new \Exception('Only team administrators and owners can modify terminal access.');
|
throw new \Exception('Only team administrators and owners can modify terminal access.');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue