enh: option to disable api auth

This commit is contained in:
Timothy Jaeryang Baek
2024-11-19 12:17:23 -08:00
parent 979e6e5a79
commit 7a585fbaf3
8 changed files with 34 additions and 30 deletions

View File

@@ -112,6 +112,12 @@
</div>
</div>
<div class=" flex w-full justify-between pr-2">
<div class=" self-center text-xs font-medium">{$i18n.t('Enable API Key Auth')}</div>
<Switch bind:state={adminConfig.ENABLE_API_KEY} />
</div>
<hr class=" border-gray-50 dark:border-gray-850 my-2" />
<div class="my-3 flex w-full items-center justify-between pr-2">

View File

@@ -26,9 +26,6 @@
let APIKey = '';
let APIKeyCopied = false;
$: enableApiKeyAuth = $config?.features.enable_api_key_auth ?? true;
let profileImageInputElement: HTMLInputElement;
const submitHandler = async () => {
@@ -303,16 +300,11 @@
</button>
</div>
</div>
<div class="justify-between w-full">
<div class="flex justify-between w-full">
<div class="self-center text-xs font-medium">{$i18n.t('API Key')}</div>
</div>
{#if !enableApiKeyAuth}
<div class="mt-2 p-2 bg-yellow-500/20 text-yellow-700 dark:text-yellow-200 rounded-lg">
{$i18n.t('Private API keys are disabled in this environment')}
{#if $config?.features?.enable_api_key ?? true}
<div class="justify-between w-full">
<div class="flex justify-between w-full">
<div class="self-center text-xs font-medium">{$i18n.t('API Key')}</div>
</div>
{:else}
<div class="flex mt-2">
{#if APIKey}
<SensitiveInput value={APIKey} readOnly={true} />
@@ -397,8 +389,8 @@
>
{/if}
</div>
{/if}
</div>
</div>
{/if}
</div>
{/if}
</div>

View File

@@ -172,7 +172,7 @@ type Config = {
features: {
auth: boolean;
auth_trusted_header: boolean;
enable_api_key_auth: boolean;
enable_api_key: boolean;
enable_signup: boolean;
enable_login_form: boolean;
enable_web_search?: boolean;