Skip to content

Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.

feat(auth): add GitHub OAuth integration with settings management

Timothy Yind8c723deaa0d
diff --git a/app/pages/dashboard/settings/system.vue b/app/pages/dashboard/settings/system.vue
index f550bf95..ee4ea02d 100644
--- a/app/pages/dashboard/settings/system.vue
+++ b/app/pages/dashboard/settings/system.vue
@@ -1,4 +1,6 @@
<script lang="ts" setup>
+import type { FieldDescriptor } from '~~/shared/types/settings'
+
definePageMeta({
layout: 'dashboard',
})
@@ -18,27 +20,80 @@ const systemFields = computed(() =>
rawSystemFields.value.filter((field) => !field.isReadonly),
)
+type SystemSection = {
+ id: string
+ titleKey: string
+ keys: string[]
+}
+
+type SystemSectionWithFields = SystemSection & {
+ fields: FieldDescriptor[]
+}
+
+const SYSTEM_SECTION_ORDER: SystemSection[] = [
+ {
+ id: 'thirdPartyLogin',
+ titleKey: 'settings.system.sections.thirdPartyLogin',
+ keys: [
+ 'auth.github.enabled',
+ 'auth.github.clientId',
+ 'auth.github.clientSecret',
+ ],
+ },
+ {
+ id: 'fileProcessing',
+ titleKey: 'settings.system.sections.fileProcessing',
+ keys: [
+ 'upload.maxFileSize',
+ 'upload.duplicateCheck.enabled',
+ 'upload.duplicateCheck.mode',
+ ],
+ },
+ {
+ id: 'debug',
+ titleKey: 'settings.system.sections.debugSettings',
+ keys: ['webglImageViewerDebug'],
+ },
+] as const
+
+const isFieldDescriptor = (
+ field: FieldDescriptor | undefined,
+): field is FieldDescriptor => Boolean(field)
+
+const systemFieldSections = computed<SystemSectionWithFields[]>(() =>
+ SYSTEM_SECTION_ORDER.map((section) => ({
+ ...section,
+ fields: section.keys
+ .map((key) => systemFields.value.find((field) => field.key === key))
+ .filter(isFieldDescriptor),
+ })).filter((section) => section.fields.length > 0),
+)
+
const sameValue = (left: any, right: any) =>
JSON.stringify(left ?? null) === JSON.stringify(right ?? null)
const getDefaultFieldValue = (field: (typeof rawSystemFields.value)[number]) =>
field.value ?? field.defaultValue ?? null
-const isSystemDirty = computed(() =>
- systemFields.value.some(
+const getSectionFormId = (sectionId: string) =>
+ `systemSettingsForm-${sectionId}`
+
+const isSectionDirty = (section: SystemSectionWithFields) =>
+ section.fields.some(
(field) => !sameValue(systemState[field.key], getDefaultFieldValue(field)),
- ),
-)
+ )
-const resetSystemSettings = () => {
- systemFields.value.forEach((field) => {
+const resetSectionSettings = (section: SystemSectionWithFields) => {
+ section.fields.forEach((field) => {
systemState[field.key] = getDefaultFieldValue(field)
})
}
-const handleSystemSettingsSubmit = async () => {
+const handleSectionSettingsSubmit = async (
+ section: SystemSectionWithFields,
+) => {
const systemData = Object.fromEntries(
- systemFields.value.map((f) => [f.key, systemState[f.key]]),
+ section.fields.map((f) => [f.key, systemState[f.key]]),
)
try {
@@ -70,7 +125,27 @@ const handleSystemSettingsSubmit = async () => {
</p>
</section>
+ <template v-if="systemLoading && systemFieldSections.length === 0">
+ <section
+ v-for="index in 3"
+ :key="index"
+ class="rounded-md border border-neutral-200 bg-white dark:border-neutral-800 dark:bg-neutral-950"
+ >
+ <header
+ class="border-b border-neutral-200 px-5 py-4 dark:border-neutral-800"
+ >
+ <USkeleton class="h-5 w-32" />
+ </header>
+ <div class="space-y-4 px-5 py-5">
+ <USkeleton class="h-4 w-40" />
+ <USkeleton class="h-10 w-full" />
+ </div>
+ </section>
+ </template>
+
<section
+ v-for="section in systemFieldSections"
+ :key="section.id"
class="rounded-md border border-neutral-200 bg-white dark:border-neutral-800 dark:bg-neutral-950"
>
<header
@@ -79,26 +154,17 @@ const handleSystemSettingsSubmit = async () => {
<h3
class="text-base font-semibold text-neutral-900 dark:text-neutral-100"
>
- {{ $t('title.systemSettings') }}
+ {{ $t(section.titleKey) }}
</h3>
</header>
- <div
- v-if="systemLoading && systemFields.length === 0"
- class="space-y-4 px-5 py-5"
- >
- <USkeleton class="h-4 w-40" />
- <USkeleton class="h-10 w-full" />
- </div>
-
<UForm
- v-else
- id="systemSettingsForm"
+ :id="getSectionFormId(section.id)"
class="space-y-5 px-5 py-5"
- @submit="handleSystemSettingsSubmit"
+ @submit="handleSectionSettingsSubmit(section)"
>
<SettingField
- v-for="field in systemFields"
+ v-for="field in section.fields"
:key="field.key"
:field="field"
:model-value="systemState[field.key]"
@@ -110,7 +176,7 @@ const handleSystemSettingsSubmit = async () => {
class="border-t border-neutral-200 px-5 py-4 dark:border-neutral-800"
>
<div
- v-if="isSystemDirty"
+ v-if="isSectionDirty(section)"
class="mb-3 rounded-md border border-warning-200 bg-warning-50 px-3 py-2 text-sm text-warning-800 dark:border-warning-900/60 dark:bg-warning-950/30 dark:text-warning-200"
>
{{ $t('common.unsavedChanges') }}
@@ -120,16 +186,16 @@ const handleSystemSettingsSubmit = async () => {
<UButton
color="neutral"
variant="outline"
- :disabled="!isSystemDirty"
- @click="resetSystemSettings"
+ :disabled="!isSectionDirty(section)"
+ @click="resetSectionSettings(section)"
>
重置
</UButton>
<UButton
:loading="systemLoading"
type="submit"
- form="systemSettingsForm"
- :disabled="!isSystemDirty"
+ :form="getSectionFormId(section.id)"
+ :disabled="!isSectionDirty(section)"
icon="tabler:device-floppy"
>
保存设置
diff --git a/app/pages/signin.vue b/app/pages/signin.vue
index 61657b24..f6e41389 100644
--- a/app/pages/signin.vue
+++ b/app/pages/signin.vue
@@ -5,12 +5,22 @@ useHead({
const { fetch: fetchUserSession } = useUserSession()
const config = useRuntimeConfig()
+const settingsStore = useSettingsStore()
const toast = useToast()
const route = useRoute()
const router = useRouter()
const isLoading = ref(false)
+const githubOauthEnabled = computed(() => {
+ const settingsValue = settingsStore.getSetting('system:auth.github.enabled')
+ if (typeof settingsValue === 'boolean') {
+ return settingsValue
+ }
+
+ return Boolean(config.public.oauth.github.enabled)
+})
+
const onAuthSubmit = async (event: any) => {
isLoading.value = true
await $fetch('/api/login', {
@@ -46,7 +56,7 @@ const onAuthSubmit = async (event: any) => {
:subtitle="$t('auth.form.signin.subtitle', [config.public.app.title])"
:loading="isLoading"
:providers="[
- config.public.oauth.github.enabled && {
+ githubOauthEnabled && {
icon: 'tabler:brand-github',
size: 'lg',
color: 'neutral',
diff --git a/i18n/locales/en.json b/i18n/locales/en.json
index b2be6267..5b2cd662 100644
--- a/i18n/locales/en.json
+++ b/i18n/locales/en.json
@@ -934,6 +934,11 @@
}
},
"system": {
+ "sections": {
+ "thirdPartyLogin": "Third-Party Login",
+ "fileProcessing": "File Processing",
+ "debugSettings": "Debug Settings"
+ },
"upload": {
"duplicateCheck": {
"enabled": {
@@ -957,6 +962,22 @@
"label": "WebGL Image Viewer debug mode",
"description": "Control whether the WebGL image viewer shows debug info in production",
"help": "When enabled, logged-in users can view the WebGL debug panel in any environment; when disabled, debug info is shown only in development"
+ },
+ "auth": {
+ "github": {
+ "enabled": {
+ "label": "Enable GitHub login",
+ "description": "Whether to enable GitHub OAuth login"
+ },
+ "clientId": {
+ "label": "GitHub Client ID",
+ "description": "Client ID of your GitHub OAuth app"
+ },
+ "clientSecret": {
+ "label": "GitHub Client Secret",
+ "description": "Client Secret of your GitHub OAuth app"
+ }
+ }
}
},
"map": {
diff --git a/i18n/locales/ja.json b/i18n/locales/ja.json
index c09707e8..7e2a88b6 100644
--- a/i18n/locales/ja.json
+++ b/i18n/locales/ja.json
@@ -869,6 +869,11 @@
}
},
"system": {
+ "sections": {
+ "thirdPartyLogin": "外部ログイン",
+ "fileProcessing": "ファイル処理",
+ "debugSettings": "デバッグ設定"
+ },
"upload": {
"duplicateCheck": {
"enabled": {
@@ -892,6 +897,22 @@
"label": "WebGL Image Viewer デバッグモード",
"description": "WebGL 画像ビューアのデバッグ情報を本番環境でも表示するかを制御します",
"help": "有効にすると、ログイン中のユーザーは環境を問わず WebGL デバッグパネルを表示できます。無効時は開発環境のみ表示されます"
+ },
+ "auth": {
+ "github": {
+ "enabled": {
+ "label": "GitHub ログインを有効化",
+ "description": "GitHub OAuth ログインを有効にするかどうか"
+ },
+ "clientId": {
+ "label": "GitHub Client ID",
+ "description": "GitHub OAuth アプリの Client ID"
+ },
+ "clientSecret": {
+ "label": "GitHub Client Secret",
+ "description": "GitHub OAuth アプリの Client Secret"
+ }
+ }
}
},
"map": {
diff --git a/i18n/locales/zh-Hans.json b/i18n/locales/zh-Hans.json
index 6d447bf7..7280a52d 100644
--- a/i18n/locales/zh-Hans.json
+++ b/i18n/locales/zh-Hans.json
@@ -938,6 +938,11 @@
}
},
"system": {
+ "sections": {
+ "thirdPartyLogin": "第三方登录",
+ "fileProcessing": "文件处理",
+ "debugSettings": "调试设置"
+ },
"upload": {
"duplicateCheck": {
"enabled": {
@@ -961,6 +966,22 @@
"label": "WebGL Image Viewer 调试模式",
"description": "控制 WebGL 图片查看器是否在生产环境也显示调试信息",
"help": "开启后,登录用户在任意环境都可看到 WebGL 调试面板;关闭后仅开发环境生效"
+ },
+ "auth": {
+ "github": {
+ "enabled": {
+ "label": "启用 GitHub 登录",
+ "description": "是否启用 GitHub OAuth 登录"
+ },
+ "clientId": {
+ "label": "GitHub Client ID",
+ "description": "GitHub OAuth 应用的 Client ID"
+ },
+ "clientSecret": {
+ "label": "GitHub Client Secret",
+ "description": "GitHub OAuth 应用的 Client Secret"
+ }
+ }
}
},
"map": {
diff --git a/i18n/locales/zh-Hant-HK.json b/i18n/locales/zh-Hant-HK.json
index bf2546b2..eff2340c 100644
--- a/i18n/locales/zh-Hant-HK.json
+++ b/i18n/locales/zh-Hant-HK.json
@@ -869,6 +869,11 @@
}
},
"system": {
+ "sections": {
+ "thirdPartyLogin": "第三方登入",
+ "fileProcessing": "檔案處理",
+ "debugSettings": "除錯設定"
+ },
"upload": {
"duplicateCheck": {
"enabled": {
@@ -892,6 +897,22 @@
"label": "WebGL Image Viewer 偵錯模式",
"description": "控制 WebGL 圖片檢視器是否喺生產環境都顯示偵錯資訊",
"help": "啟用後,已登入用戶喺任何環境都可以睇到 WebGL 偵錯面板;關閉後只會喺開發環境生效"
+ },
+ "auth": {
+ "github": {
+ "enabled": {
+ "label": "啟用 GitHub 登入",
+ "description": "是否啟用 GitHub OAuth 登入"
+ },
+ "clientId": {
+ "label": "GitHub Client ID",
+ "description": "GitHub OAuth 應用嘅 Client ID"
+ },
+ "clientSecret": {
+ "label": "GitHub Client Secret",
+ "description": "GitHub OAuth 應用嘅 Client Secret"
+ }
+ }
}
},
"map": {
diff --git a/i18n/locales/zh-Hant-TW.json b/i18n/locales/zh-Hant-TW.json
index 185b2e7c..e883d0ec 100644
--- a/i18n/locales/zh-Hant-TW.json
+++ b/i18n/locales/zh-Hant-TW.json
@@ -869,6 +869,11 @@
}
},
"system": {
+ "sections": {
+ "thirdPartyLogin": "第三方登入",
+ "fileProcessing": "檔案處理",
+ "debugSettings": "除錯設定"
+ },
"upload": {
"duplicateCheck": {
"enabled": {
@@ -892,6 +897,22 @@
"label": "WebGL Image Viewer 偵錯模式",
"description": "控制 WebGL 圖片檢視器是否在正式環境也顯示偵錯資訊",
"help": "啟用後,已登入使用者在任何環境都可看到 WebGL 偵錯面板;關閉後僅在開發環境生效"
+ },
+ "auth": {
+ "github": {
+ "enabled": {
+ "label": "啟用 GitHub 登入",
+ "description": "是否啟用 GitHub OAuth 登入"
+ },
+ "clientId": {
+ "label": "GitHub Client ID",
+ "description": "GitHub OAuth 應用的 Client ID"
+ },
+ "clientSecret": {
+ "label": "GitHub Client Secret",
+ "description": "GitHub OAuth 應用的 Client Secret"
+ }
+ }
}
},
"map": {
diff --git a/server/api/auth/github.get.ts b/server/api/auth/github.get.ts
index c6e6bf7e..f3b95c1b 100644
--- a/server/api/auth/github.get.ts
+++ b/server/api/auth/github.get.ts
@@ -1,58 +1,117 @@
+import { settingsManager } from '~~/server/services/settings/settingsManager'
+
const _accessDeniedError = createError({
statusCode: 403,
statusMessage:
'Access denied. Please contact the administrator to activate your account.',
})
-export default defineOAuthGitHubEventHandler({
- async onSuccess(event, { user }) {
- const db = useDB()
- const userFromEmail = db
- .select()
- .from(tables.users)
- .where(eq(tables.users.email, user.email || ''))
- .get()
+async function onGithubOAuthSuccess(event: any, { user }: { user: any }) {
+ const db = useDB()
+ const userFromEmail = db
+ .select()
+ .from(tables.users)
+ .where(eq(tables.users.email, user.email || ''))
+ .get()
- logger.chrono.info(
- 'GitHub OAuth login:',
- user.email,
- userFromEmail ? 'Existing user' : 'New user',
- )
+ logger.chrono.info(
+ 'GitHub OAuth login:',
+ user.email,
+ userFromEmail ? 'Existing user' : 'New user',
+ )
- if (!userFromEmail) {
- // create a new user without admin permission
- db.insert(tables.users)
- .values({
- username: user.name || '',
- email: user.email || '',
- avatar: user.avatar_url || null,
- createdAt: new Date(),
- })
- .returning()
- .get()
- // then reject login
- throw _accessDeniedError
- } else if (userFromEmail.isAdmin === 0) {
- throw _accessDeniedError
- } else {
- await setUserSession(
- event,
- { user: userFromEmail },
- {
- cookie: {
- // secure: !useRuntimeConfig().allowInsecureCookie,
- secure: false,
- },
+ if (!userFromEmail) {
+ // create a new user without admin permission
+ db.insert(tables.users)
+ .values({
+ username: user.name || '',
+ email: user.email || '',
+ avatar: user.avatar_url || null,
+ createdAt: new Date(),
+ })
+ .returning()
+ .get()
+ // then reject login
+ throw _accessDeniedError
+ } else if (userFromEmail.isAdmin === 0) {
+ throw _accessDeniedError
+ } else {
+ await setUserSession(
+ event,
+ { user: userFromEmail },
+ {
+ cookie: {
+ // secure: !useRuntimeConfig().allowInsecureCookie,
+ secure: false,
},
- )
- }
- return sendRedirect(event, '/')
- },
- onError(event, error) {
- logger.chrono.warn('GitHub OAuth login failed', error)
+ },
+ )
+ }
+ return sendRedirect(event, '/')
+}
+
+function onGithubOAuthError(_event: any, error: any) {
+ logger.chrono.warn('GitHub OAuth login failed', error)
+ throw createError({
+ statusCode: 401,
+ statusMessage: `Authentication failed: ${error.message || 'Unknown error'}`,
+ })
+}
+
+export default eventHandler(async (event) => {
+ const runtimeConfig = useRuntimeConfig(event) as any
+
+ const enabled = await settingsManager.get<boolean>(
+ 'system',
+ 'auth.github.enabled' as any,
+ Boolean(runtimeConfig.public?.oauth?.github?.enabled),
+ )
+ const clientIdFromSettings = await settingsManager.get<string>(
+ 'system',
+ 'auth.github.clientId' as any,
+ '',
+ )
+ const clientSecretFromSettings = await settingsManager.get<string>(
+ 'system',
+ 'auth.github.clientSecret' as any,
+ '',
+ )
+
+ const clientId =
+ clientIdFromSettings ||
+ runtimeConfig.oauth?.github?.clientId ||
+ process.env.NUXT_OAUTH_GITHUB_CLIENT_ID ||
+ ''
+ const clientSecret =
+ clientSecretFromSettings ||
+ runtimeConfig.oauth?.github?.clientSecret ||
+ process.env.NUXT_OAUTH_GITHUB_CLIENT_SECRET ||
+ ''
+
+ if (!enabled) {
throw createError({
- statusCode: 401,
- statusMessage: `Authentication failed: ${error.message || 'Unknown error'}`,
+ statusCode: 403,
+ statusMessage: 'GitHub OAuth login is disabled.',
})
- },
+ }
+
+ if (!clientId || !clientSecret) {
+ throw createError({
+ statusCode: 500,
+ statusMessage:
+ 'GitHub OAuth is enabled but credentials are missing in system settings.',
+ })
+ }
+
+ const handler = defineOAuthGitHubEventHandler({
+ config: {
+ clientId,
+ clientSecret,
+ emailRequired: true,
+ },
+ onSuccess: onGithubOAuthSuccess,
+ onError: onGithubOAuthError,
+ })
+
+ return handler(event)
})
diff --git a/server/plugins/0.session-password.ts b/server/plugins/0.session-password.ts
new file mode 100644
index 00000000..27a1f9d8
--- /dev/null
+++ b/server/plugins/0.session-password.ts
@@ -0,0 +1,54 @@
+import { randomBytes } from 'node:crypto'
+import { mkdir, readFile, writeFile } from 'node:fs/promises'
+import { dirname, resolve } from 'node:path'
+
+const SESSION_PASSWORD_ENV_KEY = 'NUXT_SESSION_PASSWORD'
+const SESSION_PASSWORD_FILE = resolve(process.cwd(), 'data/.session-password')
+const MIN_PASSWORD_LENGTH = 32
+
+function isValidSessionPassword(
+ password: string | undefined,
+): password is string {
+ return Boolean(password && password.length >= MIN_PASSWORD_LENGTH)
+}
+
+function generateSessionPassword(): string {
+ return randomBytes(48).toString('base64url')
+}
+
+export default defineNitroPlugin(async () => {
+ if (isValidSessionPassword(process.env[SESSION_PASSWORD_ENV_KEY])) {
+ return
+ }
+
+ const pluginLogger = logger.dynamic('session-password')
+
+ try {
+ await mkdir(dirname(SESSION_PASSWORD_FILE), { recursive: true })
+
+ const filePassword = (await readFile(SESSION_PASSWORD_FILE, 'utf8')).trim()
+ if (isValidSessionPassword(filePassword)) {
+ process.env[SESSION_PASSWORD_ENV_KEY] = filePassword
+ pluginLogger.info(
+ `Loaded session password from ${SESSION_PASSWORD_FILE.replace(process.cwd(), '.')}`,
+ )
+ return
+ }
+
+ pluginLogger.warn(
+ 'Session password file exists but is invalid, generating a new password.',
+ )
+ } catch {
+ // The password file does not exist yet, generate a new one below.
+ }
+
+ const generatedPassword = generateSessionPassword()
+ await writeFile(SESSION_PASSWORD_FILE, generatedPassword, {
+ encoding: 'utf8',
+ mode: 0o600,
+ })
+ process.env[SESSION_PASSWORD_ENV_KEY] = generatedPassword
+ pluginLogger.info(
+ `Generated and persisted a session password to ${SESSION_PASSWORD_FILE.replace(process.cwd(), '.')}`,
+ )
+})
diff --git a/server/plugins/2.settings-manager.ts b/server/plugins/2.settings-manager.ts
index cf2234e5..4b94a2c9 100644
--- a/server/plugins/2.settings-manager.ts
+++ b/server/plugins/2.settings-manager.ts
@@ -19,6 +19,9 @@ export default defineNitroPlugin(async (_nitroApp) => {
// Migrate existing configurations from runtimeConfig
// Note: Storage manager will be initialized in the next plugin (2_storage.ts)
await migrateRuntimeConfigToSettings()
+
+ // Sync GitHub OAuth credentials from settings to process.env for auth-utils.
+ await syncGithubOAuthEnvFromSettings()
} finally {
_settingsManager.setInitializingFlag(false)
}
@@ -28,7 +31,7 @@ export default defineNitroPlugin(async (_nitroApp) => {
* Migrate existing configurations from runtimeConfig to the settings system
*/
async function migrateRuntimeConfigToSettings() {
- const config = useRuntimeConfig()
+ const config = useRuntimeConfig() as any
const _logger = logger.dynamic('settings-migration')
try {
@@ -77,6 +80,39 @@ async function migrateRuntimeConfigToSettings() {
}
}
+ // Migrate auth settings (GitHub OAuth)
+ const githubOauthConfig = config.oauth?.github || {}
+ if (config.public?.oauth?.github?.enabled === true) {
+ try {
+ await settingsManager.set(
+ 'system',
+ 'auth.github.enabled' as any,
+ true,
+ undefined,
+ true,
+ )
+ _logger.debug('Migrated system.auth.github.enabled=true')
+ } catch (error) {
+ _logger.warn('Failed to migrate system.auth.github.enabled:', error)
+ }
+ }
+
+ const githubOauthSettings = {
+ 'auth.github.clientId': githubOauthConfig.clientId || '',
+ 'auth.github.clientSecret': githubOauthConfig.clientSecret || '',
+ }
+
+ for (const [key, value] of Object.entries(githubOauthSettings)) {
+ if (typeof value === 'string' && value.length > 0) {
+ try {
+ await settingsManager.set('system', key as any, value, undefined, true)
+ _logger.debug(`Migrated system.${key}`)
+ } catch (error) {
+ _logger.warn(`Failed to migrate system.${key}:`, error)
+ }
+ }
+ }
+
// Migrate storage configuration and set as active provider
if (config.STORAGE_PROVIDER || config.provider) {
_logger.info('Migrating storage configuration')
@@ -142,6 +178,36 @@ async function migrateRuntimeConfigToSettings() {
}
}
+async function syncGithubOAuthEnvFromSettings() {
+ const config = useRuntimeConfig() as any
+
+ const enabled = await settingsManager.get<boolean>(
+ 'system',
+ 'auth.github.enabled' as any,
+ Boolean(config.public?.oauth?.github?.enabled),
+ )
+ const clientId = await settingsManager.get<string>(
+ 'system',
+ 'auth.github.clientId' as any,
+ config.oauth?.github?.clientId || '',
+ )
+ const clientSecret = await settingsManager.get<string>(
+ 'system',
+ 'auth.github.clientSecret' as any,
+ config.oauth?.github?.clientSecret || '',
+ )
+
+ const canEnableGithubOauth = Boolean(enabled && clientId && clientSecret)
+
+ if (canEnableGithubOauth) {
+ process.env.NUXT_OAUTH_GITHUB_CLIENT_ID = clientId || ''
+ process.env.NUXT_OAUTH_GITHUB_CLIENT_SECRET = clientSecret || ''
+ } else {
+ delete process.env.NUXT_OAUTH_GITHUB_CLIENT_ID
+ delete process.env.NUXT_OAUTH_GITHUB_CLIENT_SECRET
+ }
+}
+
async function removeDeprecatedSettings() {
const db = useDB()
diff --git a/server/services/settings/contants.ts b/server/services/settings/contants.ts
index 3f327eaf..d5a90f7d 100644
--- a/server/services/settings/contants.ts
+++ b/server/services/settings/contants.ts
@@ -100,6 +100,32 @@ export const DEFAULT_SETTINGS = [
description: 'settings.system.webglImageViewerDebug.description',
isPublic: true,
},
+ {
+ namespace: 'system',
+ key: 'auth.github.enabled',
+ type: 'boolean',
+ defaultValue: false,
+ label: 'settings.system.auth.github.enabled.label',
+ description: 'settings.system.auth.github.enabled.description',
+ isPublic: true,
+ },
+ {
+ namespace: 'system',
+ key: 'auth.github.clientId',
+ type: 'string',
+ defaultValue: '',
+ label: 'settings.system.auth.github.clientId.label',
+ description: 'settings.system.auth.github.clientId.description',
+ },
+ {
+ namespace: 'system',
+ key: 'auth.github.clientSecret',
+ type: 'string',
+ defaultValue: '',
+ label: 'settings.system.auth.github.clientSecret.label',
+ description: 'settings.system.auth.github.clientSecret.description',
+ isSecret: true,
+ },
// NAMESPACE: privacy
{
namespace: 'privacy',
diff --git a/server/services/settings/ui-config.ts b/server/services/settings/ui-config.ts
index d7d6b94f..d3372a46 100644
--- a/server/services/settings/ui-config.ts
+++ b/server/services/settings/ui-config.ts
@@ -142,6 +142,19 @@ export const SYSTEM_SETTINGS_UI: Record<string, FieldUIConfig> = {
type: 'toggle',
help: 'settings.system.webglImageViewerDebug.help',
},
+ 'auth.github.enabled': {
+ type: 'toggle',
+ },
+ 'auth.github.clientId': {
+ type: 'input',
+ placeholder: 'Ov23li...',
+ visibleIf: { fieldKey: 'auth.github.enabled', value: true },
+ },
+ 'auth.github.clientSecret': {
+ type: 'password',
+ placeholder: 'github_oauth_client_secret',
+ visibleIf: { fieldKey: 'auth.github.enabled', value: true },
+ },
}
export const STORAGE_SETTINGS_UI: Record<string, FieldUIConfig> = {