An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix(storage): refresh storage form values consistently
Andras Bacsai59788c59f0a1
diff --git a/app/Livewire/Storage/Form.php b/app/Livewire/Storage/Form.phpindex 30084dcd39..ebf43d5019 100644--- a/app/Livewire/Storage/Form.php+++ b/app/Livewire/Storage/Form.php@@ -110,8 +110,9 @@ class Form extends Component$this->endpointPartsChanged = false;$this->bucket = $this->storage->bucket;$this->region = $this->storage->region;- $this->key = $this->storage->key;- $this->secret = $this->storage->secret;+ $canSeeCredentials = auth()->user()?->can('update', $this->storage) ?? false;+ $this->key = $canSeeCredentials ? $this->storage->key : '';+ $this->secret = $canSeeCredentials ? $this->storage->secret : '';$this->isUsable = $this->storage->is_usable;}}@@ -121,10 +122,6 @@ class Form extends Component$this->syncData(false);$this->isPasswordHiddenForMember = auth()->user()?->isMember() ?? false;- if ($this->isPasswordHiddenForMember) {- $this->key = '';- $this->secret = '';- }}public function testConnection()diff --git a/tests/Feature/Authorization/LivewireStoredSecretAuthorizationTest.php b/tests/Feature/Authorization/LivewireStoredSecretAuthorizationTest.phpindex 68bb0ac8b2..d1f16f0186 100644--- a/tests/Feature/Authorization/LivewireStoredSecretAuthorizationTest.php+++ b/tests/Feature/Authorization/LivewireStoredSecretAuthorizationTest.php@@ -2,9 +2,11 @@use App\Livewire\Security\PrivateKey\Show as PrivateKeyShow;use App\Livewire\Source\Github\Change as GithubAppChange;+use App\Livewire\Storage\Form as StorageForm;use App\Models\GithubApp;use App\Models\InstanceSettings;use App\Models\PrivateKey;+use App\Models\S3Storage;use App\Models\Team;use App\Models\User;use Illuminate\Foundation\Testing\RefreshDatabase;@@ -115,3 +117,44 @@ function createGithubAppWithSecrets(Team $team, bool $isSystemWide = false): Git'is_system_wide' => $isSystemWide,]);}++function createS3StorageWithSecrets(Team $team): S3Storage+{+ return S3Storage::query()->create([+ 'team_id' => $team->id,+ 'name' => 'Backup storage',+ 'region' => 'us-east-1',+ 'key' => 'stored-access-key',+ 'secret' => 'stored-secret-key',+ 'bucket' => 'backups',+ 'endpoint' => 'https://s3.example.com',+ 'is_usable' => true,+ ]);+}++it('does not serialize S3 credentials for a member after any storage action', function () {+ $storage = createS3StorageWithSecrets($this->team);++ $this->actingAs($this->member);+ session(['currentTeam' => $this->team]);++ Livewire::test(StorageForm::class, ['storage' => $storage])+ ->assertSet('key', '')+ ->assertSet('secret', '')+ ->call('submit')+ ->assertSet('key', '')+ ->assertSet('secret', '')+ ->assertDontSee('stored-access-key')+ ->assertDontSee('stored-secret-key');+});++it('keeps S3 credentials available to an owner who can update the storage', function () {+ $storage = createS3StorageWithSecrets($this->team);++ $this->actingAs($this->owner);+ session(['currentTeam' => $this->team]);++ Livewire::test(StorageForm::class, ['storage' => $storage])+ ->assertSet('key', 'stored-access-key')+ ->assertSet('secret', 'stored-secret-key');+});