diff --git a/packages/nc-gui/composables/useApi/interceptors.ts b/packages/nc-gui/composables/useApi/interceptors.ts index 3d340ff182..1ad82f4c3c 100644 --- a/packages/nc-gui/composables/useApi/interceptors.ts +++ b/packages/nc-gui/composables/useApi/interceptors.ts @@ -16,7 +16,7 @@ export function addAxiosInterceptors(api: Api) { axiosInstance.interceptors.request.use((config) => { config.headers['xc-gui'] = 'true' - if (state.token.value) config.headers['xc-auth'] = state.token.value + if (state.token.value && !config.headers['xc-short-token']) config.headers['xc-auth'] = state.token.value if (!config.url?.endsWith('/user/me') && !config.url?.endsWith('/admin/roles') && state.previewAs?.value) { config.headers['xc-preview'] = state.previewAs.value diff --git a/packages/nc-gui/middleware/auth.global.ts b/packages/nc-gui/middleware/auth.global.ts index 8dd8b72e0c..45914fa013 100644 --- a/packages/nc-gui/middleware/auth.global.ts +++ b/packages/nc-gui/middleware/auth.global.ts @@ -167,9 +167,9 @@ async function tryShortTokenAuth(api: Api, signIn: Actions['signIn']) { try { // `extra` prop is used in our cloud implementation, so we are keeping it const { - data: { token, extra }, + data, } = await api.instance.post( - `/auth/long-lived-token-refresh`, + `/auth/long-lived-token`, {}, { headers: { @@ -178,6 +178,11 @@ async function tryShortTokenAuth(api: Api, signIn: Actions['signIn']) { }, ) + console.log(data) + debugger + const { token, extra } = data + + // if extra prop is null/undefined set it as an empty object as fallback extraProps = extra || {} diff --git a/tests/playwright/pages/Account/Authentication.ts b/tests/playwright/pages/Account/Authentication.ts index 1bbb9f9c31..133d40f7a7 100644 --- a/tests/playwright/pages/Account/Authentication.ts +++ b/tests/playwright/pages/Account/Authentication.ts @@ -61,13 +61,22 @@ export class AccountAuthenticationPage extends BasePage { } } - async createSAMLProvider(p: { title: string; url?: string; xml?: string }) { + async createSAMLProvider( + p: { title: string; url?: string; xml?: string }, + setupRedirectUrlCbk?: ({ redirectUrl: string, audience: string }) => Promise + ) { const newSamlBtn = this.get().locator('[data-test-id="nc-new-saml-provider"]'); await newSamlBtn.click(); const samlModal = this.accountPage.rootPage.locator('.nc-saml-modal'); + if (setupRedirectUrlCbk) { + const redirectUrl = (await samlModal.locator('[data-test-id="nc-saml-redirect-url"]').textContent()).trim(); + const audience = (await samlModal.locator('[data-test-id="nc-saml-issuer-url"]').textContent()).trim(); + await setupRedirectUrlCbk({ redirectUrl, audience }); + } + await samlModal.locator('[data-test-id="nc-saml-title"]').fill(p.title); if (p.url) { await samlModal.locator('[data-test-id="nc-saml-metadata-url"]').fill(p.url); diff --git a/tests/playwright/pages/SsoIdpPage/SAMLLoginPage.ts b/tests/playwright/pages/SsoIdpPage/SAMLLoginPage.ts index 0f9d95c473..6d0192411d 100644 --- a/tests/playwright/pages/SsoIdpPage/SAMLLoginPage.ts +++ b/tests/playwright/pages/SsoIdpPage/SAMLLoginPage.ts @@ -29,6 +29,15 @@ export class SAMLLoginPage extends BasePage { await signIn.locator(`#userName`).fill(email); await signIn.locator(`#email`).fill(email); - await signIn.locator(`#btn-sign-in`).click(); + await Promise.all([ + this.rootPage.waitForNavigation({ url: /localhost:8080/ }), + signIn.locator(`#btn-sign-in`).click(), + ]); + + await this.rootPage.goto(`http://localhost:3000?` + this.rootPage.url().split('?')[1]); + + await this.projectsPage.waitToBeRendered(); + + console.log('111'); } }