fix(identity): 统一认证启用时直接跳转登录
双上下文配置不再落入工作台本地登录页,首次点击统一入口直接发起未预选上下文的 OIDC BFF 登录。 验证:OIDC 定向 Vitest 8 项通过;Web TypeScript 检查与生产构建通过。
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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<OIDCRuntimeConfiguration> {
|
||||
|
||||
Reference in New Issue
Block a user