mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-15 14:16:28 +00:00
Changes auto-committed by Conductor
This commit is contained in:
1 parent
691fdffa8b
commit
f7427fdea0
8 files changed
+334
-37
No files matched your search
@@ -20,8 +20,18 @@ class PrivateKeyPolicy
|
||||
*/
|
||||
public function view(User $user, PrivateKey $privateKey): bool
|
||||
{
|
||||
// return $user->teams->contains('id', $privateKey->team_id);
|
||||
return true;
|
||||
// Handle null team_id
|
||||
if ($privateKey->team_id === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// System resource (team_id=0): Only root team admins/owners can access
|
||||
if ($privateKey->team_id === 0) {
|
||||
return $user->canAccessSystemResources();
|
||||
}
|
||||
|
||||
// Regular resource: Check team membership
|
||||
return $user->teams->contains('id', $privateKey->team_id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,8 +39,9 @@ class PrivateKeyPolicy
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
// return $user->isAdmin();
|
||||
return true;
|
||||
// Only admins/owners can create private keys
|
||||
// Members should not be able to create SSH keys that could be used for deployments
|
||||
return $user->isAdmin();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,8 +49,19 @@ class PrivateKeyPolicy
|
||||
*/
|
||||
public function update(User $user, PrivateKey $privateKey): bool
|
||||
{
|
||||
// return $user->isAdmin() && $user->teams->contains('id', $privateKey->team_id);
|
||||
return true;
|
||||
// Handle null team_id
|
||||
if ($privateKey->team_id === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// System resource (team_id=0): Only root team admins/owners can update
|
||||
if ($privateKey->team_id === 0) {
|
||||
return $user->canAccessSystemResources();
|
||||
}
|
||||
|
||||
// Regular resource: Must be admin/owner of the team
|
||||
return $user->isAdminOfTeam($privateKey->team_id)
|
||||
&& $user->teams->contains('id', $privateKey->team_id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,8 +69,19 @@ class PrivateKeyPolicy
|
||||
*/
|
||||
public function delete(User $user, PrivateKey $privateKey): bool
|
||||
{
|
||||
// return $user->isAdmin() && $user->teams->contains('id', $privateKey->team_id);
|
||||
return true;
|
||||
// Handle null team_id
|
||||
if ($privateKey->team_id === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// System resource (team_id=0): Only root team admins/owners can delete
|
||||
if ($privateKey->team_id === 0) {
|
||||
return $user->canAccessSystemResources();
|
||||
}
|
||||
|
||||
// Regular resource: Must be admin/owner of the team
|
||||
return $user->isAdminOfTeam($privateKey->team_id)
|
||||
&& $user->teams->contains('id', $privateKey->team_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user