fix(oauth): fix login failures and add provider icon_url config

- Fix FIND_OAUTH_LINKED_USER_SQL missing allowed_providers_mode columns
- Fix TOUCH_OAUTH_LINK_SQL json/jsonb type mismatch in COALESCE
- Add icon_url field to OAuth provider config (DB, API, frontend)
- Fix admin OAuth test: accept 404 as reachable, use system proxy
This commit is contained in:
dalamudx
2026-05-17 21:22:20 +08:00
parent 3a23eaa572
commit 48deff15c4
18 changed files with 91 additions and 16 deletions

View File

@@ -3,6 +3,7 @@ import apiClient from './client'
export interface OAuthProviderInfo {
provider_type: string
display_name: string
icon_url?: string | null
}
export interface OAuthProvidersResponse {
@@ -46,6 +47,7 @@ export interface OAuthProviderAdminConfig {
frontend_callback_url: string
attribute_mapping?: Record<string, unknown> | null
extra_config?: Record<string, unknown> | null
icon_url?: string | null
is_enabled: boolean
}
@@ -61,6 +63,7 @@ export interface OAuthProviderUpsertRequest {
frontend_callback_url: string
attribute_mapping?: Record<string, unknown> | null
extra_config?: Record<string, unknown> | null
icon_url?: string | null
is_enabled: boolean
force?: boolean
}

View File

@@ -63,7 +63,7 @@
<!-- eslint-disable vue/no-v-html -->
<span
class="oauth-icon"
v-html="getOAuthIcon(oauthProviders[0].provider_type)"
v-html="getOAuthIcon(oauthProviders[0].provider_type, oauthProviders[0].icon_url)"
/>
<!-- eslint-enable vue/no-v-html -->
<span>使用 {{ oauthProviders[0].display_name }} 登录</span>
@@ -88,7 +88,7 @@
<!-- eslint-disable vue/no-v-html -->
<span
class="oauth-icon-lg"
v-html="getOAuthIcon(p.provider_type)"
v-html="getOAuthIcon(p.provider_type, p.icon_url)"
/>
<!-- eslint-enable vue/no-v-html -->
</button>

View File

@@ -9,6 +9,9 @@ export const OAUTH_ICONS: Record<string, string> = {
// Default icon when provider type is not found
const DEFAULT_ICON = OAUTH_ICONS.github
export function getOAuthIcon(providerType: string): string {
return OAUTH_ICONS[providerType.toLowerCase()] || DEFAULT_ICON
export function getOAuthIcon(providerType: string, iconUrl?: string | null): string {
const builtin = OAUTH_ICONS[providerType.toLowerCase()]
if (builtin) return builtin
if (iconUrl) return `<img src="${iconUrl}" alt="" style="width:100%;height:100%;object-fit:contain;" />`
return DEFAULT_ICON
}

View File

@@ -228,6 +228,20 @@
</div>
</div>
<!-- 图标 URL -->
<div>
<Label class="block text-sm font-medium">图标 URL</Label>
<Input
v-model="form.icon_url"
class="mt-1"
placeholder="https://example.com/icon.svg"
autocomplete="off"
/>
<p class="mt-1 text-xs text-muted-foreground">
登录页显示的 Provider 图标留空使用默认图标
</p>
</div>
<!-- 高级选项折叠 -->
<details class="group">
<summary class="cursor-pointer text-sm font-medium text-muted-foreground hover:text-foreground transition-colors">
@@ -308,6 +322,7 @@
自定义 OIDC 必填填写 Authorization / Token / Userinfo URL 所属域名
</p>
</div>
</div>
</div>
</details>
@@ -394,6 +409,7 @@ interface OAuthConfigForm {
frontend_callback_url: string
attribute_mapping_json: string
extra_config_json: string
icon_url: string
new_provider_type: string
new_display_name: string
}
@@ -415,6 +431,7 @@ const form = ref<OAuthConfigForm>({
frontend_callback_url: '',
attribute_mapping_json: '',
extra_config_json: '',
icon_url: '',
new_provider_type: '',
new_display_name: '',
})
@@ -581,6 +598,7 @@ function handleClickAdd() {
frontend_callback_url: defaultFrontendCallbackUrl(),
attribute_mapping_json: '',
extra_config_json: '',
icon_url: '',
new_provider_type: providerType,
new_display_name: '',
}
@@ -625,6 +643,7 @@ function syncFormFromSelected() {
frontend_callback_url: cfg?.frontend_callback_url || defaultFrontendCallbackUrl(),
attribute_mapping_json: cfg?.attribute_mapping ? JSON.stringify(cfg.attribute_mapping, null, 2) : '',
extra_config_json: cfg?.extra_config ? JSON.stringify(cfg.extra_config, null, 2) : '',
icon_url: cfg?.icon_url || '',
new_provider_type: '',
new_display_name: '',
}
@@ -650,6 +669,7 @@ async function toggleProviderEnabled(providerType: string, enabled: boolean, for
frontend_callback_url: cfg.frontend_callback_url,
attribute_mapping: cfg.attribute_mapping || null,
extra_config: cfg.extra_config || null,
icon_url: cfg.icon_url || null,
is_enabled: enabled,
force,
}
@@ -724,6 +744,7 @@ async function handleSave() {
frontend_callback_url: form.value.frontend_callback_url.trim(),
attribute_mapping: parseJsonOrNull(form.value.attribute_mapping_json),
extra_config: parseJsonOrNull(form.value.extra_config_json),
icon_url: form.value.icon_url.trim() || null,
is_enabled: existingConfig?.is_enabled || false,
}

View File

@@ -387,7 +387,7 @@
<!-- eslint-disable vue/no-v-html -->
<div
class="oauth-icon shrink-0"
v-html="getOAuthIcon(p.provider_type)"
v-html="getOAuthIcon(p.provider_type, p.icon_url)"
/>
<!-- eslint-enable vue/no-v-html -->
<div class="min-w-0">