diff --git a/packages/core-app-api/src/apis/implementations/IdentityApi/AppIdentityProxy.ts b/packages/core-app-api/src/apis/implementations/IdentityApi/AppIdentityProxy.ts index 8db890ad47..92e2abffb7 100644 --- a/packages/core-app-api/src/apis/implementations/IdentityApi/AppIdentityProxy.ts +++ b/packages/core-app-api/src/apis/implementations/IdentityApi/AppIdentityProxy.ts @@ -55,7 +55,7 @@ export class AppIdentityProxy implements IdentityApi { private resolveTarget: (api: CompatibilityIdentityApi) => void = () => {}; private signOutTargetUrl = '/'; - #cookieAuthSignOut?: () => void; + #cookieAuthSignOut?: () => Promise; constructor() { this.waitForTarget = new Promise(resolve => { diff --git a/plugins/app-backend/src/service/router.ts b/plugins/app-backend/src/service/router.ts index 86736d832e..002342c7db 100644 --- a/plugins/app-backend/src/service/router.ts +++ b/plugins/app-backend/src/service/router.ts @@ -263,12 +263,10 @@ async function injectAppMode(options: { let newContent; if (content.includes('backstage-app-mode')) { - console.log(`DEBUG: REPLACE`, metaTag); newContent = content.replace( //, metaTag, ); - console.log(`DEBUG: newContent=`, newContent); } else { newContent = content.replace(//, `${metaTag}`); } diff --git a/plugins/auth-react/api-report.md b/plugins/auth-react/api-report.md index a5295e54ff..f9c8a10123 100644 --- a/plugins/auth-react/api-report.md +++ b/plugins/auth-react/api-report.md @@ -22,10 +22,7 @@ export type CookieAuthRefreshProviderProps = { }; // @public -export function useCookieAuthRefresh(options: { - pluginId: string; - path?: string; -}): +export function useCookieAuthRefresh(options: { pluginId: string }): | { status: 'loading'; } diff --git a/plugins/auth-react/src/components/CookieAuthRefreshProvider/CookieAuthRefreshProvider.test.tsx b/plugins/auth-react/src/components/CookieAuthRefreshProvider/CookieAuthRefreshProvider.test.tsx index 77710dc7a4..bba876e6be 100644 --- a/plugins/auth-react/src/components/CookieAuthRefreshProvider/CookieAuthRefreshProvider.test.tsx +++ b/plugins/auth-react/src/components/CookieAuthRefreshProvider/CookieAuthRefreshProvider.test.tsx @@ -34,7 +34,7 @@ describe('CookieAuthRefreshProvider', () => { const discoveryApiMock = { getBaseUrl: jest .fn() - .mockResolvedValue('http://localhost:7000/techdocs/api'), + .mockResolvedValue('http://localhost:7000/api/techdocs'), }; function getExpiresAtInFuture() { @@ -119,7 +119,7 @@ describe('CookieAuthRefreshProvider', () => { await waitFor(() => expect(fetchApiMock.fetch).toHaveBeenCalledWith( - 'http://localhost:7000/techdocs/api/.backstage/auth/v1/cookie', + 'http://localhost:7000/api/techdocs/.backstage/auth/v1/cookie', { credentials: 'include' }, ), ); diff --git a/plugins/auth-react/src/components/CookieAuthRefreshProvider/CookieAuthRefreshProvider.tsx b/plugins/auth-react/src/components/CookieAuthRefreshProvider/CookieAuthRefreshProvider.tsx index 4f676aa2d5..b22dce474a 100644 --- a/plugins/auth-react/src/components/CookieAuthRefreshProvider/CookieAuthRefreshProvider.tsx +++ b/plugins/auth-react/src/components/CookieAuthRefreshProvider/CookieAuthRefreshProvider.tsx @@ -27,7 +27,7 @@ import { useCookieAuthRefresh } from '../../hooks'; export type CookieAuthRefreshProviderProps = { // The plugin ID used for discovering the API origin pluginId: string; - // The path used for calling the refresh cookie endpoint, default to '/cookie' + // The path used for calling the refresh cookie endpoint, default to '/.backstage/auth/v1/cookie' path?: string; // The children to render when the refresh is successful children: ReactNode; diff --git a/plugins/auth-react/src/hooks/useCookieAuthRefresh/useCookieAuthRefresh.test.tsx b/plugins/auth-react/src/hooks/useCookieAuthRefresh/useCookieAuthRefresh.test.tsx index cd61b9d94b..df5c833953 100644 --- a/plugins/auth-react/src/hooks/useCookieAuthRefresh/useCookieAuthRefresh.test.tsx +++ b/plugins/auth-react/src/hooks/useCookieAuthRefresh/useCookieAuthRefresh.test.tsx @@ -24,7 +24,7 @@ describe('useCookieAuthRefresh', () => { const discoveryApiMock = { getBaseUrl: jest .fn() - .mockResolvedValue('http://localhost:7000/techdocs/api'), + .mockResolvedValue('http://localhost:7000/api/techdocs'), }; const now = 1710316886171; @@ -236,7 +236,7 @@ describe('useCookieAuthRefresh', () => { await waitFor(() => expect(fetchApiMock.fetch).toHaveBeenCalledWith( - 'http://localhost:7000/techdocs/api/.backstage/auth/v1/cookie', + 'http://localhost:7000/api/techdocs/.backstage/auth/v1/cookie', { credentials: 'include' }, ), ); diff --git a/plugins/auth-react/src/hooks/useCookieAuthRefresh/useCookieAuthRefresh.tsx b/plugins/auth-react/src/hooks/useCookieAuthRefresh/useCookieAuthRefresh.tsx index b26d45447e..244491f7e6 100644 --- a/plugins/auth-react/src/hooks/useCookieAuthRefresh/useCookieAuthRefresh.tsx +++ b/plugins/auth-react/src/hooks/useCookieAuthRefresh/useCookieAuthRefresh.tsx @@ -23,6 +23,8 @@ import { import { useAsync, useMountEffect } from '@react-hookz/web'; import { ResponseError } from '@backstage/errors'; +const COOKIE_PATH = '/.backstage/auth/v1/cookie'; + /** * @public * A hook that will refresh the cookie when it is about to expire. @@ -31,13 +33,11 @@ import { ResponseError } from '@backstage/errors'; export function useCookieAuthRefresh(options: { // The plugin id used for discovering the API origin pluginId: string; - // The path used for calling the refresh cookie endpoint, default to '/.backstage/auth/v1/cookie' - path?: string; }): | { status: 'loading' } | { status: 'error'; error: Error; retry: () => void } | { status: 'success'; data: { expiresAt: string } } { - const { pluginId, path = '/.backstage/auth/v1/cookie' } = options ?? {}; + const { pluginId } = options ?? {}; const fetchApi = useApi(fetchApiRef); const discoveryApi = useApi(discoveryApiRef); @@ -49,7 +49,7 @@ export function useCookieAuthRefresh(options: { const [state, actions] = useAsync<{ expiresAt: string }>(async () => { const apiOrigin = await discoveryApi.getBaseUrl(pluginId); - const requestUrl = `${apiOrigin}${path}`; + const requestUrl = `${apiOrigin}${COOKIE_PATH}`; const response = await fetchApi.fetch(`${requestUrl}`, { credentials: 'include', });