From c8e849c8cc4e102128d48627105333f16bc9c2b7 Mon Sep 17 00:00:00 2001 From: SuZhou-Joe Date: Mon, 29 Jul 2024 17:04:28 +0800 Subject: [PATCH] feat: consume the get redirect url function from osd core Signed-off-by: SuZhou-Joe --- server/auth/types/openid/openid_auth.ts | 2 +- server/auth/types/saml/saml_auth.ts | 2 +- server/utils/next_url.ts | 12 +++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/server/auth/types/openid/openid_auth.ts b/server/auth/types/openid/openid_auth.ts index 4e50cff5..46c0f23a 100644 --- a/server/auth/types/openid/openid_auth.ts +++ b/server/auth/types/openid/openid_auth.ts @@ -131,7 +131,7 @@ export class OpenIdAuthentication extends AuthenticationType { const path = getRedirectUrl({ request, basePath: this.coreSetup.http.basePath.serverBasePath, - nextUrl: request.url.pathname || '/app/opensearch-dashboards' + nextUrl: request.url.pathname || '/app/opensearch-dashboards', }); return escape(path); } diff --git a/server/auth/types/saml/saml_auth.ts b/server/auth/types/saml/saml_auth.ts index a0abe5b5..e7a2311d 100644 --- a/server/auth/types/saml/saml_auth.ts +++ b/server/auth/types/saml/saml_auth.ts @@ -63,7 +63,7 @@ export class SamlAuthentication extends AuthenticationType { let path = getRedirectUrl({ request, basePath: this.coreSetup.http.basePath.serverBasePath, - nextUrl: request.url.pathname || '/app/opensearch-dashboards' + nextUrl: request.url.pathname || '/app/opensearch-dashboards', }); if (request.url.search) { path += request.url.search; diff --git a/server/utils/next_url.ts b/server/utils/next_url.ts index 7012d490..9cc47adb 100644 --- a/server/utils/next_url.ts +++ b/server/utils/next_url.ts @@ -29,11 +29,13 @@ export function composeNextUrlQueryParam( const nextUrl = parsedUrl?.path; if (!!nextUrl && nextUrl !== '/') { - return `nextUrl=${encodeUriQuery(getRedirectUrl({ - request, - basePath, - nextUrl, - }))}`; + return `nextUrl=${encodeUriQuery( + getRedirectUrl({ + request, + basePath, + nextUrl, + }) + )}`; } } catch (error) { /* Ignore errors from parsing */