setting to disable tow step confirmation

This commit is contained in:
peaklabs-dev
2024-10-17 12:07:35 +02:00
parent 5d62a46a16
commit 2cb424ed7b
3 changed files with 114 additions and 92 deletions

View File

@@ -25,6 +25,10 @@ class Index extends Component
public string $update_check_frequency; public string $update_check_frequency;
public $timezones;
public bool $disable_two_step_confirmation;
protected string $dynamic_config_path = '/data/coolify/proxy/dynamic'; protected string $dynamic_config_path = '/data/coolify/proxy/dynamic';
protected Server $server; protected Server $server;
@@ -55,8 +59,6 @@ class Index extends Component
'update_check_frequency' => 'Update Check Frequency', 'update_check_frequency' => 'Update Check Frequency',
]; ];
public $timezones;
public function mount() public function mount()
{ {
if (isInstanceAdmin()) { if (isInstanceAdmin()) {
@@ -69,6 +71,7 @@ class Index extends Component
$this->auto_update_frequency = $this->settings->auto_update_frequency; $this->auto_update_frequency = $this->settings->auto_update_frequency;
$this->update_check_frequency = $this->settings->update_check_frequency; $this->update_check_frequency = $this->settings->update_check_frequency;
$this->timezones = collect(timezone_identifiers_list())->sort()->values()->toArray(); $this->timezones = collect(timezone_identifiers_list())->sort()->values()->toArray();
$this->disable_two_step_confirmation = $this->settings->disable_two_step_confirmation;
} else { } else {
return redirect()->route('dashboard'); return redirect()->route('dashboard');
} }
@@ -83,6 +86,7 @@ class Index extends Component
$this->settings->is_api_enabled = $this->is_api_enabled; $this->settings->is_api_enabled = $this->is_api_enabled;
$this->settings->auto_update_frequency = $this->auto_update_frequency; $this->settings->auto_update_frequency = $this->auto_update_frequency;
$this->settings->update_check_frequency = $this->update_check_frequency; $this->settings->update_check_frequency = $this->update_check_frequency;
$this->settings->disable_two_step_confirmation = $this->disable_two_step_confirmation;
$this->settings->save(); $this->settings->save();
$this->dispatch('success', 'Settings updated!'); $this->dispatch('success', 'Settings updated!');
} }
@@ -148,6 +152,7 @@ class Index extends Component
$this->settings->is_api_enabled = $this->is_api_enabled; $this->settings->is_api_enabled = $this->is_api_enabled;
$this->settings->auto_update_frequency = $this->auto_update_frequency; $this->settings->auto_update_frequency = $this->auto_update_frequency;
$this->settings->update_check_frequency = $this->update_check_frequency; $this->settings->update_check_frequency = $this->update_check_frequency;
$this->settings->disable_two_step_confirmation = $this->disable_two_step_confirmation;
$this->settings->save(); $this->settings->save();
$this->server->setupDynamicProxyConfiguration(); $this->server->setupDynamicProxyConfiguration();
if (! $error_show) { if (! $error_show) {

View File

@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::table('instance_settings', function (Blueprint $table) {
$table->boolean('disable_two_step_confirmation')->default(false);
});
}
public function down()
{
Schema::table('instance_settings', function (Blueprint $table) {
$table->dropColumn('disable_two_step_confirmation');
});
}
};

View File

