mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-19 17:01:13 +00:00
Format
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
|||||||
getFeatureEndpointOrDefault,
|
getFeatureEndpointOrDefault,
|
||||||
queryDocuments,
|
queryDocuments,
|
||||||
readDocument,
|
readDocument,
|
||||||
updateDocument
|
updateDocument,
|
||||||
} from "./MongoProxyClient";
|
} from "./MongoProxyClient";
|
||||||
|
|
||||||
const databaseId = "testDB";
|
const databaseId = "testDB";
|
||||||
|
|||||||
@@ -337,8 +337,9 @@ export function createMongoCollectionWithProxy(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getFeatureEndpointOrDefault(feature: string): string {
|
export function getFeatureEndpointOrDefault(feature: string): string {
|
||||||
|
const endpoint =
|
||||||
const endpoint = (hasFlag(userContext.features.mongoProxyAPIs, feature) && validateEndpoint(userContext.features.mongoProxyEndpoint, allowedMongoProxyEndpoints))
|
hasFlag(userContext.features.mongoProxyAPIs, feature) &&
|
||||||
|
validateEndpoint(userContext.features.mongoProxyEndpoint, allowedMongoProxyEndpoints)
|
||||||
? userContext.features.mongoProxyEndpoint
|
? userContext.features.mongoProxyEndpoint
|
||||||
: configContext.MONGO_BACKEND_ENDPOINT || configContext.BACKEND_ENDPOINT;
|
: configContext.MONGO_BACKEND_ENDPOINT || configContext.BACKEND_ENDPOINT;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,18 @@
|
|||||||
import { JunoEndpoints } from "Common/Constants";
|
import { JunoEndpoints } from "Common/Constants";
|
||||||
import { allowedAadEndpoints, allowedArcadiaEndpoints, allowedArcadiaLivyDnsZones, allowedArmEndpoints, allowedBackendEndpoints, allowedEmulatorEndpoints, allowedGraphEndpoints, allowedHostedExplorerEndpoints, allowedJunoEndpoints, allowedMongoBackendEndpoints, allowedMsalRedirectEndpoints, validateEndpoint } from "Utils/EndpointValidation";
|
import {
|
||||||
|
allowedAadEndpoints,
|
||||||
|
allowedArcadiaEndpoints,
|
||||||
|
allowedArcadiaLivyDnsZones,
|
||||||
|
allowedArmEndpoints,
|
||||||
|
allowedBackendEndpoints,
|
||||||
|
allowedEmulatorEndpoints,
|
||||||
|
allowedGraphEndpoints,
|
||||||
|
allowedHostedExplorerEndpoints,
|
||||||
|
allowedJunoEndpoints,
|
||||||
|
allowedMongoBackendEndpoints,
|
||||||
|
allowedMsalRedirectEndpoints,
|
||||||
|
validateEndpoint,
|
||||||
|
} from "Utils/EndpointValidation";
|
||||||
|
|
||||||
export enum Platform {
|
export enum Platform {
|
||||||
Portal = "Portal",
|
Portal = "Portal",
|
||||||
@@ -84,47 +97,102 @@ export function updateConfigContext(newContext: Partial<ConfigContext>): void {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validateEndpoint(newContext.ARM_ENDPOINT, allowedArmEndpoints.map(endpoint => endpoint))) {
|
if (
|
||||||
|
!validateEndpoint(
|
||||||
|
newContext.ARM_ENDPOINT,
|
||||||
|
allowedArmEndpoints.map((endpoint) => endpoint)
|
||||||
|
)
|
||||||
|
) {
|
||||||
delete newContext.ARM_ENDPOINT;
|
delete newContext.ARM_ENDPOINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validateEndpoint(newContext.AAD_ENDPOINT, allowedAadEndpoints.map(endpoint => endpoint))) {
|
if (
|
||||||
|
!validateEndpoint(
|
||||||
|
newContext.AAD_ENDPOINT,
|
||||||
|
allowedAadEndpoints.map((endpoint) => endpoint)
|
||||||
|
)
|
||||||
|
) {
|
||||||
delete newContext.AAD_ENDPOINT;
|
delete newContext.AAD_ENDPOINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validateEndpoint(newContext.EMULATOR_ENDPOINT, allowedEmulatorEndpoints.map(endpoint => endpoint))) {
|
if (
|
||||||
|
!validateEndpoint(
|
||||||
|
newContext.EMULATOR_ENDPOINT,
|
||||||
|
allowedEmulatorEndpoints.map((endpoint) => endpoint)
|
||||||
|
)
|
||||||
|
) {
|
||||||
delete newContext.EMULATOR_ENDPOINT;
|
delete newContext.EMULATOR_ENDPOINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validateEndpoint(newContext.GRAPH_ENDPOINT, allowedGraphEndpoints.map(endpoint => endpoint))) {
|
if (
|
||||||
|
!validateEndpoint(
|
||||||
|
newContext.GRAPH_ENDPOINT,
|
||||||
|
allowedGraphEndpoints.map((endpoint) => endpoint)
|
||||||
|
)
|
||||||
|
) {
|
||||||
delete newContext.GRAPH_ENDPOINT;
|
delete newContext.GRAPH_ENDPOINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validateEndpoint(newContext.ARCADIA_ENDPOINT, allowedArcadiaEndpoints.map(endpoint => endpoint))) {
|
if (
|
||||||
|
!validateEndpoint(
|
||||||
|
newContext.ARCADIA_ENDPOINT,
|
||||||
|
allowedArcadiaEndpoints.map((endpoint) => endpoint)
|
||||||
|
)
|
||||||
|
) {
|
||||||
delete newContext.ARCADIA_ENDPOINT;
|
delete newContext.ARCADIA_ENDPOINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validateEndpoint(newContext.ARCADIA_LIVY_ENDPOINT_DNS_ZONE, allowedArcadiaLivyDnsZones.map(endpoint => endpoint))) {
|
if (
|
||||||
|
!validateEndpoint(
|
||||||
|
newContext.ARCADIA_LIVY_ENDPOINT_DNS_ZONE,
|
||||||
|
allowedArcadiaLivyDnsZones.map((endpoint) => endpoint)
|
||||||
|
)
|
||||||
|
) {
|
||||||
delete newContext.ARCADIA_LIVY_ENDPOINT_DNS_ZONE;
|
delete newContext.ARCADIA_LIVY_ENDPOINT_DNS_ZONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validateEndpoint(newContext.BACKEND_ENDPOINT, allowedBackendEndpoints.map(endpoint => endpoint))) {
|
if (
|
||||||
|
!validateEndpoint(
|
||||||
|
newContext.BACKEND_ENDPOINT,
|
||||||
|
allowedBackendEndpoints.map((endpoint) => endpoint)
|
||||||
|
)
|
||||||
|
) {
|
||||||
delete newContext.BACKEND_ENDPOINT;
|
delete newContext.BACKEND_ENDPOINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validateEndpoint(newContext.MONGO_BACKEND_ENDPOINT, allowedMongoBackendEndpoints.map(endpoint => endpoint))) {
|
if (
|
||||||
|
!validateEndpoint(
|
||||||
|
newContext.MONGO_BACKEND_ENDPOINT,
|
||||||
|
allowedMongoBackendEndpoints.map((endpoint) => endpoint)
|
||||||
|
)
|
||||||
|
) {
|
||||||
delete newContext.MONGO_BACKEND_ENDPOINT;
|
delete newContext.MONGO_BACKEND_ENDPOINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validateEndpoint(newContext.JUNO_ENDPOINT, allowedJunoEndpoints.map(endpoint => endpoint))) {
|
if (
|
||||||
|
!validateEndpoint(
|
||||||
|
newContext.JUNO_ENDPOINT,
|
||||||
|
allowedJunoEndpoints.map((endpoint) => endpoint)
|
||||||
|
)
|
||||||
|
) {
|
||||||
delete newContext.JUNO_ENDPOINT;
|
delete newContext.JUNO_ENDPOINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validateEndpoint(newContext.hostedExplorerURL, allowedHostedExplorerEndpoints.map(endpoint => endpoint))) {
|
if (
|
||||||
|
!validateEndpoint(
|
||||||
|
newContext.hostedExplorerURL,
|
||||||
|
allowedHostedExplorerEndpoints.map((endpoint) => endpoint)
|
||||||
|
)
|
||||||
|
) {
|
||||||
delete newContext.hostedExplorerURL;
|
delete newContext.hostedExplorerURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validateEndpoint(newContext.msalRedirectURI, allowedMsalRedirectEndpoints.map(endpoint => endpoint))) {
|
if (
|
||||||
|
!validateEndpoint(
|
||||||
|
newContext.msalRedirectURI,
|
||||||
|
allowedMsalRedirectEndpoints.map((endpoint) => endpoint)
|
||||||
|
)
|
||||||
|
) {
|
||||||
delete newContext.msalRedirectURI;
|
delete newContext.msalRedirectURI;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,4 +269,3 @@ export async function initializeConfiguration(): Promise<ConfigContext> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export { configContext };
|
export { configContext };
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import {
|
|||||||
ContainerConnectionInfo,
|
ContainerConnectionInfo,
|
||||||
IPhoenixConnectionInfoResult,
|
IPhoenixConnectionInfoResult,
|
||||||
IProvisionData,
|
IProvisionData,
|
||||||
IResponse
|
IResponse,
|
||||||
} from "../Contracts/DataModels";
|
} from "../Contracts/DataModels";
|
||||||
import * as ViewModels from "../Contracts/ViewModels";
|
import * as ViewModels from "../Contracts/ViewModels";
|
||||||
import { GitHubOAuthService } from "../GitHub/GitHubOAuthService";
|
import { GitHubOAuthService } from "../GitHub/GitHubOAuthService";
|
||||||
@@ -36,7 +36,7 @@ import { update } from "../Utils/arm/generatedClients/cosmos/databaseAccounts";
|
|||||||
import {
|
import {
|
||||||
get as getWorkspace,
|
get as getWorkspace,
|
||||||
listByDatabaseAccount,
|
listByDatabaseAccount,
|
||||||
start
|
start,
|
||||||
} from "../Utils/arm/generatedClients/cosmosNotebooks/notebookWorkspaces";
|
} from "../Utils/arm/generatedClients/cosmosNotebooks/notebookWorkspaces";
|
||||||
import { stringToBlob } from "../Utils/BlobUtils";
|
import { stringToBlob } from "../Utils/BlobUtils";
|
||||||
import { isCapabilityEnabled } from "../Utils/CapabilityUtils";
|
import { isCapabilityEnabled } from "../Utils/CapabilityUtils";
|
||||||
@@ -179,7 +179,11 @@ export default class Explorer {
|
|||||||
this.resourceTree = new ResourceTreeAdapter(this);
|
this.resourceTree = new ResourceTreeAdapter(this);
|
||||||
|
|
||||||
// Override notebook server parameters from URL parameters
|
// Override notebook server parameters from URL parameters
|
||||||
if (userContext.features.notebookServerUrl && validateEndpoint(userContext.features.notebookServerUrl, allowedNotebookServerUrls) && userContext.features.notebookServerToken) {
|
if (
|
||||||
|
userContext.features.notebookServerUrl &&
|
||||||
|
validateEndpoint(userContext.features.notebookServerUrl, allowedNotebookServerUrls) &&
|
||||||
|
userContext.features.notebookServerToken
|
||||||
|
) {
|
||||||
useNotebook.getState().setNotebookServerInfo({
|
useNotebook.getState().setNotebookServerInfo({
|
||||||
notebookServerEndpoint: userContext.features.notebookServerUrl,
|
notebookServerEndpoint: userContext.features.notebookServerUrl,
|
||||||
authToken: userContext.features.notebookServerToken,
|
authToken: userContext.features.notebookServerToken,
|
||||||
@@ -410,7 +414,10 @@ export default class Explorer {
|
|||||||
connectionStatus.status = ConnectionStatusType.Connected;
|
connectionStatus.status = ConnectionStatusType.Connected;
|
||||||
useNotebook.getState().setConnectionInfo(connectionStatus);
|
useNotebook.getState().setConnectionInfo(connectionStatus);
|
||||||
useNotebook.getState().setNotebookServerInfo({
|
useNotebook.getState().setNotebookServerInfo({
|
||||||
notebookServerEndpoint: validateEndpoint(userContext.features.notebookServerUrl, allowedNotebookServerUrls) && userContext.features.notebookServerUrl || connectionInfo.data.notebookServerUrl,
|
notebookServerEndpoint:
|
||||||
|
(validateEndpoint(userContext.features.notebookServerUrl, allowedNotebookServerUrls) &&
|
||||||
|
userContext.features.notebookServerUrl) ||
|
||||||
|
connectionInfo.data.notebookServerUrl,
|
||||||
authToken: userContext.features.notebookServerToken || connectionInfo.data.notebookAuthToken,
|
authToken: userContext.features.notebookServerToken || connectionInfo.data.notebookAuthToken,
|
||||||
forwardingId: connectionInfo.data.forwardingId,
|
forwardingId: connectionInfo.data.forwardingId,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
ContainerStatusType,
|
ContainerStatusType,
|
||||||
HttpHeaders,
|
HttpHeaders,
|
||||||
HttpStatusCodes,
|
HttpStatusCodes,
|
||||||
Notebook
|
Notebook,
|
||||||
} from "../Common/Constants";
|
} from "../Common/Constants";
|
||||||
import { getErrorMessage } from "../Common/ErrorHandlingUtils";
|
import { getErrorMessage } from "../Common/ErrorHandlingUtils";
|
||||||
import * as Logger from "../Common/Logger";
|
import * as Logger from "../Common/Logger";
|
||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
IContainerData,
|
IContainerData,
|
||||||
IPhoenixConnectionInfoResult,
|
IPhoenixConnectionInfoResult,
|
||||||
IProvisionData,
|
IProvisionData,
|
||||||
IResponse
|
IResponse,
|
||||||
} from "../Contracts/DataModels";
|
} from "../Contracts/DataModels";
|
||||||
import { useNotebook } from "../Explorer/Notebook/useNotebook";
|
import { useNotebook } from "../Explorer/Notebook/useNotebook";
|
||||||
import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor";
|
import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor";
|
||||||
|
|||||||
@@ -3,63 +3,38 @@ export function validateEndpoint(endpointToValidate: string, allowedEndpoints: s
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const originToValidate: string = new URL(endpointToValidate).origin;
|
const originToValidate: string = new URL(endpointToValidate).origin;
|
||||||
const allowedOrigins: string[] = allowedEndpoints.map(allowedEndpoint => new URL(allowedEndpoint).origin) || [];
|
const allowedOrigins: string[] = allowedEndpoints.map((allowedEndpoint) => new URL(allowedEndpoint).origin) || [];
|
||||||
return allowedOrigins.indexOf(originToValidate) >= 0;
|
return allowedOrigins.indexOf(originToValidate) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const allowedArmEndpoints: ReadonlyArray<string> = [
|
export const allowedArmEndpoints: ReadonlyArray<string> = [
|
||||||
"https://management.azure.com",
|
"https://management.azure.com",
|
||||||
"https://management.usgovcloudapi.net",
|
"https://management.usgovcloudapi.net",
|
||||||
"https://management.chinacloudapi.cn"
|
"https://management.chinacloudapi.cn",
|
||||||
];
|
];
|
||||||
|
|
||||||
export const allowedAadEndpoints: ReadonlyArray<string> = [
|
export const allowedAadEndpoints: ReadonlyArray<string> = ["https://login.microsoftonline.com/"];
|
||||||
"https://login.microsoftonline.com/"
|
|
||||||
];
|
|
||||||
|
|
||||||
export const allowedEmulatorEndpoints: ReadonlyArray<string> = [
|
export const allowedEmulatorEndpoints: ReadonlyArray<string> = [];
|
||||||
];
|
|
||||||
|
|
||||||
export const allowedGraphEndpoints: ReadonlyArray<string> = [
|
export const allowedGraphEndpoints: ReadonlyArray<string> = [];
|
||||||
|
|
||||||
];
|
export const allowedArcadiaEndpoints: ReadonlyArray<string> = [];
|
||||||
|
|
||||||
export const allowedArcadiaEndpoints: ReadonlyArray<string> = [
|
export const allowedArcadiaLivyDnsZones: ReadonlyArray<string> = [];
|
||||||
|
|
||||||
];
|
export const allowedBackendEndpoints: ReadonlyArray<string> = [];
|
||||||
|
|
||||||
export const allowedArcadiaLivyDnsZones: ReadonlyArray<string> = [
|
export const allowedMongoBackendEndpoints: ReadonlyArray<string> = [];
|
||||||
|
|
||||||
];
|
export const allowedJunoEndpoints: ReadonlyArray<string> = [];
|
||||||
|
|
||||||
export const allowedBackendEndpoints: ReadonlyArray<string> = [
|
export const allowedHostedExplorerEndpoints: ReadonlyArray<string> = [];
|
||||||
|
|
||||||
];
|
export const allowedMsalRedirectEndpoints: ReadonlyArray<string> = [];
|
||||||
|
|
||||||
export const allowedMongoBackendEndpoints: ReadonlyArray<string> = [
|
export const allowedMongoProxyEndpoints: ReadonlyArray<string> = [];
|
||||||
|
|
||||||
];
|
export const allowedPhoenixEndpoints: ReadonlyArray<string> = [];
|
||||||
|
|
||||||
export const allowedJunoEndpoints: ReadonlyArray<string> = [
|
export const allowedNotebookServerUrls: ReadonlyArray<string> = [];
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
export const allowedHostedExplorerEndpoints: ReadonlyArray<string> = [
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
export const allowedMsalRedirectEndpoints: ReadonlyArray<string> = [
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
export const allowedMongoProxyEndpoints: ReadonlyArray<string> = [
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
export const allowedPhoenixEndpoints: ReadonlyArray<string> = [
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
export const allowedNotebookServerUrls: ReadonlyArray<string> = [
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|||||||
Reference in New Issue
Block a user