From 46c93f3fb933417556ad685d4d084124839d521d Mon Sep 17 00:00:00 2001 From: hsiang9431-amzn Date: Wed, 2 Jun 2021 14:35:44 -0700 Subject: [PATCH] Fix login redirect (#777) --- public/apps/account/utils.tsx | 6 ++++-- ...-security-dashboards-plugin.release-notes-1.0.0.0-rc1.md | 1 + server/auth/types/basic/routes.ts | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/public/apps/account/utils.tsx b/public/apps/account/utils.tsx index e0b91b099..465b47005 100644 --- a/public/apps/account/utils.tsx +++ b/public/apps/account/utils.tsx @@ -14,7 +14,7 @@ */ import { HttpStart } from 'opensearch-dashboards/public'; -import { API_AUTH_LOGOUT } from '../../../common'; +import { API_AUTH_LOGOUT, LOGIN_PAGE_URI } from '../../../common'; import { API_ENDPOINT_ACCOUNT_INFO } from './constants'; import { AccountInfo } from './types'; import { httpGet, httpGetWithIgnores, httpPost } from '../configuration/utils/request-utils'; @@ -31,7 +31,9 @@ export async function fetchAccountInfoSafe(http: HttpStart): Promise { await httpPost(http, API_AUTH_LOGOUT); setShouldShowTenantPopup(null); - window.location.href = logoutUrl || `${http.basePath.serverBasePath}/app/login`; + const nextUrl = encodeURIComponent(http.basePath.serverBasePath); + window.location.href = + logoutUrl || `${http.basePath.serverBasePath}/app/login?nextUrl=${nextUrl}`; } export async function updateNewPassword( diff --git a/release-notes/opensearch-security-dashboards-plugin.release-notes-1.0.0.0-rc1.md b/release-notes/opensearch-security-dashboards-plugin.release-notes-1.0.0.0-rc1.md index 3182c0d1e..52ed89cef 100644 --- a/release-notes/opensearch-security-dashboards-plugin.release-notes-1.0.0.0-rc1.md +++ b/release-notes/opensearch-security-dashboards-plugin.release-notes-1.0.0.0-rc1.md @@ -6,6 +6,7 @@ ### Bug Fixes * Fixing JSON parsing in SAML for strings that contain '\' character [#749](https://github.com/opensearch-project/security-dashboards-plugin/pull/749) +* Fix login redirect [#777](https://github.com/opensearch-project/security-dashboards-plugin/pull/777) ### Maintenance * move issue templates to ISSUE_TEMPLATE [#758](https://github.com/opensearch-project/security-dashboards-plugin/pull/758) diff --git a/server/auth/types/basic/routes.ts b/server/auth/types/basic/routes.ts index 892e88cd3..a32b4486c 100644 --- a/server/auth/types/basic/routes.ts +++ b/server/auth/types/basic/routes.ts @@ -178,7 +178,7 @@ export class BasicAuthRoutes { ); return response.redirected({ headers: { - location: `${this.coreSetup.http.basePath.serverBasePath}${LOGIN_PAGE_URI}`, + location: `${this.coreSetup.http.basePath.serverBasePath}`, }, }); } @@ -214,7 +214,7 @@ export class BasicAuthRoutes { ); return response.redirected({ headers: { - location: `${this.coreSetup.http.basePath.serverBasePath}${LOGIN_PAGE_URI}`, + location: `${this.coreSetup.http.basePath.serverBasePath}`, }, }); }