mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-14 16:52:45 -04:00
Hardcoded variables parsed from docker-compose are now redacted in the environment variable list unless the user can update the resource. The value is nulled server-side and flagged with is_value_hidden, so it no longer reaches the Livewire snapshot or rendered HTML. ShowHardcoded gets a locked isValueHidden property. When it is set, the copy button is hidden and the details modal shows "Hidden (only admins can view)" in place of the value. Previously the view checked member role only. Add tests covering redaction for members and visibility for owners.
67 lines
1.6 KiB
PHP
67 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Project\Shared\EnvironmentVariable;
|
|
|
|
use App\Models\EnvironmentVariable;
|
|
use Livewire\Attributes\Locked;
|
|
use Livewire\Component;
|
|
|
|
class ShowHardcoded extends Component
|
|
{
|
|
public bool $showEnvironmentType = true;
|
|
|
|
public array $env;
|
|
|
|
public string $key;
|
|
|
|
#[Locked]
|
|
public ?string $value = null;
|
|
|
|
#[Locked]
|
|
public bool $isValueHidden = true;
|
|
|
|
public ?string $comment = null;
|
|
|
|
public ?string $serviceName = null;
|
|
|
|
#[Locked]
|
|
public bool $isPreview = false;
|
|
|
|
#[Locked]
|
|
public ?string $resourceableType = null;
|
|
|
|
#[Locked]
|
|
public ?int $resourceableId = null;
|
|
|
|
public function mount()
|
|
{
|
|
$this->key = $this->env['key'];
|
|
$this->value = $this->env['value'] ?? null;
|
|
$this->isValueHidden = $this->env['is_value_hidden'] ?? true;
|
|
$this->comment = $this->env['comment'] ?? null;
|
|
$this->serviceName = $this->env['service_name'] ?? null;
|
|
}
|
|
|
|
public function copyValue(): ?string
|
|
{
|
|
$environmentVariable = EnvironmentVariable::make([
|
|
'value' => $this->value,
|
|
'is_preview' => $this->isPreview,
|
|
'resourceable_type' => $this->resourceableType,
|
|
'resourceable_id' => $this->resourceableId,
|
|
]);
|
|
$resource = $environmentVariable->resourceable;
|
|
|
|
if (! $resource || auth()->user()->cannot('update', $resource)) {
|
|
return null;
|
|
}
|
|
|
|
return $environmentVariable->resolveReferencedValue();
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.project.shared.environment-variable.show-hardcoded');
|
|
}
|
|
}
|