Skip to content

Commit

Permalink
Fix for 1627
Browse files Browse the repository at this point in the history
Signed-off-by: Deepak Devarakonda <[email protected]>
  • Loading branch information
devardee committed Jan 22, 2024
1 parent 9b88d92 commit 5f2d167
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions server/multitenancy/tenant_resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
* permissions and limitations under the License.
*/

import { isEmpty, findKey, cloneDeep } from 'lodash';
import { cloneDeep, findKey, isEmpty } from 'lodash';
import { OpenSearchDashboardsRequest } from 'opensearch-dashboards/server';
import { ResponseObject } from '@hapi/hapi';
import { modifyUrl } from '@osd/std';
import { SecuritySessionCookie } from '../session/security_cookie';
import { SecurityPluginConfigType } from '..';
import { GLOBAL_TENANT_SYMBOL, PRIVATE_TENANT_SYMBOL, globalTenantName } from '../../common';
import { GLOBAL_TENANT_SYMBOL, globalTenantName, PRIVATE_TENANT_SYMBOL } from '../../common';
import { ensureRawRequest } from '../../../../src/core/server/http/router';
import { GOTO_PREFIX } from '../../../../src/plugins/share/common/short_url_routes';

Expand Down Expand Up @@ -210,16 +210,16 @@ export function addTenantParameterToResolvedShortLink(request: OpenSearchDashboa
if (request.url.pathname.startsWith(`${GOTO_PREFIX}/`)) {
const rawRequest = ensureRawRequest(request);
const rawResponse = rawRequest.response as ResponseObject;
const responsePath = rawResponse.headers.location as string;

// Make sure the request really should redirect
if (rawResponse.headers.location) {
const modifiedUrl = modifyUrl(rawResponse.headers.location as string, (parts) => {
if (rawResponse.headers.location && !responsePath.includes('security_tenant')) {
// Mutating the headers toolkit.next({headers: ...}) logs a warning about headers being overwritten
rawResponse.headers.location = modifyUrl(responsePath, (parts) => {
if (parts.query.security_tenant === undefined) {
parts.query.security_tenant = request.headers.securitytenant as string;
}
// Mutating the headers toolkit.next({headers: ...}) logs a warning about headers being overwritten
});
rawResponse.headers.location = modifiedUrl;
}
}

Expand Down

0 comments on commit 5f2d167

Please sign in to comment.