Compare commits

..

3 Commits

Author SHA1 Message Date
dcf5c4f340 Merge pull request '修复生产 OIDC 相对登录地址跳转' (#9) from codex/fix-oidc-relative-login-url into main
All checks were successful
ci / verify (push) Successful in 19m32s
release-ci / verify-tag (push) Successful in 15m28s
2026-07-20 15:54:13 +08:00
d956524690 fix(web): 修复相对 OIDC 登录地址跳转
All checks were successful
ci / verify (pull_request) Successful in 22m7s
2026-07-20 15:26:44 +08:00
c070cda22a Merge pull request ci: 限制 Go 门禁并发峰值 (#8)
All checks were successful
ci / verify (push) Successful in 12m47s
release-ci / verify-tag (push) Successful in 14m2s
修复 rootless DinD runner 在 Go 冷编译期间资源峰值过高导致 daemon 掉线的问题。
2026-07-17 21:26:27 +08:00
2 changed files with 27 additions and 1 deletions

View File

@ -26,6 +26,32 @@ describe('OIDC BFF navigation', () => {
expect(target.searchParams.has('code_challenge')).toBe(false);
});
it('resolves the production relative API base against the browser origin', async () => {
vi.stubEnv('VITE_GATEWAY_API_BASE_URL', '/gateway-api');
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({
ok: true,
json: async () => ({
enabled: true,
oidcLogin: true,
loginUrl: '/api/v1/auth/oidc/login',
logoutUrl: '/api/v1/auth/oidc/logout',
status: 'active',
}),
}));
const assign = vi.fn();
vi.stubGlobal('window', {
location: { origin: 'https://ai.51easyai.com', pathname: '/workspace/overview', search: '', hash: '', assign },
});
const { startOIDCLogin } = await import('./oidc');
await startOIDCLogin();
const target = new URL(String(assign.mock.calls[0]?.[0]));
expect(target.origin).toBe('https://ai.51easyai.com');
expect(target.pathname).toBe('/gateway-api/api/v1/auth/oidc/login');
expect(target.searchParams.get('returnTo')).toBe('/workspace/overview');
});
it('submits logout as a top-level POST without exposing tokens', async () => {
vi.stubEnv('VITE_GATEWAY_API_BASE_URL', 'https://gateway.example.com/gateway-api');
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({

View File

@ -77,7 +77,7 @@ export async function startOIDCLogin() {
const configuration = await loadOIDCRuntimeConfiguration(true);
if (!configuration.enabled || !configuration.oidcLogin || !configuration.loginUrl) throw new Error('统一认证未配置');
const returnTo = `${window.location.pathname}${window.location.search}${window.location.hash}` || '/';
const loginURL = new URL(identityEndpointURL(configuration.loginUrl));
const loginURL = new URL(identityEndpointURL(configuration.loginUrl), window.location.origin);
loginURL.searchParams.set('returnTo', returnTo.startsWith('/') ? returnTo : '/');
window.location.assign(loginURL.toString());
}