mirror of
https://github.com/tiennm99/coolify.git
synced 2026-08-17 00:25:13 +00:00
fix(source): scope private key and source selection to current team
The Source component now resolves the supplied private key and Git source IDs through team-scoped queries before persisting them, so a selection can only ever reference a resource owned by the current team. The source type is additionally restricted to the supported GitHub/GitLab app classes. The privateKeyId property is marked #[Locked] so it can only change through the dedicated handler rather than a direct property update. Adds feature tests covering team-scoped selection of private keys and Git sources. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
b124397613
commit
5dda39e588
@@ -3,6 +3,8 @@
|
||||
namespace App\Livewire\Project\Application;
|
||||
|
||||
use App\Models\Application;
|
||||
use App\Models\GithubApp;
|
||||
use App\Models\GitlabApp;
|
||||
use App\Models\PrivateKey;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Livewire\Attributes\Locked;
|
||||
@@ -21,7 +23,7 @@ class Source extends Component
|
||||
#[Validate(['nullable', 'string'])]
|
||||
public ?string $privateKeyName = null;
|
||||
|
||||
#[Validate(['nullable', 'integer'])]
|
||||
#[Locked]
|
||||
public ?int $privateKeyId = null;
|
||||
|
||||
#[Validate(['required', 'string'])]
|
||||
@@ -103,7 +105,8 @@ class Source extends Component
|
||||
{
|
||||
try {
|
||||
$this->authorize('update', $this->application);
|
||||
$this->privateKeyId = $privateKeyId;
|
||||
$key = PrivateKey::ownedByCurrentTeam()->findOrFail($privateKeyId);
|
||||
$this->privateKeyId = $key->id;
|
||||
$this->syncData(true);
|
||||
$this->getPrivateKeys();
|
||||
$this->application->refresh();
|
||||
@@ -136,8 +139,11 @@ class Source extends Component
|
||||
|
||||
try {
|
||||
$this->authorize('update', $this->application);
|
||||
$allowedSourceTypes = [GithubApp::class, GitlabApp::class];
|
||||
abort_unless(in_array($sourceType, $allowedSourceTypes, true), 404);
|
||||
$source = $sourceType::ownedByCurrentTeam()->findOrFail($sourceId);
|
||||
$this->application->update([
|
||||
'source_id' => $sourceId,
|
||||
'source_id' => $source->id,
|
||||
'source_type' => $sourceType,
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user