From 13df1e8da0f7910f13b24808e8ad1784a2cb7ad8 Mon Sep 17 00:00:00 2001 From: Asier Isayas Date: Fri, 21 Jun 2024 12:46:47 -0400 Subject: [PATCH] testing for legacy mongo shell --- src/Common/CosmosClient.ts | 3 ++- src/Common/MongoProxyClient.ts | 2 +- src/ConfigContext.ts | 5 ++-- src/Explorer/Explorer.tsx | 3 +-- .../MongoShellTab/MongoShellTabComponent.tsx | 7 +++-- .../Tabs/MongoShellTab/getMongoShellUrl.ts | 2 +- src/Utils/MessageValidation.ts | 27 ++++++++++--------- 7 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/Common/CosmosClient.ts b/src/Common/CosmosClient.ts index c24680f4b..7a1b33b82 100644 --- a/src/Common/CosmosClient.ts +++ b/src/Common/CosmosClient.ts @@ -16,10 +16,11 @@ const _global = typeof self === "undefined" ? window : self; export const tokenProvider = async (requestInfo: Cosmos.RequestInfo) => { const { verb, resourceId, resourceType, headers } = requestInfo; - + if (userContext.features.enableAadDataPlane && userContext.aadToken) { const AUTH_PREFIX = `type=aad&ver=1.0&sig=`; const authorizationToken = `${AUTH_PREFIX}${userContext.aadToken}`; + console.log(authorizationToken) return authorizationToken; } diff --git a/src/Common/MongoProxyClient.ts b/src/Common/MongoProxyClient.ts index d9aa0fb4c..f3202347b 100644 --- a/src/Common/MongoProxyClient.ts +++ b/src/Common/MongoProxyClient.ts @@ -70,7 +70,7 @@ export function queryDocuments( if (!useMongoProxyEndpoint("resourcelist") || !useMongoProxyEndpoint("queryDocuments")) { return queryDocuments_ToBeDeprecated(databaseId, collection, isResourceList, query, continuationToken); } - + console.log(configContext.MONGO_PROXY_ENDPOINT) const { databaseAccount } = userContext; const resourceEndpoint = databaseAccount.properties.mongoEndpoint || databaseAccount.properties.documentEndpoint; const params = { diff --git a/src/ConfigContext.ts b/src/ConfigContext.ts index 564e905ba..1a20562e7 100644 --- a/src/ConfigContext.ts +++ b/src/ConfigContext.ts @@ -107,7 +107,7 @@ let configContext: Readonly = { JUNO_ENDPOINT: JunoEndpoints.Prod, BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com", PORTAL_BACKEND_ENDPOINT: PortalBackendEndpoints.Prod, - MONGO_PROXY_ENDPOINT: MongoProxyEndpoints.Prod, + MONGO_PROXY_ENDPOINT: MongoProxyEndpoints.Local, NEW_MONGO_APIS: [ "resourcelist", "queryDocuments", @@ -200,7 +200,7 @@ if (process.env.NODE_ENV === "development") { PROXY_PATH: "/proxy", EMULATOR_ENDPOINT: "https://localhost:8081", PORTAL_BACKEND_ENDPOINT: PortalBackendEndpoints.Mpac, - MONGO_PROXY_ENDPOINT: MongoProxyEndpoints.Mpac, + // MONGO_PROXY_ENDPOINT: MongoProxyEndpoints.Mpac, CASSANDRA_PROXY_ENDPOINT: CassandraProxyEndpoints.Mpac, }); } @@ -255,3 +255,4 @@ export async function initializeConfiguration(): Promise { } export { configContext }; + diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index bb198e6c3..a52177efb 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -1,5 +1,4 @@ import { Link } from "@fluentui/react/lib/Link"; -import { isPublicInternetAccessAllowed } from "Common/DatabaseAccountUtility"; import { sendMessage } from "Common/MessageHandler"; import { Platform, configContext } from "ConfigContext"; import { MessageTypes } from "Contracts/ExplorerContracts"; @@ -1124,7 +1123,7 @@ export default class Explorer { useNotebook.getState().setIsNotebookEnabled(isNotebookEnabled); useNotebook .getState() - .setIsShellEnabled(useNotebook.getState().isPhoenixFeatures && isPublicInternetAccessAllowed()); + .setIsShellEnabled(false); TelemetryProcessor.trace(Action.NotebookEnabled, ActionModifiers.Mark, { isNotebookEnabled, diff --git a/src/Explorer/Tabs/MongoShellTab/MongoShellTabComponent.tsx b/src/Explorer/Tabs/MongoShellTab/MongoShellTabComponent.tsx index 052c81ce6..53cecb8f2 100644 --- a/src/Explorer/Tabs/MongoShellTab/MongoShellTabComponent.tsx +++ b/src/Explorer/Tabs/MongoShellTab/MongoShellTabComponent.tsx @@ -1,4 +1,3 @@ -import { useMongoProxyEndpoint } from "Common/MongoProxyClient"; import React, { Component } from "react"; import * as Constants from "../../../Common/Constants"; import { configContext } from "../../../ConfigContext"; @@ -55,8 +54,8 @@ export default class MongoShellTabComponent extends Component< constructor(props: IMongoShellTabComponentProps) { super(props); this._logTraces = new Map(); - this._useMongoProxyEndpoint = useMongoProxyEndpoint("legacyMongoShell"); - + // this._useMongoProxyEndpoint = useMongoProxyEndpoint("legacyMongoShell"); + this._useMongoProxyEndpoint = true; this.state = { url: getMongoShellUrl(this._useMongoProxyEndpoint), }; @@ -140,7 +139,7 @@ export default class MongoShellTabComponent extends Component< apiEndpoint: apiEndpoint, }, }, - window.origin, + "https://localhost:8080", ); } diff --git a/src/Explorer/Tabs/MongoShellTab/getMongoShellUrl.ts b/src/Explorer/Tabs/MongoShellTab/getMongoShellUrl.ts index a3b49b373..5c84332de 100644 --- a/src/Explorer/Tabs/MongoShellTab/getMongoShellUrl.ts +++ b/src/Explorer/Tabs/MongoShellTab/getMongoShellUrl.ts @@ -7,5 +7,5 @@ export function getMongoShellUrl(useMongoProxyEndpoint?: boolean): string { const mongoEndpoint = account?.properties?.mongoEndpoint || account?.properties?.documentEndpoint; const queryString = `resourceId=${resourceId}&accountName=${accountName}&mongoEndpoint=${mongoEndpoint}`; - return useMongoProxyEndpoint ? `/mongoshell/index.html?${queryString}` : `/mongoshell/indexv2.html?${queryString}`; + return useMongoProxyEndpoint ? `https://localhost:8080/index.html?${queryString}` : `/mongoshell/indexv2.html?${queryString}`; } diff --git a/src/Utils/MessageValidation.ts b/src/Utils/MessageValidation.ts index 6490722ea..a26def462 100644 --- a/src/Utils/MessageValidation.ts +++ b/src/Utils/MessageValidation.ts @@ -5,20 +5,21 @@ export function isInvalidParentFrameOrigin(event: MessageEvent): boolean { } function isValidOrigin(allowedOrigins: ReadonlyArray, event: MessageEvent): boolean { - const eventOrigin = (event && event.origin) || ""; - const windowOrigin = (window && window.origin) || ""; - if (eventOrigin === windowOrigin) { - return true; - } + return true; + // const eventOrigin = (event && event.origin) || ""; + // const windowOrigin = (window && window.origin) || ""; + // if (eventOrigin === windowOrigin) { + // return true; + // } - for (const origin of allowedOrigins) { - const result = new RegExp(origin).test(eventOrigin); - if (result) { - return true; - } - } - console.error(`Invalid parent frame origin detected: ${eventOrigin}`); - return false; + // for (const origin of allowedOrigins) { + // const result = new RegExp(origin).test(eventOrigin); + // if (result) { + // return true; + // } + // } + // console.error(`Invalid parent frame origin detected: ${eventOrigin}`); + // return false; } export function shouldProcessMessage(event: MessageEvent): boolean {