show public key of generated private key

This commit is contained in:
Andras Bacsai 2023-08-27 15:23:47 +02:00
parent 9f10cb2899
commit c21ce45d70
24 changed files with 40 additions and 33 deletions

View File

@ -14,14 +14,14 @@ class CheckResaleLicense
$settings->update([ $settings->update([
'is_resale_license_active' => false, 'is_resale_license_active' => false,
]); ]);
if (is_dev()) { if (isDev()) {
return; return;
} }
if (!$settings->resale_license) { if (!$settings->resale_license) {
return; return;
} }
$base_url = config('coolify.license_url'); $base_url = config('coolify.license_url');
if (is_dev()) { if (isDev()) {
$base_url = 'http://host.docker.internal:8787'; $base_url = 'http://host.docker.internal:8787';
} }
$instance_id = config('app.id'); $instance_id = config('app.id');

View File

@ -12,7 +12,7 @@ class InstallDocker
{ {
$dockerVersion = '23.0'; $dockerVersion = '23.0';
$config = base64_encode('{ "live-restore": true }'); $config = base64_encode('{ "live-restore": true }');
if (is_dev()) { if (isDev()) {
$activity = remote_process([ $activity = remote_process([
"echo ####### Installing Prerequisites...", "echo ####### Installing Prerequisites...",
"echo ####### Installing/updating Docker Engine...", "echo ####### Installing/updating Docker Engine...",

View File

@ -50,7 +50,7 @@ class UpdateCoolify
private function update() private function update()
{ {
if (is_dev()) { if (isDev()) {
ray("Running update on local docker container. Updating to $this->latest_version"); ray("Running update on local docker container. Updating to $this->latest_version");
remote_process([ remote_process([
"sleep 10" "sleep 10"

View File

@ -18,7 +18,7 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule): void protected function schedule(Schedule $schedule): void
{ {
// $schedule->call(fn() => $this->check_scheduled_backups($schedule))->everyTenSeconds(); // $schedule->call(fn() => $this->check_scheduled_backups($schedule))->everyTenSeconds();
if (is_dev()) { if (isDev()) {
$schedule->command('horizon:snapshot')->everyMinute(); $schedule->command('horizon:snapshot')->everyMinute();
$schedule->job(new ResourceStatusJob)->everyMinute(); $schedule->job(new ResourceStatusJob)->everyMinute();
$schedule->job(new ProxyCheckJob)->everyFiveMinutes(); $schedule->job(new ProxyCheckJob)->everyFiveMinutes();

View File

@ -45,7 +45,7 @@ class Handler extends ExceptionHandler
{ {
$this->reportable(function (Throwable $e) { $this->reportable(function (Throwable $e) {
$this->settings = InstanceSettings::get(); $this->settings = InstanceSettings::get();
if ($this->settings->do_not_track || is_dev()) { if ($this->settings->do_not_track || isDev()) {
return; return;
} }
Integration::captureUnhandledException($e); Integration::captureUnhandledException($e);

View File

@ -66,7 +66,7 @@ class Controller extends BaseController
]); ]);
} }
public function boarding() { public function boarding() {
if (currentTeam()->boarding || is_dev()) { if (currentTeam()->boarding || isDev()) {
return view('boarding'); return view('boarding');
} else { } else {
return redirect()->route('dashboard'); return redirect()->route('dashboard');

View File

@ -14,6 +14,7 @@ class Boarding extends Component
public ?string $privateKeyType = null; public ?string $privateKeyType = null;
public ?string $privateKey = null; public ?string $privateKey = null;
public ?string $publicKey = null;
public ?string $privateKeyName = null; public ?string $privateKeyName = null;
public ?string $privateKeyDescription = null; public ?string $privateKeyDescription = null;
public ?PrivateKey $createdPrivateKey = null; public ?PrivateKey $createdPrivateKey = null;
@ -31,7 +32,7 @@ class Boarding extends Component
{ {
$this->privateKeyName = generate_random_name(); $this->privateKeyName = generate_random_name();
$this->remoteServerName = generate_random_name(); $this->remoteServerName = generate_random_name();
if (is_dev()) { if (isDev()) {
$this->privateKey = '-----BEGIN OPENSSH PRIVATE KEY----- $this->privateKey = '-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
QyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevAAAAJi/QySHv0Mk QyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevAAAAJi/QySHv0Mk
@ -77,6 +78,9 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
public function setPrivateKey(string $type) public function setPrivateKey(string $type)
{ {
$this->privateKeyType = $type; $this->privateKeyType = $type;
if ($type === 'create' && !isDev()) {
$this->createNewPrivateKey();
}
$this->currentState = 'create-private-key'; $this->currentState = 'create-private-key';
} }
public function savePrivateKey() public function savePrivateKey()
@ -95,9 +99,6 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
'remoteServerPort' => 'required', 'remoteServerPort' => 'required',
'remoteServerUser' => 'required', 'remoteServerUser' => 'required',
]); ]);
if ($this->privateKeyType === 'create') {
$this->createNewPrivateKey();
}
$this->privateKey = formatPrivateKey($this->privateKey); $this->privateKey = formatPrivateKey($this->privateKey);
$this->createdPrivateKey = PrivateKey::create([ $this->createdPrivateKey = PrivateKey::create([
'name' => $this->privateKeyName, 'name' => $this->privateKeyName,
@ -175,6 +176,6 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
{ {
$this->privateKeyName = generate_random_name(); $this->privateKeyName = generate_random_name();
$this->privateKeyDescription = 'Created by Coolify'; $this->privateKeyDescription = 'Created by Coolify';
['private' => $this->privateKey] = generateSSHKey(); ['private' => $this->privateKey, 'public'=> $this->publicKey] = generateSSHKey();
} }
} }

View File

@ -50,7 +50,7 @@ class GithubPrivateRepositoryDeployKey extends Component
public function mount() public function mount()
{ {
if (is_dev()) { if (isDev()) {
$this->repository_url = 'https://github.com/coollabsio/coolify-examples'; $this->repository_url = 'https://github.com/coollabsio/coolify-examples';
} }
$this->parameters = get_route_parameters(); $this->parameters = get_route_parameters();

View File

@ -45,7 +45,7 @@ class PublicGitRepository extends Component
public function mount() public function mount()
{ {
if (is_dev()) { if (isDev()) {
$this->repository_url = 'https://github.com/coollabsio/coolify-examples'; $this->repository_url = 'https://github.com/coollabsio/coolify-examples';
$this->port = 3000; $this->port = 3000;
} }

View File

@ -19,7 +19,7 @@ class SimpleDockerfile extends Component
{ {
$this->parameters = get_route_parameters(); $this->parameters = get_route_parameters();
$this->query = request()->query(); $this->query = request()->query();
if (is_dev()) { if (isDev()) {
$this->dockerfile = 'FROM nginx $this->dockerfile = 'FROM nginx
EXPOSE 80 EXPOSE 80
CMD ["nginx", "-g", "daemon off;"] CMD ["nginx", "-g", "daemon off;"]

View File

@ -15,7 +15,7 @@ class InviteLink extends Component
public function mount() public function mount()
{ {
$this->email = is_dev() ? 'test3@example.com' : ''; $this->email = isDev() ? 'test3@example.com' : '';
} }
public function viaEmail() public function viaEmail()

View File

@ -36,7 +36,7 @@ class Create extends Component
public function mount() public function mount()
{ {
if (is_dev()) { if (isDev()) {
$this->name = 'Local MinIO'; $this->name = 'Local MinIO';
$this->description = 'Local MinIO'; $this->description = 'Local MinIO';
$this->key = 'minioadmin'; $this->key = 'minioadmin';

View File

@ -18,7 +18,7 @@ class Upgrade extends Component
$this->latestVersion = get_latest_version_of_coolify(); $this->latestVersion = get_latest_version_of_coolify();
$currentVersion = config('version'); $currentVersion = config('version');
version_compare($currentVersion, $this->latestVersion, '<') ? $this->isUpgradeAvailable = true : $this->isUpgradeAvailable = false; version_compare($currentVersion, $this->latestVersion, '<') ? $this->isUpgradeAvailable = true : $this->isUpgradeAvailable = false;
if (is_dev()) { if (isDev()) {
$this->isUpgradeAvailable = true; $this->isUpgradeAvailable = true;
} }
$settings = InstanceSettings::get(); $settings = InstanceSettings::get();

View File

@ -17,7 +17,7 @@ class Waitlist extends Component
]; ];
public function mount() public function mount()
{ {
if (is_dev()) { if (isDev()) {
$this->email = 'waitlist@example.com'; $this->email = 'waitlist@example.com';
} }
} }

View File

@ -32,7 +32,7 @@ class DockerCleanupJob implements ShouldQueue
try { try {
$servers = Server::all(); $servers = Server::all();
foreach ($servers as $server) { foreach ($servers as $server) {
if (is_dev()) { if (isDev()) {
$docker_root_filesystem = "/"; $docker_root_filesystem = "/";
} else { } else {
$docker_root_filesystem = instant_remote_process(['stat --printf=%m $(docker info --format "{{json .DockerRootDir}}" |sed \'s/"//g\')'], $server); $docker_root_filesystem = instant_remote_process(['stat --printf=%m $(docker info --format "{{json .DockerRootDir}}" |sed \'s/"//g\')'], $server);

View File

@ -82,7 +82,7 @@ function generate_default_proxy_configuration(Server $server)
], ],
], ],
]; ];
if (is_dev()) { if (isDev()) {
$config['services']['traefik']['command'][] = "--log.level=debug"; $config['services']['traefik']['command'][] = "--log.level=debug";
} }
return Yaml::dump($config, 4, 2); return Yaml::dump($config, 4, 2);

View File

@ -163,7 +163,7 @@ function set_transanctional_email_settings(InstanceSettings | null $settings = n
function base_ip(): string function base_ip(): string
{ {
if (is_dev()) { if (isDev()) {
return "localhost"; return "localhost";
} }
$settings = InstanceSettings::get(); $settings = InstanceSettings::get();
@ -188,12 +188,12 @@ function base_url(bool $withPort = true): string
$port = config('app.port'); $port = config('app.port');
if ($settings->public_ipv4) { if ($settings->public_ipv4) {
if ($withPort) { if ($withPort) {
if (is_dev()) { if (isDev()) {
return "http://localhost:$port"; return "http://localhost:$port";
} }
return "http://$settings->public_ipv4:$port"; return "http://$settings->public_ipv4:$port";
} }
if (is_dev()) { if (isDev()) {
return "http://localhost"; return "http://localhost";
} }
return "http://$settings->public_ipv4"; return "http://$settings->public_ipv4";
@ -207,7 +207,7 @@ function base_url(bool $withPort = true): string
return url('/'); return url('/');
} }
function is_dev(): bool function isDev(): bool
{ {
return config('app.env') === 'local'; return config('app.env') === 'local';
} }

View File

@ -55,7 +55,7 @@
@endif @endif
@if (data_get($application, 'ports_mappings_array')) @if (data_get($application, 'ports_mappings_array'))
@foreach ($application->ports_mappings_array as $port) @foreach ($application->ports_mappings_array as $port)
@if (is_dev()) @if (isDev())
<li> <li>
<a class="text-xs text-white rounded-none hover:no-underline hover:bg-coollabs hover:text-white" <a class="text-xs text-white rounded-none hover:no-underline hover:bg-coollabs hover:text-white"
target="_blank" href="http://localhost:{{ explode(':', $port)[0] }}"> target="_blank" href="http://localhost:{{ explode(':', $port)[0] }}">

View File

@ -28,7 +28,7 @@
<x-slot:other> <x-slot:other>
<script src="https://cdn.paddle.com/paddle/v2/paddle.js"></script> <script src="https://cdn.paddle.com/paddle/v2/paddle.js"></script>
<script type="text/javascript"> <script type="text/javascript">
Paddle.Environment.set("{{ is_dev() ? 'sandbox' : 'production' }}"); Paddle.Environment.set("{{ isDev() ? 'sandbox' : 'production' }}");
Paddle.Setup({ Paddle.Setup({
seller: {{ config('subscription.paddle_vendor_id') }}, seller: {{ config('subscription.paddle_vendor_id') }},
checkout: { checkout: {

View File

@ -22,7 +22,7 @@
<div class="stat-value">{{ $s3s->count() }}</div> <div class="stat-value">{{ $s3s->count() }}</div>
</div> </div>
</div> </div>
@if (is_dev()) @if (isDev())
{{-- <livewire:dev.s3-test /> --}} {{-- <livewire:dev.s3-test /> --}}
@endif @endif
</x-layout> </x-layout>

View File

@ -47,7 +47,8 @@
<x-slot:explanation> <x-slot:explanation>
<p>SSH Keys are used to connect to a remote server through a secure shell, called SSH.</p> <p>SSH Keys are used to connect to a remote server through a secure shell, called SSH.</p>
<p>You can use your own ssh private key, or you can let Coolify to create one for you.</p> <p>You can use your own ssh private key, or you can let Coolify to create one for you.</p>
<p>In both ways, you need to add the public version of your ssh private key to the remote server's <p>In both ways, you need to add the public version of your ssh private key to the remote
server's
<code class="text-warning">~/.ssh/authorized_keys</code> file. <code class="text-warning">~/.ssh/authorized_keys</code> file.
</p> </p>
</x-slot:explanation> </x-slot:explanation>
@ -66,6 +67,10 @@
label="Description" id="privateKeyDescription" /> label="Description" id="privateKeyDescription" />
<x-forms.textarea required placeholder="-----BEGIN OPENSSH PRIVATE KEY-----" <x-forms.textarea required placeholder="-----BEGIN OPENSSH PRIVATE KEY-----"
label="Private Key" id="privateKey" /> label="Private Key" id="privateKey" />
@if ($privateKeyType === 'create' && !isDev())
<span class="font-bold text-warning">Copy this to your server's ~/.ssh/authorized_keys file.</span>
<x-forms.textarea rows="7" readonly label="Public Key" id="publicKey" />
@endif
<x-forms.button type="submit">Save</x-forms.button> <x-forms.button type="submit">Save</x-forms.button>
</form> </form>
</x-slot:actions> </x-slot:actions>
@ -115,7 +120,8 @@
Could not find Docker Engine on your server. Do you want me to install it for you? Could not find Docker Engine on your server. Do you want me to install it for you?
</x-slot:question> </x-slot:question>
<x-slot:actions> <x-slot:actions>
<div class="justify-center box" wire:click="installDocker" onclick="installDocker.showModal()">Let's do <div class="justify-center box" wire:click="installDocker" onclick="installDocker.showModal()">
Let's do
it!</div> it!</div>
</x-slot:actions> </x-slot:actions>
<x-slot:explanation> <x-slot:explanation>

View File

@ -22,7 +22,7 @@
@if (data_get($model, 'discord_enabled')) @if (data_get($model, 'discord_enabled'))
<h3 class="mt-4">Subscribe to events</h3> <h3 class="mt-4">Subscribe to events</h3>
<div class="w-64"> <div class="w-64">
@if (is_dev()) @if (isDev())
<x-forms.checkbox instantSave="saveModel" id="model.discord_notifications_test" label="Test" /> <x-forms.checkbox instantSave="saveModel" id="model.discord_notifications_test" label="Test" />
@endif @endif
<h4 class="mt-4">General</h4> <h4 class="mt-4">General</h4>

View File

@ -59,7 +59,7 @@
@if (data_get($model, 'smtp_enabled')) @if (data_get($model, 'smtp_enabled'))
<h4 class="mt-4">Subscribe to events</h4> <h4 class="mt-4">Subscribe to events</h4>
<div class="w-64"> <div class="w-64">
@if (is_dev()) @if (isDev())
<x-forms.checkbox instantSave="saveModel" id="model.smtp_notifications_test" label="Test" /> <x-forms.checkbox instantSave="saveModel" id="model.smtp_notifications_test" label="Test" />
@endif @endif
<h4 class="mt-4">General</h4> <h4 class="mt-4">General</h4>

View File

@ -93,7 +93,7 @@
<div class="pb-4">This will remove this server from Coolify. Beware! There is no coming <div class="pb-4">This will remove this server from Coolify. Beware! There is no coming
back! back!
</div> </div>
@if ($server->id !== 0 || is_dev()) @if ($server->id !== 0 || isDev())
<x-forms.button isError isModal modalId="deleteServer"> <x-forms.button isError isModal modalId="deleteServer">
Delete Delete
</x-forms.button> </x-forms.button>