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
Merge remote-tracking branch 'origin/next' into audit-policies
Andras Bacsaic175d3d2823c
diff --cc app/Http/Controllers/Api/CloudProviderTokensController.phpindex 5ca7212fd5,d652f2ba1a..1dd2e00060--- a/app/Http/Controllers/Api/CloudProviderTokensController.php+++ b/app/Http/Controllers/Api/CloudProviderTokensController.php@@@ -243,10 -243,9 +244,10 @@@ class CloudProviderTokensController extif (is_null($teamId)) {return invalidTokenResponse();}+ $this->authorize('create', [CloudProviderToken::class]);$return = validateIncomingRequest($request);- if ($return instanceof \Illuminate\Http\JsonResponse) {+ if ($return instanceof JsonResponse) {return $return;}diff --cc app/Http/Controllers/Api/HetznerController.phpindex ec49162ae7,2f35ba576f..ded23bb805--- a/app/Http/Controllers/Api/HetznerController.php+++ b/app/Http/Controllers/Api/HetznerController.php@@@ -548,10 -550,9 +550,10 @@@ class HetznerController extends Controlif (is_null($teamId)) {return invalidTokenResponse();}+ $this->authorize('create', [Server::class]);$return = validateIncomingRequest($request);- if ($return instanceof \Illuminate\Http\JsonResponse) {+ if ($return instanceof JsonResponse) {return $return;}diff --cc app/Http/Controllers/Api/SecurityController.phpindex f8641764d9,e59c408668..0559bcd99a--- a/app/Http/Controllers/Api/SecurityController.php+++ b/app/Http/Controllers/Api/SecurityController.php@@@ -333,9 -338,15 +340,16 @@@ class SecurityController extends Contro'message' => 'Private Key not found.',], 404);}+ $this->authorize('update', $foundKey);$foundKey->update($request->only($allowedFields));+ auditLog('api.private_key.updated', [+ 'team_id' => $teamId,+ 'private_key_uuid' => $foundKey->uuid,+ 'private_key_name' => $foundKey->name,+ 'changed_fields' => array_values(array_intersect($allowedFields, array_keys($request->all()))),+ ]);+return response()->json(serializeApiResponse(['uuid' => $foundKey->uuid,]))->setStatusCode(201);diff --cc app/Http/Controllers/Api/ServersController.phpindex 9c11faef87,6c3b2da007..30cafad3fb--- a/app/Http/Controllers/Api/ServersController.php+++ b/app/Http/Controllers/Api/ServersController.php@@@ -476,10 -476,9 +477,10 @@@ class ServersController extends Controlif (is_null($teamId)) {return invalidTokenResponse();}+ $this->authorize('create', [ModelsServer::class]);$return = validateIncomingRequest($request);- if ($return instanceof \Illuminate\Http\JsonResponse) {+ if ($return instanceof JsonResponse) {return $return;}$validator = customApiValidator($request->all(), [@@@ -883,9 -908,14 +912,15 @@@if (! $server) {return response()->json(['message' => 'Server not found.'], 404);}+ $this->authorize('update', $server);ValidateServer::dispatch($server);+ auditLog('api.server.validated', [+ 'team_id' => $teamId,+ 'server_uuid' => $server->uuid,+ 'server_name' => $server->name,+ ]);+return response()->json(['message' => 'Validation started.'], 201);}}diff --cc app/Http/Controllers/UploadController.phpindex 895564caa6,6c3dda402c..26a76ab3ea--- a/app/Http/Controllers/UploadController.php+++ b/app/Http/Controllers/UploadController.php@@@ -12,8 -11,27 +12,29 @@@ use Pion\Laravel\ChunkUpload\Receiver\Fclass UploadController extends BaseController{+ use AuthorizesRequests;++ private const MAX_BYTES = 10 * 1024 * 1024 * 1024; // 10 GiB++ private const ALLOWED_EXTENSIONS = [+ 'sql',+ 'sql.gz',+ 'gz',+ 'zip',+ 'tar',+ 'tar.gz',+ 'tgz',+ 'dump',+ 'bak',+ 'bson',+ 'bson.gz',+ 'archive',+ 'archive.gz',+ 'bz2',+ 'xz',+ 'dmp',+ ];+public function upload(Request $request){$databaseIdentifier = request()->route('databaseUuid');@@@ -22,8 -40,21 +43,23 @@@return response()->json(['error' => 'You do not have permission for this database'], 500);}+ $this->authorize('uploadBackup', $resource);++ $chunk = $request->file('file');+ $originalName = $chunk instanceof UploadedFile ? $chunk->getClientOriginalName() : null;+ if (blank($originalName) || ! self::hasAllowedExtension($originalName)) {+ return response()->json([+ 'error' => 'Unsupported file type. Allowed extensions: '.implode(', ', self::ALLOWED_EXTENSIONS),+ ], 422);+ }++ $declaredTotalSize = (int) $request->input('dzTotalFilesize', 0);+ if ($declaredTotalSize > self::MAX_BYTES) {+ return response()->json([+ 'error' => 'File exceeds maximum allowed size of '.self::formatMaxSize().'.',+ ], 422);+ }+$receiver = new FileReceiver('file', $request, HandlerFactory::classFromRequest($request));if ($receiver->isUploaded() === false) {diff --cc app/Livewire/Project/Application/Deployment/Show.phpindex b8f5e891a1,c9f818e2cd..9ed0ab807c--- a/app/Livewire/Project/Application/Deployment/Show.php+++ b/app/Livewire/Project/Application/Deployment/Show.php@@@ -110,23 -108,8 +110,10 @@@ class Show extends Componenreturn decode_remote_command_output($this->application_deployment_queue);}- public function copyLogs(): string- {- $logs = decode_remote_command_output($this->application_deployment_queue)- ->map(function ($line) {- return $line['timestamp'].' '.- (isset($line['command']) && $line['command'] ? '[CMD]: ' : '').- trim($line['line']);- })- ->join("\n");-- return sanitizeLogsForExport($logs);- }-public function downloadAllLogs(): string{+ $this->authorize('update', $this->application);+$logs = decode_remote_command_output($this->application_deployment_queue, includeAll: true)->map(function ($line) {$prefix = '';diff --cc app/Livewire/Security/ApiTokens.phpindex 97d2bfb448,37d5332f34..08503359e9--- a/app/Livewire/Security/ApiTokens.php+++ b/app/Livewire/Security/ApiTokens.php@@@ -108,20 -98,13 +118,22 @@@ class ApiTokens extends Componenthrow new \Exception('You do not have permission to create tokens with write permissions.');}+ if (in_array('deploy', $this->permissions) && ! auth()->user()->can('useDeployPermissions', PersonalAccessToken::class)) {+ throw new \Exception('You do not have permission to create tokens with deploy permissions.');+ }++ if (in_array('read:sensitive', $this->permissions) && ! auth()->user()->can('useSensitivePermissions', PersonalAccessToken::class)) {+ throw new \Exception('You do not have permission to create tokens with read:sensitive permissions.');+ }+$this->validate(['description' => 'required|min:3|max:255',+ 'expiresInDays' => 'nullable|integer|in:7,30,60,90,365',]);- $token = auth()->user()->createToken($this->description, array_values($this->permissions));+ $expiresAt = $this->expiresInDays ? now()->addDays($this->expiresInDays) : null;+ $token = auth()->user()->createToken($this->description, array_values($this->permissions), $expiresAt);$this->getTokens();+ // Do NOT strip the numeric prefix (e.g. "69|...") — Sanctum uses it to index and look up tokens.session()->flash('token', $token->plainTextToken);} catch (\Exception $e) {return handleError($e, $this);diff --cc resources/views/livewire/project/database/clickhouse/general.blade.phpindex cb96ad2bed,9283172ad0..adc57725d5--- a/resources/views/livewire/project/database/clickhouse/general.blade.php+++ b/resources/views/livewire/project/database/clickhouse/general.blade.php@@@ -49,28 -41,19 +49,27 @@@helper="A comma separated list of ports you would like to map to the host system.<br><span class='inline-block font-bold dark:text-warning'>Example</span>3000:5432,3002:5433"canGate="update" :canResource="$database" /></div>- <x-forms.input label="Clickhouse URL (internal)"- helper="If you change the user/password/port, this could be different. This is with the default values."- type="password" readonly wire:model="dbUrl" canGate="update" :canResource="$database" />- @if ($dbUrlPublic)- <x-forms.input label="Clickhouse URL (public)"- helper="If you change the user/password/port, this could be different. This is with the default values."- type="password" readonly wire:model="dbUrlPublic" canGate="update" :canResource="$database" />+ @if ($isPasswordHiddenForMember)+ <x-forms.input label="Clickhouse URL (internal)" disabled value="Hidden (only admins can view)" />@else- <x-forms.input label="Clickhouse URL (public)"+ <x-forms.input label="Clickhouse URL (internal)"helper="If you change the user/password/port, this could be different. This is with the default values."- readonly value="Starting the database will generate this." canGate="update" :canResource="$database" />+ type="password" readonly wire:model="dbUrl" canGate="update" :canResource="$database" />+ @endif+ @if ($isPasswordHiddenForMember)+ <x-forms.input label="Clickhouse URL (public)" disabled value="Hidden (only admins can view)" />+ @else+ @if ($dbUrlPublic)+ <x-forms.input label="Clickhouse URL (public)"+ helper="If you change the user/password/port, this could be different. This is with the default values."+ type="password" readonly wire:model="dbUrlPublic" canGate="update" :canResource="$database" />+ @else+ <x-forms.input label="Clickhouse URL (public)"+ helper="If you change the user/password/port, this could be different. This is with the default values."+ readonly value="Starting the database will generate this." canGate="update" :canResource="$database" />+ @endif@endif</div>- <div><div class="flex flex-col py-2 w-64"><div class="flex items-center gap-2 pb-2"><div class="flex items-center">diff --cc resources/views/livewire/security/api-tokens.blade.phpindex bf04aad2ac,69eab3e70d..dc8c97952d--- a/resources/views/livewire/security/api-tokens.blade.php+++ b/resources/views/livewire/security/api-tokens.blade.php@@@ -14,27 -14,30 +14,33 @@@<h3>New Token</h3>@can('create', App\Models\PersonalAccessToken::class)<form class="flex flex-col gap-2" wire:submit='addNewToken'>- <div class="flex gap-2 items-end w-96">- <x-forms.input required id="description" label="Description" />+ <div class="flex gap-2 items-end w-lg">+ <x-forms.input class="w-64" required id="description" label="Description" />+ <x-forms.select id="expiresInDays" label="Expires in" wire:model="expiresInDays">+ @foreach ($expirationOptions as $days => $label)+ <option value="{{ $days }}">{{ $label }}</option>+ @endforeach+ <option value="">Never</option>+ </x-forms.select><x-forms.button type="submit">Create</x-forms.button></div>- <div class="flex">- Permissions- <span- class="pr-1">:</span>- <div class="flex gap-1 font-bold dark:text-white">- @if ($permissions)+ <div class="flex items-center gap-2">+ <span>Permissions</span>+ <x-helper helper="These permissions will be granted to the token." />+ @if ($permissions)+ <div class="flex gap-1.5 flex-wrap">@foreach ($permissions as $permission)- <div>{{ $permission }}</div>+ <span+ class="px-2 py-0.5 text-xs rounded-sm font-medium {{ $permission === 'root' ? 'bg-red-500/20 text-red-400' : ($permission === 'write' || $permission === 'write:sensitive' ? 'bg-amber-500/20 text-amber-400' : ($permission === 'deploy' ? 'bg-blue-500/20 text-blue-400' : 'bg-neutral-500/20 text-neutral-300')) }}">+ {{ $permission }}+ </span>@endforeach- @endif- </div>+ </div>+ @endif</div>- <div class="w-64">+ <h4>Token Permissions</h4>+ <div class="w-96">@if ($canUseRootPermissions)<x-forms.checkbox label="root" wire:model.live="permissions" domValue="root"helper="Root access, be careful!" :checked="in_array('root', $permissions)"></x-forms.checkbox>@@@ -52,23 -55,13 +58,23 @@@helper="Write access requires admin or owner role" :checked="false"></x-forms.checkbox>@endif- <x-forms.checkbox label="deploy" wire:model.live="permissions" domValue="deploy"- helper="Can trigger deploy webhooks." :checked="in_array('deploy', $permissions)"></x-forms.checkbox>- <x-forms.checkbox label="read" domValue="read" wire:model.live="permissions" domValue="read"+ @if ($canUseDeployPermissions)+ <x-forms.checkbox label="deploy" wire:model.live="permissions" domValue="deploy"+ helper="Can trigger deploy webhooks." :checked="in_array('deploy', $permissions)"></x-forms.checkbox>+ @else+ <x-forms.checkbox label="deploy (admin/owner only)" disabled domValue="deploy"+ helper="Deploy access requires admin or owner role" :checked="false"></x-forms.checkbox>+ @endif- <x-forms.checkbox label="read" domValue="read" wire:model.live="permissions" domValue="read"++ <x-forms.checkbox label="read" wire:model.live="permissions" domValue="read":checked="in_array('read', $permissions)"></x-forms.checkbox>- <x-forms.checkbox label="read:sensitive" wire:model.live="permissions" domValue="read:sensitive"- helper="Responses will include secrets, logs, passwords, and compose file contents."- :checked="in_array('read:sensitive', $permissions)"></x-forms.checkbox>+ @if ($canUseSensitivePermissions)+ <x-forms.checkbox label="read:sensitive" wire:model.live="permissions" domValue="read:sensitive"+ helper="Responses will include secrets, logs, passwords, and compose file contents."+ :checked="in_array('read:sensitive', $permissions)"></x-forms.checkbox>+ @else+ <x-forms.checkbox label="read:sensitive (admin/owner only)" disabled domValue="read:sensitive"+ helper="Read:sensitive access requires admin or owner role" :checked="false"></x-forms.checkbox>+ @endif@endif</div>@if (in_array('root', $permissions))@@@ -77,73 -70,83 +83,110 @@@</form>@endcan@if (session()->has('token'))- <div class="py-4 font-bold dark:text-warning">Please copy this token now. For your security, it won't be shown- again.+ <div class="p-4 my-4 border rounded dark:border-coolgray-200 dark:bg-coolgray-100">+ <div class="pb-2 font-bold dark:text-warning">Please copy this token now. For your security, it won't+ be shown again.</div>+ <div class="relative" x-data="{ copied: false, isSecure: window.isSecureContext }">+ <input type="text" value="{{ session('token') }}" readonly+ class="input !text-white !bg-coolgray-200 font-mono" />+ <button x-show="isSecure"+ @click.prevent="copied = true; navigator.clipboard.writeText({{ Js::from(session('token')) }}); setTimeout(() => copied = false, 1000)"+ class="absolute right-2 top-1/2 -translate-y-1/2 p-1.5 text-gray-400 hover:text-gray-300 transition-colors"+ title="Copy to clipboard">+ <svg x-show="!copied" class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"+ d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" />+ </svg>+ <svg x-show="copied" class="w-5 h-5 text-green-500" fill="none" stroke="currentColor"+ viewBox="0 0 24 24">+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"+ d="M5 13l4 4L19 7" />+ </svg>+ </button>+ </div></div>- <div class="pb-4 font-bold dark:text-white"> {{ session('token') }}</div>@endif- <h3 class="py-4">Issued Tokens</h3>- <div class="flex flex-col">+ <div x-data="{ search: '' }">+ <div class="flex items-center justify-between py-4">+ <h3>Issued Tokens</h3>+ @if ($tokens->count() > 1)- <input type="text" x-model="search" placeholder="Filter tokens..."- class="input w-64" />++ <input type="text" x-model="search" placeholder="Filter tokens..." class="input w-64" />+ @endif+ </div>- <div class="flex flex-col gap-2">- @forelse ($tokens as $token)- <div wire:key="token-{{ $token->id }}"- x-show="!search || '{{ strtolower($token->name) }} {{ strtolower(implode(' ', $token->abilities ?? [])) }}'.includes(search.toLowerCase())"- class="flex items-center justify-between p-3 border rounded dark:border-coolgray-200">- <div>- <div class="flex items-center gap-2">- <span class="font-bold dark:text-white">{{ $token->name }}</span>- @if ($token->abilities)- @foreach ($token->abilities as $ability)- <span- class="px-2 py-0.5 text-xs rounded-sm font-medium {{ $ability === 'root' ? 'bg-red-500/20 text-red-400' : ($ability === 'write' || $ability === 'write:sensitive' ? 'bg-amber-500/20 text-amber-400' : ($ability === 'deploy' ? 'bg-blue-500/20 text-blue-400' : 'bg-neutral-500/20 text-neutral-300')) }}">- {{ $ability }}- </span>- @endforeach- @endif- </div>- <div class="text-xs text-neutral-400">- Last used: {{ $token->last_used_at ? $token->last_used_at->diffForHumans() : 'Never' }}- </div>+ <div class="flex flex-col">+ <div class="overflow-x-auto">+ <div class="inline-block min-w-full">+ <div class="overflow-hidden">+ <table class="min-w-full">+ <thead>+ <tr>+ <th class="px-5 py-3 text-xs font-medium text-left uppercase">Description</th>+ <th class="px-5 py-3 text-xs font-medium text-left uppercase">Permissions</th>+ <th class="px-5 py-3 text-xs font-medium text-left uppercase">Last used</th>+ <th class="px-5 py-3 text-xs font-medium text-left uppercase">Created</th>+ <th class="px-5 py-3 text-xs font-medium text-left uppercase">Expires</th>+ <th class="px-5 py-3 text-xs font-medium text-left uppercase">Actions</th>+ </tr>+ </thead>+ <tbody>+ @forelse ($tokens as $token)- <tr wire:key="token-{{ $token->id }}">++ <tr wire:key="token-{{ $token->id }}"++ x-show="!search || {{ Js::from(strtolower($token->name).' '.strtolower(implode(' ', $token->abilities ?? []))) }}.includes(search.toLowerCase())">+ <td class="px-5 py-4 text-sm whitespace-nowrap">{{ $token->name }}</td>+ <td class="px-5 py-4 text-sm whitespace-nowrap">+ @if ($token->abilities)- <div class="flex gap-1">++ <div class="flex gap-1.5 flex-wrap">+ @foreach ($token->abilities as $ability)- <div class="font-bold dark:text-white">{{ $ability }}</div>++ <span++ class="px-2 py-0.5 text-xs rounded-sm font-medium {{ $ability === 'root' ? 'bg-red-500/20 text-red-400' : ($ability === 'write' || $ability === 'write:sensitive' ? 'bg-amber-500/20 text-amber-400' : ($ability === 'deploy' ? 'bg-blue-500/20 text-blue-400' : 'bg-neutral-500/20 text-neutral-300')) }}">++ {{ $ability }}++ </span>+ @endforeach+ </div>+ @endif+ </td>+ <td class="px-5 py-4 text-sm whitespace-nowrap">+ {{ $token->last_used_at ? $token->last_used_at->diffForHumans() : 'Never' }}+ </td>+ <td class="px-5 py-4 text-sm whitespace-nowrap">+ {{ $token->created_at->diffForHumans() }}+ </td>+ <td class="px-5 py-4 text-sm whitespace-nowrap">+ @if (! $token->expires_at)+ Never+ @elseif ($token->expires_at->isPast())+ <span class="font-bold dark:text-error">Expired+ {{ $token->expires_at->format('Y-m-d H:i:s') }}</span>+ @else+ {{ $token->expires_at->format('Y-m-d H:i:s') }}+ @endif+ </td>+ <td class="px-5 py-4 text-sm font-medium whitespace-nowrap">+ @if (auth()->id() === $token->tokenable_id)+ <x-modal-confirmation title="Confirm API Token Revocation?" isErrorButton+ buttonTitle="Revoke token"+ submitAction="revoke({{ data_get($token, 'id') }})" :actions="[+ 'This API Token will be revoked and permanently deleted.',+ 'Any API call made with this token will fail.',+ ]"+ confirmationText="{{ $token->name }}"+ confirmationLabel="Please confirm the execution of the actions by entering the API Token Description below"+ shortConfirmationLabel="API Token Description" :confirmWithPassword="false"+ step2ButtonText="Revoke API Token" />+ @endif+ </td>+ </tr>+ @empty+ <tr>+ <td class="px-5 py-4 text-sm whitespace-nowrap" colspan="6">No API tokens found.+ </td>+ </tr>+ @endforelse+ </tbody>+ </table></div>- @if (auth()->id() === $token->tokenable_id)- <x-modal-confirmation title="Confirm API Token Revocation?" isErrorButton- buttonTitle="Revoke" submitAction="revoke({{ data_get($token, 'id') }})"- :actions="[- 'This API Token will be revoked and permanently deleted.',- 'Any API call made with this token will fail.',- ]" confirmationText="{{ $token->name }}"- confirmationLabel="Please confirm the execution of the actions by entering the API Token Description below"- shortConfirmationLabel="API Token Description" :confirmWithPassword="false"- step2ButtonText="Revoke API Token" />- @endif</div>- @empty- <div class="text-neutral-400">No API tokens found.</div>- @endforelse+ </div></div></div>@endif