From 93d36d0e55870f1dfaa5d314ff7adba2603ac181 Mon Sep 17 00:00:00 2001 From: chengcheng Date: Fri, 31 Jul 2026 17:33:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(identity):=20=E7=BB=9F=E4=B8=80=E8=AE=A4?= =?UTF-8?q?=E8=AF=81=E5=90=AF=E7=94=A8=E6=97=B6=E7=9B=B4=E6=8E=A5=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 双上下文配置不再落入工作台本地登录页,首次点击统一入口直接发起未预选上下文的 OIDC BFF 登录。 验证:OIDC 定向 Vitest 8 项通过;Web TypeScript 检查与生产构建通过。 --- apps/web/src/App.tsx | 5 +---- apps/web/src/lib/oidc.test.ts | 16 +++++++++++++--- apps/web/src/lib/oidc.ts | 6 ++++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx index 9c45e83..1989903 100644 --- a/apps/web/src/App.tsx +++ b/apps/web/src/App.tsx @@ -1321,10 +1321,7 @@ export function App() { const configuration = await loadOIDCRuntimeConfiguration(true); const identityEnabled = configuration.enabled && configuration.oidcLogin; setOIDCEnabled(identityEnabled); - if ( - loginEntryAction(identityEnabled) === 'oidc' && - configuration.contextTypes.length === 1 - ) { + if (loginEntryAction(configuration) === 'oidc') { setOIDCCallbackError(null); await startOIDCLogin(undefined, configuration); return; diff --git a/apps/web/src/lib/oidc.test.ts b/apps/web/src/lib/oidc.test.ts index 6fbb243..4272716 100644 --- a/apps/web/src/lib/oidc.test.ts +++ b/apps/web/src/lib/oidc.test.ts @@ -127,15 +127,25 @@ describe('OIDC BFF navigation', () => { }); describe('login entry routing', () => { - it('uses the authentication center when OIDC login is enabled', async () => { + it('uses the authentication center directly when both login contexts are available', async () => { const { loginEntryAction } = await import('./oidc'); - expect(loginEntryAction(true)).toBe('oidc'); + expect(loginEntryAction({ + enabled: true, + oidcLogin: true, + contextTypes: ['platform', 'tenant'], + status: 'active', + })).toBe('oidc'); }); it('keeps the existing workspace login when OIDC login is disabled', async () => { const { loginEntryAction } = await import('./oidc'); - expect(loginEntryAction(false)).toBe('workspace'); + expect(loginEntryAction({ + enabled: false, + oidcLogin: false, + contextTypes: [], + status: 'disabled', + })).toBe('workspace'); }); }); diff --git a/apps/web/src/lib/oidc.ts b/apps/web/src/lib/oidc.ts index 4d6704f..d33551d 100644 --- a/apps/web/src/lib/oidc.ts +++ b/apps/web/src/lib/oidc.ts @@ -53,8 +53,10 @@ export function oidcBrowserSessionEnabled() { return oidcLoginEnabled(); } -export function loginEntryAction(oidcEnabled: boolean): 'oidc' | 'workspace' { - return oidcEnabled ? 'oidc' : 'workspace'; +export function loginEntryAction( + configuration: OIDCRuntimeConfiguration, +): 'oidc' | 'workspace' { + return configuration.enabled && configuration.oidcLogin ? 'oidc' : 'workspace'; } export async function loadOIDCRuntimeConfiguration(force = false): Promise {