@@ -1,26 +1,24 @@
<div> <div>
<x-slot:title> <x-slot:title>
Settings | Coolify Settings | Coolify
</x-slot> </x-slot>
<x-settings.navbar /> <x-settings.navbar />
<form wire:submit='submit' class="flex flex-col"> <form wire:submit='submit' class="flex flex-col">
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<h2>Configuration</h2> <h2>Configuration</h2>
<x-forms.button type="submit"> <x-forms.button type="submit">
Save Save
</x-forms.button> </x-forms.button>
</div> </div>
<div>General configuration for your Coolify instance.</div> <div>General configuration for your Coolify instance.</div>
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<h4 class="pt-6">Instance Settings</h4> <h4 class="pt-6">Instance Settings</h4>
<div class="flex flex-wrap items-end gap-2"> <div class="flex flex-wrap items-end gap-2">
<div class="flex gap-2 md:flex-row flex-col w-full"> <div class="flex gap-2 md:flex-row flex-col w-full">
<x-forms.input id="settings.fqdn" label="Instance's Domain" <x-forms.input id="settings.fqdn" label="Instance's Domain" helper="Enter the full domain name (FQDN) of the instance, including 'https://' if you want to secure the dashboard with HTTPS. Setting this will make the dashboard accessible via this domain, secured by HTTPS, instead of just the IP address." placeholder="https://coolify.yourdomain.com" />
helper="Enter the full domain name (FQDN) of the instance, including 'https://' if you want to secure the dashboard with HTTPS. Setting this will make the dashboard accessible via this domain, secured by HTTPS, instead of just the IP address." <x-forms.input id="settings.instance_name" label="Instance's Name" placeholder="Coolify" />
placeholder="https://coolify.yourdomain.com" /> <div class="w-full" x-data="{
<x-forms.input id="settings.instance_name" label="Instance's Name" placeholder="Coolify" />
<div class="w-full" x-data="{
open: false, open: false,
search: '{{ $settings->instance_timezone ?: '' }}', search: '{{ $settings->instance_timezone ?: '' }}',
timezones: @js($timezones), timezones: @js($timezones),
@@ -33,92 +31,89 @@
}) })
} }
}"> }">
<div class="flex items-center mb-1"> <div class="flex items-center mb-1">
<label for="settings.instance_timezone">Instance <label for="settings.instance_timezone">Instance
Timezone</label> Timezone</label>
<x-helper class="ml-2" <x-helper class="ml-2" helper="Timezone for the Coolify instance. This is used for the update check and automatic update frequency." />
helper="Timezone for the Coolify instance. This is used for the update check and automatic update frequency." />
</div>
<div class="relative">
<div class="inline-flex items-center relative w-full">
<input autocomplete="off" wire:dirty.class.remove='dark:focus:ring-coolgray-300 dark:ring-coolgray-300'
wire:dirty.class="dark:focus:ring-warning dark:ring-warning" x-model="search"
@focus="open = true" @click.away="open = false" @input="open = true"
class="w-full input " :placeholder="placeholder"
wire:model.debounce.300ms="settings.instance_timezone">
<svg class="absolute right-0 w-4 h-4 mr-2" xmlns="http://www.w3.org/2000/svg"
fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
@click="open = true">
<path stroke-linecap="round" stroke-linejoin="round"
d="M8.25 15L12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9" />
</svg>
</div> </div>
<div x-show="open" <div class="relative">
class="absolute z-50 w-full mt-1 bg-white dark:bg-coolgray-100 border dark:border-coolgray-200 rounded-md shadow-lg max-h-60 overflow-auto scrollbar overflow-x-hidden"> <div class="inline-flex items-center relative w-full">
<template <input autocomplete="off" wire:dirty.class.remove='dark:focus:ring-coolgray-300 dark:ring-coolgray-300' wire:dirty.class="dark:focus:ring-warning dark:ring-warning" x-model="search" @focus="open = true" @click.away="open = false" @input="open = true" class="w-full input " :placeholder="placeholder" wire:model.debounce.300ms="settings.instance_timezone">
x-for="timezone in timezones.filter(tz => tz.toLowerCase().includes(search.toLowerCase()))" <svg class="absolute right-0 w-4 h-4 mr-2" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" @click="open = true">
:key="timezone"> <path stroke-linecap="round" stroke-linejoin="round" d="M8.25 15L12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9" />
<div @click="search = timezone; open = false; $wire.set('settings.instance_timezone', timezone)" </svg>
class="px-4 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-coolgray-300 text-gray-800 dark:text-gray-200" </div>
x-text="timezone"></div> <div x-show="open" class="absolute z-50 w-full mt-1 bg-white dark:bg-coolgray-100 border dark:border-coolgray-200 rounded-md shadow-lg max-h-60 overflow-auto scrollbar overflow-x-hidden">
</template> <template x-for="timezone in timezones.filter(tz => tz.toLowerCase().includes(search.toLowerCase()))" :key="timezone">
<div @click="search = timezone; open = false; $wire.set('settings.instance_timezone', timezone)" class="px-4 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-coolgray-300 text-gray-800 dark:text-gray-200" x-text="timezone"></div>
</template>
</div>
</div> </div>
</div> </div>
</div> </div>
<h4 class="w-full pt-6">DNS Validation</h4>
<div class="md:w-96">
<x-forms.checkbox instantSave id="is_dns_validation_enabled" label="Enabled" />
</div>
<x-forms.input id="settings.custom_dns_servers" label="DNS Servers" helper="DNS servers to validate FQDNs against. A comma separated list of DNS servers." placeholder="1.1.1.1,8.8.8.8" />
</div> </div>
<h4 class="w-full pt-6">DNS Validation</h4> {{-- <div class="flex gap-2 ">
<div class="md:w-96">
<x-forms.checkbox instantSave id="is_dns_validation_enabled" label="Enabled" />
</div>
<x-forms.input id="settings.custom_dns_servers" label="DNS Servers"
helper="DNS servers to validate FQDNs against. A comma separated list of DNS servers."
placeholder="1.1.1.1,8.8.8.8" />
</div>
{{-- <div class="flex gap-2 ">
<x-forms.input type="number" id="settings.public_port_min" label="Public Port Min" /> <x-forms.input type="number" id="settings.public_port_min" label="Public Port Min" />
<x-forms.input type="number" id="settings.public_port_max" label="Public Port Max" /> <x-forms.input type="number" id="settings.public_port_max" label="Public Port Max" />
</div> --}} </div> --}}
</div> </div>
<h4 class="pt-6">API</h4> <h4 class="pt-6">API</h4>
<div class="md:w-96"> <div class="md:w-96">
<x-forms.checkbox instantSave id="is_api_enabled" label="Enabled" /> <x-forms.checkbox instantSave id="is_api_enabled" label="Enabled" />
</div> </div>
<x-forms.input id="settings.allowed_ips" label="Allowed IPs" <x-forms.input id="settings.allowed_ips" label="Allowed IPs" helper="Allowed IP lists for the API. A comma separated list of IPs. Empty means you allow from everywhere." placeholder="1.1.1.1,8.8.8.8" />
helper="Allowed IP lists for the API. A comma separated list of IPs. Empty means you allow from everywhere."
placeholder="1.1.1.1,8.8.8.8" />
<h4 class="pt-6">Advanced</h4> <h5 class="pt-4 font-bold text-white">Update</h5>
<div class="text-right md:w-96"> <div class="text-right md:w-96">
<x-forms.checkbox instantSave id="is_registration_enabled" label="Registration Allowed" /> @if (!is_null(env('AUTOUPDATE', null)))
<x-forms.checkbox instantSave id="do_not_track" label="Do Not Track" />
</div>
<h5 class="pt-4 font-bold text-white">Update</h5>
<div class="text-right md:w-96">
@if (!is_null(env('AUTOUPDATE', null)))
<div class="text-right md:w-96"> <div class="text-right md:w-96">
<x-forms.checkbox instantSave helper="AUTOUPDATE is set in .env file, you need to modify it there." <x-forms.checkbox instantSave helper="AUTOUPDATE is set in .env file, you need to modify it there." disabled id="is_auto_update_enabled" label="Enabled" />
disabled id="is_auto_update_enabled" label="Enabled" />
</div> </div>
@else @else
<x-forms.checkbox instantSave id="is_auto_update_enabled" label="Auto Update Enabled" /> <x-forms.checkbox instantSave id="is_auto_update_enabled" label="Auto Update Enabled" />
@endif @endif
</div> </div>
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<div class="flex items-end gap-2"> <div class="flex items-end gap-2">
<x-forms.input required id="update_check_frequency" label="Update Check Frequency" <x-forms.input required id="update_check_frequency" label="Update Check Frequency" placeholder="0 * * * *" helper="Cron expression for update check frequency (check for new Coolify versions and pull new Service Templates from CDN).<br>You can use every_minute, hourly, daily, weekly, monthly, yearly.<br><br>Default is every hour." />
placeholder="0 * * * *" <x-forms.button wire:click='checkManually'>Check Manually</x-forms.button>
helper="Cron expression for update check frequency (check for new Coolify versions and pull new Service Templates from CDN).<br>You can use every_minute, hourly, daily, weekly, monthly, yearly.<br><br>Default is every hour." /> </div>
<x-forms.button wire:click='checkManually'>Check Manually</x-forms.button>
@if (is_null(env('AUTOUPDATE', null)) && $is_auto_update_enabled)
<x-forms.input required id="auto_update_frequency" label="Auto Update Frequency" placeholder="0 0 * * *" helper="Cron expression for auto update frequency (automatically update coolify).<br>You can use every_minute, hourly, daily, weekly, monthly, yearly.<br><br>Default is every day at 00:00" />
@endif
</div> </div>
@if (is_null(env('AUTOUPDATE', null)) && $is_auto_update_enabled) <h4 class="pt-6">Advanced</h4>
<x-forms.input required id="auto_update_frequency" label="Auto Update Frequency" placeholder="0 0 * * *" <div class="text-right md:w-96">
helper="Cron expression for auto update frequency (automatically update coolify).<br>You can use every_minute, hourly, daily, weekly, monthly, yearly.<br><br>Default is every day at 00:00" /> <x-forms.checkbox instantSave id="is_registration_enabled" label="Registration Allowed" />
@endif <x-forms.checkbox instantSave id="do_not_track" label="Do Not Track" />
</div> </div>
</form>
<h5 class="pt-4 font-bold text-white">Confirmation Settings</h5>
<div x-data="{ open: false }" class="md:w-96">
<button type="button" @click="open = !open" class="flex items-center justify-between w-full py-2 text-left">
<span>Confirmation Options</span>
<svg :class="{'rotate-180': open}" class="w-5 h-5 transition-transform duration-200" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
</svg>
</button>
<div x-show="open" x-transition:enter="transition ease-out duration-100" x-transition:enter-start="transform opacity-0 scale-95" x-transition:enter-end="transform opacity-100 scale-100" x-transition:leave="transition ease-in duration-75" x-transition:leave-start="transform opacity-100 scale-100" x-transition:leave-end="transform opacity-0 scale-95" class="mt-2">
<div class="mb-4 p-4 bg-yellow-100 border-l-4 border-yellow-500 text-yellow-700">
<p class="font-bold">Warning!</p>
<p>Disabling two-step confirmation reduces security (as anyone can easily delete anything) and increases the risk of accidental actions. This is not recommended for production servers.</p>
</div>
<x-forms.checkbox instantSave id="disable_two_step_confirmation" label="Disable Two Step Confirmation" helper="When disabled, you will not need to confirm actions with a text and user password. This significantly reduces security and may lead to accidental deletions or unwanted changes. Use with extreme caution, especially on production servers." />
</div>
</div>
</form>
</div> </div>