mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
feat(access): add scoped grants for team members and API tokens (#12329)
This commit is contained in:
@@ -4,7 +4,9 @@ namespace App\Models;
|
||||
|
||||
use App\Casts\EncryptedArrayCast;
|
||||
use App\Enums\ApplicationDeploymentStatus;
|
||||
use App\Services\Access\AccessResolver;
|
||||
use App\Services\Security\SensitiveDataRedactor;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Carbon;
|
||||
@@ -48,6 +50,20 @@ use OpenApi\Attributes as OA;
|
||||
)]
|
||||
class ApplicationDeploymentQueue extends Model
|
||||
{
|
||||
/**
|
||||
* Only deployments of applications the authenticated member or API token can see.
|
||||
*/
|
||||
public function scopeVisibleToCurrentActor(Builder $query): Builder
|
||||
{
|
||||
foreach (app(AccessResolver::class)->currentLayers() as $layer) {
|
||||
if (! $layer->coversWholeTeam()) {
|
||||
return $query->whereIn('application_id', Application::query()->pluck('id')->map(fn ($id) => (string) $id));
|
||||
}
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log redaction variants of remote secrets. Kept in memory only, never saved.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user