Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

Remove absolute url for login button for truefoundry (#788)

Chirag Jain5b2752103443
diff --git a/packages/trueforge/src/apis/auth.ts b/packages/trueforge/src/apis/auth.ts
index b1085dbcc..371ee5a60 100644
--- a/packages/trueforge/src/apis/auth.ts
+++ b/packages/trueforge/src/apis/auth.ts
@@ -11,7 +11,7 @@ import { safeReturnTo } from '../auth/safeReturnTo';
import { getPublicUiBasePath, isTrueFoundryModeEnabled } from '../config';
import { authLoginRoute, authLogoutRoute, meRoute, oAuthCallbackRoute } from '../routes/authRoutes';
import type { GetMeResponse } from '../schemas/auth';
-import { buildTrueFoundryExternalLoginHref, resolveTrueFoundryLoginReturnTo } from '../truefoundry/externalLogin';
+import { resolveTrueFoundryLoginReturnTo } from '../truefoundry/externalLogin';
/** Login / OIDC failures land on the public UI home with `?error=<reason>`. */
function oauthErrorRedirect(reason: string): string {
@@ -68,7 +68,7 @@ export function createAuthRouter(params: {
if (isTrueFoundryModeEnabled()) {
try {
- return c.redirect(buildTrueFoundryExternalLoginHref(resolveTrueFoundryLoginReturnTo(returnTo)), 302);
+ return c.redirect(resolveTrueFoundryLoginReturnTo(returnTo), 302);
} catch (error) {
params.logger.error('Failed to build TrueFoundry external login URL', extractErrorLogFields(error));
return c.redirect(oauthErrorRedirect('login_failed'), 302);
diff --git a/packages/trueforge/src/truefoundry/externalLogin.ts b/packages/trueforge/src/truefoundry/externalLogin.ts
index 488300cf3..1e8203a26 100644
--- a/packages/trueforge/src/truefoundry/externalLogin.ts
+++ b/packages/trueforge/src/truefoundry/externalLogin.ts
@@ -1,5 +1,5 @@
import { safeReturnTo } from '../auth/safeReturnTo';
-import { getPublicBaseUrl, getPublicUiBasePath } from '../config';
+import { getPublicUiBasePath } from '../config';
/** TrueFoundry platform browser login entry (same-origin path). */
export const TRUEFOUNDRY_EXTERNAL_SIGNIN_PATH = '/signin/external';
@@ -14,14 +14,3 @@ export function resolveTrueFoundryLoginReturnTo(returnTo: string | undefined): s
returnTo !== undefined && returnTo !== '' && safeReturnTo(returnTo) === returnTo ? returnTo : getPublicUiBasePath();
return `${TRUEFOUNDRY_EXTERNAL_SIGNIN_PATH}?${new URLSearchParams({ redirectPath }).toString()}`;
}
-
-/**
- * TrueFoundry platform browser login. Harness is mounted under the TF frontend
- * origin (e.g. `https://app.example.com/trueforge`); `returnTo` is the
- * same-origin `/signin/external?…` path produced by
- * {@link resolveTrueFoundryLoginReturnTo}.
- */
-export function buildTrueFoundryExternalLoginHref(returnTo: string): string {
- const publicUrl = new URL(getPublicBaseUrl());
- return `${publicUrl.origin}${returnTo}`;
-}
diff --git a/packages/trueforge/tests/unit/apis/auth.test.ts b/packages/trueforge/tests/unit/apis/auth.test.ts
index fce05da27..6063d5b21 100644
--- a/packages/trueforge/tests/unit/apis/auth.test.ts
+++ b/packages/trueforge/tests/unit/apis/auth.test.ts
@@ -8,7 +8,7 @@ import { createAuthMiddleware } from '../../../src/auth/middleware';
import { disableOidcAuth, initOidc } from '../../../src/auth/oidc';
import { OidcAuthenticator } from '../../../src/auth/oidcAuthenticator';
import { StandaloneAuthenticator } from '../../../src/auth/standaloneAuthenticator';
-import configuration, { getPublicBaseUrl, getPublicUiBasePath, isTrueFoundryModeEnabled } from '../../../src/config';
+import configuration, { getPublicUiBasePath, isTrueFoundryModeEnabled } from '../../../src/config';
jest.mock('../../../src/config', () => {
const actual = jest.requireActual<typeof import('../../../src/config')>('../../../src/config');
@@ -119,13 +119,11 @@ describe('auth router (TrueFoundry mode)', () => {
beforeEach(() => {
disableOidcAuth();
jest.mocked(isTrueFoundryModeEnabled).mockReturnValue(true);
- jest.mocked(getPublicBaseUrl).mockReturnValue('https://app.example.com/trueforge');
jest.mocked(getPublicUiBasePath).mockReturnValue('/trueforge/');
});
afterEach(() => {
jest.mocked(isTrueFoundryModeEnabled).mockReturnValue(false);
- jest.mocked(getPublicBaseUrl).mockReturnValue('https://harness.example.com');
jest.mocked(getPublicUiBasePath).mockReturnValue('/');
});
@@ -135,7 +133,7 @@ describe('auth router (TrueFoundry mode)', () => {
const res = await router.request('/login', { redirect: 'manual' });
expect(res.status).toBe(302);
- expect(res.headers.get('location')).toBe('https://app.example.com/signin/external?redirectPath=%2Ftrueforge%2F');
+ expect(res.headers.get('location')).toBe('/signin/external?redirectPath=%2Ftrueforge%2F');
});
it('GET /auth/login wraps return_to as platform redirectPath', async () => {
@@ -144,9 +142,7 @@ describe('auth router (TrueFoundry mode)', () => {
const res = await router.request('/login?return_to=/trueforge/sessions/abc', { redirect: 'manual' });
expect(res.status).toBe(302);
- expect(res.headers.get('location')).toBe(
- 'https://app.example.com/signin/external?redirectPath=%2Ftrueforge%2Fsessions%2Fabc',
- );
+ expect(res.headers.get('location')).toBe('/signin/external?redirectPath=%2Ftrueforge%2Fsessions%2Fabc');
});
});
diff --git a/packages/trueforge/tests/unit/truefoundry/externalLogin.test.ts b/packages/trueforge/tests/unit/truefoundry/externalLogin.test.ts
index d089b904d..ea240e8f3 100644
--- a/packages/trueforge/tests/unit/truefoundry/externalLogin.test.ts
+++ b/packages/trueforge/tests/unit/truefoundry/externalLogin.test.ts
@@ -1,5 +1,4 @@
import {
- buildTrueFoundryExternalLoginHref,
resolveTrueFoundryLoginReturnTo,
TRUEFOUNDRY_EXTERNAL_SIGNIN_PATH,
} from '../../../src/truefoundry/externalLogin';
@@ -8,25 +7,10 @@ jest.mock('../../../src/config', () => {
const actual = jest.requireActual<typeof import('../../../src/config')>('../../../src/config');
return {
...actual,
- getPublicBaseUrl: () => 'https://app.example.com/trueforge',
getPublicUiBasePath: () => '/trueforge/',
};
});
-describe('buildTrueFoundryExternalLoginHref', () => {
- it('prefixes PUBLIC_BASE_URL origin onto return_to', () => {
- expect(buildTrueFoundryExternalLoginHref('/signin/external?redirectPath=%2Ftrueforge%2F')).toBe(
- 'https://app.example.com/signin/external?redirectPath=%2Ftrueforge%2F',
- );
- });
-
- it('preserves a deep-link redirectPath inside return_to', () => {
- expect(buildTrueFoundryExternalLoginHref('/signin/external?redirectPath=%2Ftrueforge%2Fsessions%2Fabc')).toBe(
- 'https://app.example.com/signin/external?redirectPath=%2Ftrueforge%2Fsessions%2Fabc',
- );
- });
-});
-
describe('resolveTrueFoundryLoginReturnTo', () => {
it('wraps a safe app path as redirectPath', () => {
expect(resolveTrueFoundryLoginReturnTo('/trueforge/sessions/abc')).toBe(