fix(identity): 统一认证启用时直接跳转登录

双上下文配置不再落入工作台本地登录页,首次点击统一入口直接发起未预选上下文的 OIDC BFF 登录。

验证:OIDC 定向 Vitest 8 项通过;Web TypeScript 检查与生产构建通过。
This commit is contained in:
2026-07-31 17:33:02 +08:00
parent 59f0817938
commit 93d36d0e55
3 changed files with 18 additions and 9 deletions
+1 -4
View File
@@ -1321,10 +1321,7 @@ export function App() {
const configuration = await loadOIDCRuntimeConfiguration(true); const configuration = await loadOIDCRuntimeConfiguration(true);
const identityEnabled = configuration.enabled && configuration.oidcLogin; const identityEnabled = configuration.enabled && configuration.oidcLogin;
setOIDCEnabled(identityEnabled); setOIDCEnabled(identityEnabled);
if ( if (loginEntryAction(configuration) === 'oidc') {
loginEntryAction(identityEnabled) === 'oidc' &&
configuration.contextTypes.length === 1
) {
setOIDCCallbackError(null); setOIDCCallbackError(null);
await startOIDCLogin(undefined, configuration); await startOIDCLogin(undefined, configuration);
return; return;
+13 -3
View File
@@ -127,15 +127,25 @@ describe('OIDC BFF navigation', () => {
}); });
describe('login entry routing', () => { 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'); 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 () => { it('keeps the existing workspace login when OIDC login is disabled', async () => {
const { loginEntryAction } = await import('./oidc'); const { loginEntryAction } = await import('./oidc');
expect(loginEntryAction(false)).toBe('workspace'); expect(loginEntryAction({
enabled: false,
oidcLogin: false,
contextTypes: [],
status: 'disabled',
})).toBe('workspace');
}); });
}); });
+4 -2
View File
@@ -53,8 +53,10 @@ export function oidcBrowserSessionEnabled() {
return oidcLoginEnabled(); return oidcLoginEnabled();
} }
export function loginEntryAction(oidcEnabled: boolean): 'oidc' | 'workspace' { export function loginEntryAction(
return oidcEnabled ? 'oidc' : 'workspace'; configuration: OIDCRuntimeConfiguration,
): 'oidc' | 'workspace' {
return configuration.enabled && configuration.oidcLogin ? 'oidc' : 'workspace';
} }
export async function loadOIDCRuntimeConfiguration(force = false): Promise<OIDCRuntimeConfiguration> { export async function loadOIDCRuntimeConfiguration(force = false): Promise<OIDCRuntimeConfiguration> {