mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-06-11 23:17:38 +01:00
Disabled Mongo Shell based on auth method from portal for vcore cluster
This commit is contained in:
@@ -17,12 +17,18 @@ import SynapseIcon from "../../../../images/synapse-link.svg";
|
|||||||
import VSCodeIcon from "../../../../images/vscode.svg";
|
import VSCodeIcon from "../../../../images/vscode.svg";
|
||||||
import { AuthType } from "../../../AuthType";
|
import { AuthType } from "../../../AuthType";
|
||||||
import * as Constants from "../../../Common/Constants";
|
import * as Constants from "../../../Common/Constants";
|
||||||
import { Platform, configContext } from "../../../ConfigContext";
|
import { configContext, Platform } from "../../../ConfigContext";
|
||||||
import * as ViewModels from "../../../Contracts/ViewModels";
|
import * as ViewModels from "../../../Contracts/ViewModels";
|
||||||
import { userContext } from "../../../UserContext";
|
import {
|
||||||
|
isVCoreMongoNativeAuthDisabled,
|
||||||
|
userContext,
|
||||||
|
VCoreMongoNativeAuthDisabledMessage,
|
||||||
|
VCoreMongoNativeAuthLearnMoreUrl,
|
||||||
|
} from "../../../UserContext";
|
||||||
import { isRunningOnNationalCloud } from "../../../Utils/CloudUtils";
|
import { isRunningOnNationalCloud } from "../../../Utils/CloudUtils";
|
||||||
import { useSidePanel } from "../../../hooks/useSidePanel";
|
import { useSidePanel } from "../../../hooks/useSidePanel";
|
||||||
import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent";
|
import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent";
|
||||||
|
import { useDialog } from "../../Controls/Dialog";
|
||||||
import Explorer from "../../Explorer";
|
import Explorer from "../../Explorer";
|
||||||
import { useNotebook } from "../../Notebook/useNotebook";
|
import { useNotebook } from "../../Notebook/useNotebook";
|
||||||
import { BrowseQueriesPane } from "../../Panes/BrowseQueriesPane/BrowseQueriesPane";
|
import { BrowseQueriesPane } from "../../Panes/BrowseQueriesPane/BrowseQueriesPane";
|
||||||
@@ -508,12 +514,23 @@ function createOpenTerminalButtonByKind(
|
|||||||
const label = `Open ${terminalFriendlyName()} shell`;
|
const label = `Open ${terminalFriendlyName()} shell`;
|
||||||
const tooltip =
|
const tooltip =
|
||||||
"This feature is not yet available in your account's region. View supported regions here: https://aka.ms/cosmos-enable-notebooks.";
|
"This feature is not yet available in your account's region. View supported regions here: https://aka.ms/cosmos-enable-notebooks.";
|
||||||
|
const isNativeAuthDisabled =
|
||||||
|
terminalKind === ViewModels.TerminalKind.VCoreMongo && isVCoreMongoNativeAuthDisabled();
|
||||||
const disableButton =
|
const disableButton =
|
||||||
!useNotebook.getState().isNotebooksEnabledForAccount && !useNotebook.getState().isNotebookEnabled;
|
(!useNotebook.getState().isNotebooksEnabledForAccount && !useNotebook.getState().isNotebookEnabled) ||
|
||||||
|
isNativeAuthDisabled;
|
||||||
return {
|
return {
|
||||||
iconSrc: HostedTerminalIcon,
|
iconSrc: HostedTerminalIcon,
|
||||||
iconAlt: label,
|
iconAlt: label,
|
||||||
onCommandClick: () => {
|
onCommandClick: () => {
|
||||||
|
if (isNativeAuthDisabled) {
|
||||||
|
useDialog.getState().showOkModalDialog(
|
||||||
|
"Native Authentication Disabled",
|
||||||
|
VCoreMongoNativeAuthDisabledMessage,
|
||||||
|
{ linkText: "Learn more", linkUrl: VCoreMongoNativeAuthLearnMoreUrl },
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (useNotebook.getState().isNotebookEnabled || userContext.features.enableCloudShell) {
|
if (useNotebook.getState().isNotebookEnabled || userContext.features.enableCloudShell) {
|
||||||
container.openNotebookTerminal(terminalKind);
|
container.openNotebookTerminal(terminalKind);
|
||||||
}
|
}
|
||||||
@@ -522,7 +539,7 @@ function createOpenTerminalButtonByKind(
|
|||||||
hasPopup: false,
|
hasPopup: false,
|
||||||
disabled: disableButton,
|
disabled: disableButton,
|
||||||
ariaLabel: label,
|
ariaLabel: label,
|
||||||
tooltipText: !disableButton ? "" : tooltip,
|
tooltipText: isNativeAuthDisabled ? VCoreMongoNativeAuthDisabledMessage : !disableButton ? "" : tooltip,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,14 @@ import VisualStudioIcon from "../../../images/VisualStudio.svg";
|
|||||||
import NotebookIcon from "../../../images/notebook/Notebook-resource.svg";
|
import NotebookIcon from "../../../images/notebook/Notebook-resource.svg";
|
||||||
import CollectionIcon from "../../../images/tree-collection.svg";
|
import CollectionIcon from "../../../images/tree-collection.svg";
|
||||||
import * as Constants from "../../Common/Constants";
|
import * as Constants from "../../Common/Constants";
|
||||||
import { userContext } from "../../UserContext";
|
import {
|
||||||
|
isVCoreMongoNativeAuthDisabled,
|
||||||
|
userContext,
|
||||||
|
VCoreMongoNativeAuthDisabledMessage,
|
||||||
|
VCoreMongoNativeAuthLearnMoreUrl,
|
||||||
|
} from "../../UserContext";
|
||||||
import { getCollectionName } from "../../Utils/APITypeUtils";
|
import { getCollectionName } from "../../Utils/APITypeUtils";
|
||||||
|
import { useDialog } from "../Controls/Dialog";
|
||||||
import Explorer from "../Explorer";
|
import Explorer from "../Explorer";
|
||||||
import * as MostRecentActivity from "../MostRecentActivity/MostRecentActivity";
|
import * as MostRecentActivity from "../MostRecentActivity/MostRecentActivity";
|
||||||
import { useNotebook } from "../Notebook/useNotebook";
|
import { useNotebook } from "../Notebook/useNotebook";
|
||||||
@@ -423,11 +429,22 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({ explorer }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (userContext.apiType === "VCoreMongo") {
|
if (userContext.apiType === "VCoreMongo") {
|
||||||
|
const isNativeAuthDisabled = isVCoreMongoNativeAuthDisabled();
|
||||||
return {
|
return {
|
||||||
iconSrc: PowerShellIcon,
|
iconSrc: PowerShellIcon,
|
||||||
title: "Mongo Shell",
|
title: "Mongo Shell",
|
||||||
description: "Create a collection and interact with data using MongoDB's shell interface",
|
description: "Create a collection and interact with data using MongoDB's shell interface",
|
||||||
onClick: () => container.openNotebookTerminal(TerminalKind.VCoreMongo),
|
onClick: () => {
|
||||||
|
if (isNativeAuthDisabled) {
|
||||||
|
useDialog.getState().showOkModalDialog(
|
||||||
|
"Native Authentication Disabled",
|
||||||
|
VCoreMongoNativeAuthDisabledMessage,
|
||||||
|
{ linkText: "Learn more", linkUrl: VCoreMongoNativeAuthLearnMoreUrl },
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
container.openNotebookTerminal(TerminalKind.VCoreMongo);
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Spinner, SpinnerSize, Stack, Text } from "@fluentui/react";
|
import { Link, MessageBar, MessageBarType, Spinner, SpinnerSize, Stack, Text } from "@fluentui/react";
|
||||||
import { PoolIdType } from "Common/Constants";
|
import { PoolIdType } from "Common/Constants";
|
||||||
import { NotebookWorkspaceConnectionInfo } from "Contracts/DataModels";
|
import { NotebookWorkspaceConnectionInfo } from "Contracts/DataModels";
|
||||||
import { MessageTypes } from "Contracts/ExplorerContracts";
|
import { MessageTypes } from "Contracts/ExplorerContracts";
|
||||||
@@ -8,7 +8,12 @@ import { useNotebook } from "Explorer/Notebook/useNotebook";
|
|||||||
import { QuickstartFirewallNotification } from "Explorer/Quickstart/QuickstartFirewallNotification";
|
import { QuickstartFirewallNotification } from "Explorer/Quickstart/QuickstartFirewallNotification";
|
||||||
import { VcoreMongoQuickstartGuide } from "Explorer/Quickstart/VCoreMongoQuickstartGuide";
|
import { VcoreMongoQuickstartGuide } from "Explorer/Quickstart/VCoreMongoQuickstartGuide";
|
||||||
import { checkFirewallRules } from "Explorer/Tabs/Shared/CheckFirewallRules";
|
import { checkFirewallRules } from "Explorer/Tabs/Shared/CheckFirewallRules";
|
||||||
import { userContext } from "UserContext";
|
import {
|
||||||
|
isVCoreMongoNativeAuthDisabled,
|
||||||
|
userContext,
|
||||||
|
VCoreMongoNativeAuthDisabledMessage,
|
||||||
|
VCoreMongoNativeAuthLearnMoreUrl,
|
||||||
|
} from "UserContext";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import FirewallRuleScreenshot from "../../../images/vcoreMongoFirewallRule.png";
|
import FirewallRuleScreenshot from "../../../images/vcoreMongoFirewallRule.png";
|
||||||
|
|
||||||
@@ -21,6 +26,7 @@ export const VcoreMongoQuickstartTab: React.FC<VCoreMongoQuickstartTabProps> = (
|
|||||||
}: VCoreMongoQuickstartTabProps): JSX.Element => {
|
}: VCoreMongoQuickstartTabProps): JSX.Element => {
|
||||||
const notebookServerInfo = useNotebook((state) => state.notebookServerInfo);
|
const notebookServerInfo = useNotebook((state) => state.notebookServerInfo);
|
||||||
const [isAllPublicIPAddressEnabled, setIsAllPublicIPAddressEnabled] = useState<boolean>(true);
|
const [isAllPublicIPAddressEnabled, setIsAllPublicIPAddressEnabled] = useState<boolean>(true);
|
||||||
|
const isNativeAuthDisabled = isVCoreMongoNativeAuthDisabled();
|
||||||
|
|
||||||
const getNotebookServerInfo = (): NotebookWorkspaceConnectionInfo => ({
|
const getNotebookServerInfo = (): NotebookWorkspaceConnectionInfo => ({
|
||||||
authToken: notebookServerInfo.authToken,
|
authToken: notebookServerInfo.authToken,
|
||||||
@@ -48,14 +54,26 @@ export const VcoreMongoQuickstartTab: React.FC<VCoreMongoQuickstartTabProps> = (
|
|||||||
<VcoreMongoQuickstartGuide />
|
<VcoreMongoQuickstartGuide />
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack style={{ width: "50%", borderLeft: "black solid 1px" }}>
|
<Stack style={{ width: "50%", borderLeft: "black solid 1px" }}>
|
||||||
{!isAllPublicIPAddressEnabled && (
|
{isNativeAuthDisabled && (
|
||||||
|
<Stack style={{ margin: "auto", padding: 20 }}>
|
||||||
|
<MessageBar messageBarType={MessageBarType.warning} isMultiline={true}>
|
||||||
|
<Text>
|
||||||
|
{VCoreMongoNativeAuthDisabledMessage}{" "}
|
||||||
|
<Link href={VCoreMongoNativeAuthLearnMoreUrl} target="_blank">
|
||||||
|
Learn more
|
||||||
|
</Link>
|
||||||
|
</Text>
|
||||||
|
</MessageBar>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
{!isNativeAuthDisabled && !isAllPublicIPAddressEnabled && (
|
||||||
<QuickstartFirewallNotification
|
<QuickstartFirewallNotification
|
||||||
messageType={MessageTypes.OpenVCoreMongoNetworkingBlade}
|
messageType={MessageTypes.OpenVCoreMongoNetworkingBlade}
|
||||||
screenshot={FirewallRuleScreenshot}
|
screenshot={FirewallRuleScreenshot}
|
||||||
shellName="MongoDB"
|
shellName="MongoDB"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{isAllPublicIPAddressEnabled && notebookServerInfo?.notebookServerEndpoint && (
|
{!isNativeAuthDisabled && isAllPublicIPAddressEnabled && notebookServerInfo?.notebookServerEndpoint && (
|
||||||
<NotebookTerminalComponent
|
<NotebookTerminalComponent
|
||||||
notebookServerInfo={getNotebookServerInfo()}
|
notebookServerInfo={getNotebookServerInfo()}
|
||||||
databaseAccount={userContext.databaseAccount}
|
databaseAccount={userContext.databaseAccount}
|
||||||
@@ -63,7 +81,7 @@ export const VcoreMongoQuickstartTab: React.FC<VCoreMongoQuickstartTabProps> = (
|
|||||||
username={userContext.vcoreMongoConnectionParams.adminLogin}
|
username={userContext.vcoreMongoConnectionParams.adminLogin}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{isAllPublicIPAddressEnabled && !notebookServerInfo?.notebookServerEndpoint && (
|
{!isNativeAuthDisabled && isAllPublicIPAddressEnabled && !notebookServerInfo?.notebookServerEndpoint && (
|
||||||
<Stack style={{ margin: "auto 0" }}>
|
<Stack style={{ margin: "auto 0" }}>
|
||||||
<Text block style={{ margin: "auto" }}>
|
<Text block style={{ margin: "auto" }}>
|
||||||
Connecting to the Mongo shell.
|
Connecting to the Mongo shell.
|
||||||
|
|||||||
@@ -42,10 +42,25 @@ export interface PostgresConnectionStrParams {
|
|||||||
isMarlinServerGroup: boolean;
|
isMarlinServerGroup: boolean;
|
||||||
isFreeTier: boolean;
|
isFreeTier: boolean;
|
||||||
}
|
}
|
||||||
|
export type VCoreMongoAuthMode = "NativeAuth" | "MicrosoftEntraID";
|
||||||
|
|
||||||
|
export interface VCoreMongoAuthConfig {
|
||||||
|
allowedModes?: VCoreMongoAuthMode[];
|
||||||
|
}
|
||||||
|
|
||||||
export interface VCoreMongoConnectionParams {
|
export interface VCoreMongoConnectionParams {
|
||||||
adminLogin: string;
|
adminLogin: string;
|
||||||
connectionString: string;
|
connectionString: string;
|
||||||
|
authConfig?: VCoreMongoAuthConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const VCoreMongoNativeAuthLearnMoreUrl = "https://go.microsoft.com/fwlink/?linkid=2340100";
|
||||||
|
|
||||||
|
export const VCoreMongoNativeAuthDisabledMessage =
|
||||||
|
"Native DocumentDB authentication is disabled on this cluster. You can use MongoDB Shell with Entra ID authentication outside of the Azure portal.";
|
||||||
|
export function isVCoreMongoNativeAuthDisabled(): boolean {
|
||||||
|
const allowedModes = userContext.vcoreMongoConnectionParams?.authConfig?.allowedModes || [];
|
||||||
|
return allowedModes.length > 0 && !allowedModes.includes("NativeAuth");
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FabricArtifactInfo {
|
export interface FabricArtifactInfo {
|
||||||
@@ -212,3 +227,4 @@ export function apiType(account: DatabaseAccount | undefined): ApiType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export { updateUserContext, userContext };
|
export { updateUserContext, userContext };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user