init of cloud providers

This commit is contained in:
Andras Bacsai committed 2025-10-08 20:47:50 +02:00
1 parent b803a137f6
commit c1bcc41546
13 files changed
+548 -2

No files matched your search

@@ -6,8 +6,13 @@
<a href="{{ route('security.private-key.index') }}">
<button>Private Keys</button>
</a>
@can('viewAny', App\Models\CloudProviderToken::class)
<a href="{{ route('security.cloud-tokens') }}">
<button>Cloud Tokens</button>
</a>
@endcan
<a href="{{ route('security.api-tokens') }}">
<button>API tokens</button>
<button>API Tokens</button>
</a>
</nav>
</div>
@@ -0,0 +1,66 @@
<div>
<h2>Cloud Provider Tokens</h2>
<div class="pb-4">Manage API tokens for cloud providers (Hetzner, DigitalOcean, etc.). Tokens are saved encrypted and shared with your team.</div>
<h3>New Token</h3>
@can('create', App\Models\CloudProviderToken::class)
<form class="flex flex-col gap-2" wire:submit='addNewToken'>
<div class="flex gap-2 items-end flex-wrap">
<div class="w-64">
<x-forms.select required id="provider" label="Provider">
<option value="hetzner">Hetzner</option>
<option value="digitalocean">DigitalOcean</option>
</x-forms.select>
</div>
<div class="flex-1 min-w-64">
<x-forms.input required id="name" label="Token Name" placeholder="e.g., Production Hetzner" />
</div>
</div>
<div class="flex gap-2 items-end flex-wrap">
<div class="flex-1 min-w-64">
<x-forms.input required type="password" id="token" label="API Token" placeholder="Enter your API token" />
</div>
<x-forms.button type="submit">Add Token</x-forms.button>
</div>
</form>
@endcan
<h3 class="py-4">Saved Tokens</h3>
<div class="grid gap-2 lg:grid-cols-1">
@forelse ($tokens as $savedToken)
<div wire:key="token-{{ $savedToken->id }}"
class="flex flex-col gap-1 p-2 border dark:border-coolgray-200 hover:no-underline">
<div class="flex items-center gap-2">
<span class="px-2 py-1 text-xs font-bold rounded dark:bg-coolgray-300 dark:text-white">
{{ strtoupper($savedToken->provider) }}
</span>
<span class="font-bold dark:text-white">{{ $savedToken->name }}</span>
</div>
<div class="text-sm">Token: ***{{ substr($savedToken->token, -4) }}</div>
<div class="text-sm">Created: {{ $savedToken->created_at->diffForHumans() }}</div>
@can('delete', $savedToken)
<x-modal-confirmation
title="Confirm Token Deletion?"
isErrorButton
buttonTitle="Delete Token"
submitAction="deleteToken({{ $savedToken->id }})"
:actions="[
'This cloud provider token will be permanently deleted.',
'Any servers using this token will need to be reconfigured.',
]"
confirmationText="{{ $savedToken->name }}"
confirmationLabel="Please confirm the deletion by entering the token name below"
shortConfirmationLabel="Token Name"
:confirmWithPassword="false"
step2ButtonText="Delete Token"
/>
@endcan
</div>
@empty
<div>
<div>No cloud provider tokens found.</div>
</div>
@endforelse
</div>
</div>
@@ -0,0 +1,7 @@
<div>
<x-slot:title>
Cloud Tokens | Coolify
</x-slot>
<x-security.navbar />
<livewire:security.cloud-provider-tokens />
</div>
@@ -1,3 +1,23 @@
<div class="w-full">
<livewire:server.new.by-ip :private_keys="$private_keys" :limit_reached="$limit_reached" />
<div class="flex flex-col gap-4">
@can('viewAny', App\Models\CloudProviderToken::class)
<div>
<h3 class="pb-2">Add Server from Cloud Provider</h3>
<div class="flex gap-2 flex-wrap">
<x-modal-input
buttonTitle="+ Hetzner"
title="Connect to Hetzner">
<livewire:server.new.by-hetzner :private_keys="$private_keys" :limit_reached="$limit_reached" />
</x-modal-input>
</div>
</div>
<div class="border-t dark:border-coolgray-300 my-4"></div>
@endcan
<div>
<h3 class="pb-2">Add Server by IP Address</h3>
<livewire:server.new.by-ip :private_keys="$private_keys" :limit_reached="$limit_reached" />
</div>
</div>
</div>
@@ -0,0 +1,52 @@
<div class="w-full">
@if ($limit_reached)
<x-limit-reached name="servers" />
@else
<form class="flex flex-col w-full gap-2" wire:submit='submit'>
@if ($available_tokens->count() > 0)
<div>
<x-forms.select label="Use Saved Token" id="selected_token_id" wire:change="selectToken($event.target.value)">
<option value="">Select a saved token...</option>
@foreach ($available_tokens as $token)
<option value="{{ $token->id }}">
{{ $token->name ?? 'Hetzner Token' }} (***{{ substr($token->token, -4) }})
</option>
@endforeach
</x-forms.select>
</div>
<div class="text-center text-sm dark:text-neutral-500 py-2">OR</div>
@endif
<div>
<x-forms.input
type="password"
id="hetzner_token"
label="New Hetzner API Token"
helper="Your Hetzner Cloud API token. You can create one in your <a href='https://console.hetzner.cloud/' target='_blank' class='underline dark:text-white'>Hetzner Cloud Console</a>."
/>
</div>
<div>
<x-forms.checkbox
id="save_token"
label="Save this token for my team"
/>
</div>
@if ($save_token)
<div>
<x-forms.input
id="token_name"
label="Token Name"
placeholder="e.g., Production Hetzner"
helper="Give this token a friendly name to identify it later."
/>
</div>
@endif
<x-forms.button canGate="create" :canResource="App\Models\Server::class" type="submit">
Continue
</x-forms.button>
</form>
@endif
</div>