From c21ce45d705bc98cacd7959befc2b0377787a95f Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 27 Aug 2023 15:23:47 +0200 Subject: [PATCH] show public key of generated private key --- app/Actions/License/CheckResaleLicense.php | 4 ++-- app/Actions/Server/InstallDocker.php | 2 +- app/Actions/Server/UpdateCoolify.php | 2 +- app/Console/Kernel.php | 2 +- app/Exceptions/Handler.php | 2 +- app/Http/Controllers/Controller.php | 2 +- app/Http/Livewire/Boarding.php | 11 ++++++----- .../Project/New/GithubPrivateRepositoryDeployKey.php | 2 +- app/Http/Livewire/Project/New/PublicGitRepository.php | 2 +- app/Http/Livewire/Project/New/SimpleDockerfile.php | 2 +- app/Http/Livewire/Team/InviteLink.php | 2 +- app/Http/Livewire/Team/Storage/Create.php | 2 +- app/Http/Livewire/Upgrade.php | 2 +- app/Http/Livewire/Waitlist.php | 2 +- app/Jobs/DockerCleanupJob.php | 2 +- bootstrap/helpers/proxy.php | 2 +- bootstrap/helpers/shared.php | 8 ++++---- .../views/components/applications/links.blade.php | 2 +- resources/views/components/paddle.blade.php | 2 +- resources/views/dashboard.blade.php | 2 +- resources/views/livewire/boarding.blade.php | 10 ++++++++-- .../livewire/notifications/discord-settings.blade.php | 2 +- .../livewire/notifications/email-settings.blade.php | 2 +- resources/views/livewire/server/form.blade.php | 2 +- 24 files changed, 40 insertions(+), 33 deletions(-) diff --git a/app/Actions/License/CheckResaleLicense.php b/app/Actions/License/CheckResaleLicense.php index e7dcecdb6..54f97c834 100644 --- a/app/Actions/License/CheckResaleLicense.php +++ b/app/Actions/License/CheckResaleLicense.php @@ -14,14 +14,14 @@ class CheckResaleLicense $settings->update([ 'is_resale_license_active' => false, ]); - if (is_dev()) { + if (isDev()) { return; } if (!$settings->resale_license) { return; } $base_url = config('coolify.license_url'); - if (is_dev()) { + if (isDev()) { $base_url = 'http://host.docker.internal:8787'; } $instance_id = config('app.id'); diff --git a/app/Actions/Server/InstallDocker.php b/app/Actions/Server/InstallDocker.php index 732d58d52..a26fadc05 100644 --- a/app/Actions/Server/InstallDocker.php +++ b/app/Actions/Server/InstallDocker.php @@ -12,7 +12,7 @@ class InstallDocker { $dockerVersion = '23.0'; $config = base64_encode('{ "live-restore": true }'); - if (is_dev()) { + if (isDev()) { $activity = remote_process([ "echo ####### Installing Prerequisites...", "echo ####### Installing/updating Docker Engine...", diff --git a/app/Actions/Server/UpdateCoolify.php b/app/Actions/Server/UpdateCoolify.php index fa0718d17..0be05894f 100644 --- a/app/Actions/Server/UpdateCoolify.php +++ b/app/Actions/Server/UpdateCoolify.php @@ -50,7 +50,7 @@ class UpdateCoolify private function update() { - if (is_dev()) { + if (isDev()) { ray("Running update on local docker container. Updating to $this->latest_version"); remote_process([ "sleep 10" diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 047f037d7..0dc99ba8a 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -18,7 +18,7 @@ class Kernel extends ConsoleKernel protected function schedule(Schedule $schedule): void { // $schedule->call(fn() => $this->check_scheduled_backups($schedule))->everyTenSeconds(); - if (is_dev()) { + if (isDev()) { $schedule->command('horizon:snapshot')->everyMinute(); $schedule->job(new ResourceStatusJob)->everyMinute(); $schedule->job(new ProxyCheckJob)->everyFiveMinutes(); diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index b08c07012..9d9dabab6 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -45,7 +45,7 @@ class Handler extends ExceptionHandler { $this->reportable(function (Throwable $e) { $this->settings = InstanceSettings::get(); - if ($this->settings->do_not_track || is_dev()) { + if ($this->settings->do_not_track || isDev()) { return; } Integration::captureUnhandledException($e); diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index a194c3ad9..4fd997055 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -66,7 +66,7 @@ class Controller extends BaseController ]); } public function boarding() { - if (currentTeam()->boarding || is_dev()) { + if (currentTeam()->boarding || isDev()) { return view('boarding'); } else { return redirect()->route('dashboard'); diff --git a/app/Http/Livewire/Boarding.php b/app/Http/Livewire/Boarding.php index 524e9ff94..7ec11a3bc 100644 --- a/app/Http/Livewire/Boarding.php +++ b/app/Http/Livewire/Boarding.php @@ -14,6 +14,7 @@ class Boarding extends Component public ?string $privateKeyType = null; public ?string $privateKey = null; + public ?string $publicKey = null; public ?string $privateKeyName = null; public ?string $privateKeyDescription = null; public ?PrivateKey $createdPrivateKey = null; @@ -31,7 +32,7 @@ class Boarding extends Component { $this->privateKeyName = generate_random_name(); $this->remoteServerName = generate_random_name(); - if (is_dev()) { + if (isDev()) { $this->privateKey = '-----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW QyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevAAAAJi/QySHv0Mk @@ -77,6 +78,9 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== public function setPrivateKey(string $type) { $this->privateKeyType = $type; + if ($type === 'create' && !isDev()) { + $this->createNewPrivateKey(); + } $this->currentState = 'create-private-key'; } public function savePrivateKey() @@ -95,9 +99,6 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== 'remoteServerPort' => 'required', 'remoteServerUser' => 'required', ]); - if ($this->privateKeyType === 'create') { - $this->createNewPrivateKey(); - } $this->privateKey = formatPrivateKey($this->privateKey); $this->createdPrivateKey = PrivateKey::create([ 'name' => $this->privateKeyName, @@ -175,6 +176,6 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== { $this->privateKeyName = generate_random_name(); $this->privateKeyDescription = 'Created by Coolify'; - ['private' => $this->privateKey] = generateSSHKey(); + ['private' => $this->privateKey, 'public'=> $this->publicKey] = generateSSHKey(); } } diff --git a/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php b/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php index 82d898149..d18fe2541 100644 --- a/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php +++ b/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php @@ -50,7 +50,7 @@ class GithubPrivateRepositoryDeployKey extends Component public function mount() { - if (is_dev()) { + if (isDev()) { $this->repository_url = 'https://github.com/coollabsio/coolify-examples'; } $this->parameters = get_route_parameters(); diff --git a/app/Http/Livewire/Project/New/PublicGitRepository.php b/app/Http/Livewire/Project/New/PublicGitRepository.php index 7fd15cd34..6229a7fc6 100644 --- a/app/Http/Livewire/Project/New/PublicGitRepository.php +++ b/app/Http/Livewire/Project/New/PublicGitRepository.php @@ -45,7 +45,7 @@ class PublicGitRepository extends Component public function mount() { - if (is_dev()) { + if (isDev()) { $this->repository_url = 'https://github.com/coollabsio/coolify-examples'; $this->port = 3000; } diff --git a/app/Http/Livewire/Project/New/SimpleDockerfile.php b/app/Http/Livewire/Project/New/SimpleDockerfile.php index 6c4731658..e755c8c0f 100644 --- a/app/Http/Livewire/Project/New/SimpleDockerfile.php +++ b/app/Http/Livewire/Project/New/SimpleDockerfile.php @@ -19,7 +19,7 @@ class SimpleDockerfile extends Component { $this->parameters = get_route_parameters(); $this->query = request()->query(); - if (is_dev()) { + if (isDev()) { $this->dockerfile = 'FROM nginx EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] diff --git a/app/Http/Livewire/Team/InviteLink.php b/app/Http/Livewire/Team/InviteLink.php index aaf22f0e8..b554e6575 100644 --- a/app/Http/Livewire/Team/InviteLink.php +++ b/app/Http/Livewire/Team/InviteLink.php @@ -15,7 +15,7 @@ class InviteLink extends Component public function mount() { - $this->email = is_dev() ? 'test3@example.com' : ''; + $this->email = isDev() ? 'test3@example.com' : ''; } public function viaEmail() diff --git a/app/Http/Livewire/Team/Storage/Create.php b/app/Http/Livewire/Team/Storage/Create.php index 52ce3779d..e1330784a 100644 --- a/app/Http/Livewire/Team/Storage/Create.php +++ b/app/Http/Livewire/Team/Storage/Create.php @@ -36,7 +36,7 @@ class Create extends Component public function mount() { - if (is_dev()) { + if (isDev()) { $this->name = 'Local MinIO'; $this->description = 'Local MinIO'; $this->key = 'minioadmin'; diff --git a/app/Http/Livewire/Upgrade.php b/app/Http/Livewire/Upgrade.php index f46e37ff7..e79c73fb7 100644 --- a/app/Http/Livewire/Upgrade.php +++ b/app/Http/Livewire/Upgrade.php @@ -18,7 +18,7 @@ class Upgrade extends Component $this->latestVersion = get_latest_version_of_coolify(); $currentVersion = config('version'); version_compare($currentVersion, $this->latestVersion, '<') ? $this->isUpgradeAvailable = true : $this->isUpgradeAvailable = false; - if (is_dev()) { + if (isDev()) { $this->isUpgradeAvailable = true; } $settings = InstanceSettings::get(); diff --git a/app/Http/Livewire/Waitlist.php b/app/Http/Livewire/Waitlist.php index de633ceac..d9b3b92ab 100644 --- a/app/Http/Livewire/Waitlist.php +++ b/app/Http/Livewire/Waitlist.php @@ -17,7 +17,7 @@ class Waitlist extends Component ]; public function mount() { - if (is_dev()) { + if (isDev()) { $this->email = 'waitlist@example.com'; } } diff --git a/app/Jobs/DockerCleanupJob.php b/app/Jobs/DockerCleanupJob.php index df6e1915b..7a8571c00 100644 --- a/app/Jobs/DockerCleanupJob.php +++ b/app/Jobs/DockerCleanupJob.php @@ -32,7 +32,7 @@ class DockerCleanupJob implements ShouldQueue try { $servers = Server::all(); foreach ($servers as $server) { - if (is_dev()) { + if (isDev()) { $docker_root_filesystem = "/"; } else { $docker_root_filesystem = instant_remote_process(['stat --printf=%m $(docker info --format "{{json .DockerRootDir}}" |sed \'s/"//g\')'], $server); diff --git a/bootstrap/helpers/proxy.php b/bootstrap/helpers/proxy.php index 37049aaa3..164c46e94 100644 --- a/bootstrap/helpers/proxy.php +++ b/bootstrap/helpers/proxy.php @@ -82,7 +82,7 @@ function generate_default_proxy_configuration(Server $server) ], ], ]; - if (is_dev()) { + if (isDev()) { $config['services']['traefik']['command'][] = "--log.level=debug"; } return Yaml::dump($config, 4, 2); diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 367d806df..f1670723e 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -163,7 +163,7 @@ function set_transanctional_email_settings(InstanceSettings | null $settings = n function base_ip(): string { - if (is_dev()) { + if (isDev()) { return "localhost"; } $settings = InstanceSettings::get(); @@ -188,12 +188,12 @@ function base_url(bool $withPort = true): string $port = config('app.port'); if ($settings->public_ipv4) { if ($withPort) { - if (is_dev()) { + if (isDev()) { return "http://localhost:$port"; } return "http://$settings->public_ipv4:$port"; } - if (is_dev()) { + if (isDev()) { return "http://localhost"; } return "http://$settings->public_ipv4"; @@ -207,7 +207,7 @@ function base_url(bool $withPort = true): string return url('/'); } -function is_dev(): bool +function isDev(): bool { return config('app.env') === 'local'; } diff --git a/resources/views/components/applications/links.blade.php b/resources/views/components/applications/links.blade.php index 9d0a75c70..9e90c9b2b 100644 --- a/resources/views/components/applications/links.blade.php +++ b/resources/views/components/applications/links.blade.php @@ -55,7 +55,7 @@ @endif @if (data_get($application, 'ports_mappings_array')) @foreach ($application->ports_mappings_array as $port) - @if (is_dev()) + @if (isDev())
  • diff --git a/resources/views/components/paddle.blade.php b/resources/views/components/paddle.blade.php index 095487a6d..5aa10b200 100644 --- a/resources/views/components/paddle.blade.php +++ b/resources/views/components/paddle.blade.php @@ -28,7 +28,7 @@