diff --git a/package-lock.json b/package-lock.json index c19696f07..e791e117a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -108,7 +108,7 @@ "zustand": "3.5.0" }, "devDependencies": { - "@babel/core": "7.29.0", + "@babel/core": "7.29.6", "@babel/preset-env": "7.24.7", "@babel/preset-react": "7.24.7", "@babel/preset-typescript": "7.24.7", @@ -171,7 +171,7 @@ "jest-html-loader": "1.0.0", "jest-react-hooks-shallow": "1.5.1", "jest-trx-results-processor": "3.0.2", - "js-yaml": "3.14.2", + "js-yaml": "3.15.0", "less": "4.5.1", "less-loader": "11.1.3", "less-vars-loader": "1.1.0", @@ -195,7 +195,7 @@ "webpack": "5.104.1", "webpack-bundle-analyzer": "5.2.0", "webpack-cli": "5.1.4", - "webpack-dev-server": "5.2.3", + "webpack-dev-server": "5.2.5", "ws": "8.20.1" } }, @@ -622,11 +622,12 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.29.0", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.0.tgz", - "integrity": "sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", + "integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==", + "license": "MIT", "dependencies": { - "@babel/helper-validator-identifier": "^7.28.5", + "@babel/helper-validator-identifier": "^7.29.7", "js-tokens": "^4.0.0", "picocolors": "^1.1.1" }, @@ -643,16 +644,17 @@ } }, "node_modules/@babel/core": { - "version": "7.29.0", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.0.tgz", - "integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==", + "version": "7.29.6", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.6.tgz", + "integrity": "sha512-QdxmAo/ikZqqRGA8s43ww8lcql6naWRvEz0FFrl6MIlc7Gi6TroXnSdWa5U/kq6fzcpqpHesicQxFZIieZbyIA==", + "license": "MIT", "dependencies": { "@babel/code-frame": "^7.29.0", - "@babel/generator": "^7.29.0", + "@babel/generator": "^7.29.6", "@babel/helper-compilation-targets": "^7.28.6", "@babel/helper-module-transforms": "^7.28.6", - "@babel/helpers": "^7.28.6", - "@babel/parser": "^7.29.0", + "@babel/helpers": "^7.29.2", + "@babel/parser": "^7.29.3", "@babel/template": "^7.28.6", "@babel/traverse": "^7.29.0", "@babel/types": "^7.29.0", @@ -685,12 +687,13 @@ } }, "node_modules/@babel/generator": { - "version": "7.29.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.0.tgz", - "integrity": "sha512-vSH118/wwM/pLR38g/Sgk05sNtro6TlTJKuiMXDaZqPUfjTFcudpCOt00IhOfj+1BFAX+UFAlzCU+6WXr3GLFQ==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.7.tgz", + "integrity": "sha512-DkXD5OJQaAQIdZ1bt3UZdEnHAn9Imd3IVBdX03UFe+ony9Ojw5pzr9YVKGDY1jt+Gcn/FnGkNf8r+Vj5NOJWtQ==", + "license": "MIT", "dependencies": { - "@babel/parser": "^7.29.0", - "@babel/types": "^7.29.0", + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7", "@jridgewell/gen-mapping": "^0.3.12", "@jridgewell/trace-mapping": "^0.3.28", "jsesc": "^3.0.2" @@ -924,17 +927,19 @@ } }, "node_modules/@babel/helper-string-parser": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", - "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz", + "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==", + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", - "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", + "license": "MIT", "engines": { "node": ">=6.9.0" } @@ -962,23 +967,25 @@ } }, "node_modules/@babel/helpers": { - "version": "7.28.6", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.28.6.tgz", - "integrity": "sha512-xOBvwq86HHdB7WUDTfKfT/Vuxh7gElQ+Sfti2Cy6yIWNW05P8iUslOVcZ4/sKbE+/jQaukQAdz/gf3724kYdqw==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.7.tgz", + "integrity": "sha512-1k2lAGRMfHTcwuNYcCNUmaUffmQv8KWMfh2iJUUeRlwlwH4FdNG7mfPI10NPfLHJFThE4Tyr4mv7kTNZOiPuBg==", + "license": "MIT", "dependencies": { - "@babel/template": "^7.28.6", - "@babel/types": "^7.28.6" + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.7" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/parser": { - "version": "7.29.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.0.tgz", - "integrity": "sha512-IyDgFV5GeDUVX4YdF/3CPULtVGSXXMLh1xVIgdCgxApktqnQV0r7/8Nqthg+8YLGaAtdyIlo2qIdZrbCv4+7ww==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.7.tgz", + "integrity": "sha512-hnORnjP/1P/zFEndoeX+n+t1RwWRJiJpM/jO7FW32Kn9r5+sJB2JWOdYo4L6k78j15eCwY3Gm/7364B1EMwtNg==", + "license": "MIT", "dependencies": { - "@babel/types": "^7.29.0" + "@babel/types": "^7.29.7" }, "bin": { "parser": "bin/babel-parser.js" @@ -2458,13 +2465,14 @@ } }, "node_modules/@babel/template": { - "version": "7.28.6", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.28.6.tgz", - "integrity": "sha512-YA6Ma2KsCdGb+WC6UpBVFJGXL58MDA6oyONbjyF/+5sBgxY/dwkhLogbMT2GXXyU84/IhRw/2D1Os1B/giz+BQ==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz", + "integrity": "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==", + "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.28.6", - "@babel/parser": "^7.28.6", - "@babel/types": "^7.28.6" + "@babel/code-frame": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7" }, "engines": { "node": ">=6.9.0" @@ -2488,12 +2496,13 @@ } }, "node_modules/@babel/types": { - "version": "7.29.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.0.tgz", - "integrity": "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.7.tgz", + "integrity": "sha512-4zBIxpPzowiZpusoFkyGVwakdRJUyuH5PxQ/PrqghfdFWWasvnCdPfQXHrenDai+gyLARulZjZowCOj6fjT4pA==", + "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.27.1", - "@babel/helper-validator-identifier": "^7.28.5" + "@babel/helper-string-parser": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7" }, "engines": { "node": ">=6.9.0" @@ -20655,10 +20664,11 @@ "license": "MIT" }, "node_modules/js-yaml": { - "version": "3.14.2", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.2.tgz", - "integrity": "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==", + "version": "3.15.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.15.0.tgz", + "integrity": "sha512-ttBQIIQPDeLjpPOohtUdXuXUVoA2uIB6fEH9HyJ7234s5mBJ5wTx20njxplLZQgLaOfpmPQA7X2t5AX6tIPbog==", "devOptional": true, + "license": "MIT", "dependencies": { "argparse": "^1.0.7", "esprima": "^4.0.0" @@ -20984,10 +20994,21 @@ "license": "MIT" }, "node_modules/linkify-it": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", - "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.2.tgz", + "integrity": "sha512-ONTm2jCMAVZjgQa/Fy1kScXsuOoF5NPTsoFBdE1KVIZ2vAh/r9+Bqo+0jINCBYnavTPQZz38QzFTme79ENoN3Q==", "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/markdown-it" + } + ], + "license": "MIT", "dependencies": { "uc.micro": "^2.0.0" } @@ -21223,14 +21244,25 @@ } }, "node_modules/markdown-it": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", - "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", + "version": "14.3.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.3.0.tgz", + "integrity": "sha512-RCEsPjR+sr0x+AuYp601tKTkgFG4YEPLCzHST3cQ/fhlJkqAkz1L2/Qbp1j9qw5SBwQHFBoW8+hoN5xssOF0Tw==", "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/markdown-it" + } + ], + "license": "MIT", "dependencies": { "argparse": "^2.0.1", - "entities": "^4.4.0", - "linkify-it": "^5.0.0", + "entities": "^4.5.0", + "linkify-it": "^5.0.2", "mdurl": "^2.0.0", "punycode.js": "^2.3.1", "uc.micro": "^2.1.0" @@ -25831,7 +25863,8 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/uglify-js": { "version": "3.4.10", @@ -27156,10 +27189,11 @@ "dev": true }, "node_modules/webpack-dev-server": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/webpack-dev-server/-/webpack-dev-server-5.2.3.tgz", - "integrity": "sha512-9Gyu2F7+bg4Vv+pjbovuYDhHX+mqdqITykfzdM9UyKqKHlsE5aAjRhR+oOEfXW5vBeu8tarzlJFIZva4ZjAdrQ==", + "version": "5.2.5", + "resolved": "https://registry.npmjs.org/webpack-dev-server/-/webpack-dev-server-5.2.5.tgz", + "integrity": "sha512-4wZtCquSuv9CKX8oybo+mqxtxZqWz47uM1Ch94lxowBztOhWCbhqvRbfC/mODOwxgV2brY+JGZpHq58/SuVFYg==", "dev": true, + "license": "MIT", "dependencies": { "@types/bonjour": "^3.5.13", "@types/connect-history-api-fallback": "^1.5.4", diff --git a/package.json b/package.json index f90908e6c..a178123f8 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,7 @@ "@types/react-redux": "7.1.7" }, "devDependencies": { - "@babel/core": "7.29.0", + "@babel/core": "7.29.6", "@babel/preset-env": "7.24.7", "@babel/preset-react": "7.24.7", "@babel/preset-typescript": "7.24.7", @@ -181,7 +181,7 @@ "jest-html-loader": "1.0.0", "jest-react-hooks-shallow": "1.5.1", "jest-trx-results-processor": "3.0.2", - "js-yaml": "3.14.2", + "js-yaml": "3.15.0", "less": "4.5.1", "less-loader": "11.1.3", "less-vars-loader": "1.1.0", @@ -205,7 +205,7 @@ "webpack": "5.104.1", "webpack-bundle-analyzer": "5.2.0", "webpack-cli": "5.1.4", - "webpack-dev-server": "5.2.3", + "webpack-dev-server": "5.2.5", "ws": "8.20.1" }, "scripts": { diff --git a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx index 8ab643e3a..25ed4ea4f 100644 --- a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx +++ b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx @@ -19,10 +19,16 @@ import { AuthType } from "../../../AuthType"; import * as Constants from "../../../Common/Constants"; import { Platform, configContext } from "../../../ConfigContext"; import * as ViewModels from "../../../Contracts/ViewModels"; -import { userContext } from "../../../UserContext"; +import { + userContext, + isVCoreMongoNativeAuthDisabled, + VCoreMongoNativeAuthDisabledMessage, + VCoreMongoNativeAuthLearnMoreUrl, +} from "../../../UserContext"; import { isRunningOnNationalCloud } from "../../../Utils/CloudUtils"; import { useSidePanel } from "../../../hooks/useSidePanel"; import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent"; +import { useDialog } from "../../Controls/Dialog"; import Explorer from "../../Explorer"; import { useNotebook } from "../../Notebook/useNotebook"; import { BrowseQueriesPane } from "../../Panes/BrowseQueriesPane/BrowseQueriesPane"; @@ -499,12 +505,21 @@ function createOpenTerminalButtonByKind( const label = `Open ${terminalFriendlyName()} shell`; const tooltip = "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 = - !useNotebook.getState().isNotebooksEnabledForAccount && !useNotebook.getState().isNotebookEnabled; + (!useNotebook.getState().isNotebooksEnabledForAccount && !useNotebook.getState().isNotebookEnabled) || + isNativeAuthDisabled; return { iconSrc: HostedTerminalIcon, iconAlt: label, onCommandClick: () => { + if (isNativeAuthDisabled) { + useDialog.getState().showOkModalDialog("Native Authentication Disabled", VCoreMongoNativeAuthDisabledMessage, { + linkText: "Learn more", + linkUrl: VCoreMongoNativeAuthLearnMoreUrl, + }); + return; + } if (useNotebook.getState().isNotebookEnabled || userContext.features.enableCloudShell) { container.openNotebookTerminal(terminalKind); } @@ -513,7 +528,7 @@ function createOpenTerminalButtonByKind( hasPopup: false, disabled: disableButton, ariaLabel: label, - tooltipText: !disableButton ? "" : tooltip, + tooltipText: isNativeAuthDisabled ? VCoreMongoNativeAuthDisabledMessage : !disableButton ? "" : tooltip, }; } diff --git a/src/Explorer/Quickstart/VCoreMongoQuickstartGuide.tsx b/src/Explorer/Quickstart/VCoreMongoQuickstartGuide.tsx index fa40d8e4c..c0c9d60ca 100644 --- a/src/Explorer/Quickstart/VCoreMongoQuickstartGuide.tsx +++ b/src/Explorer/Quickstart/VCoreMongoQuickstartGuide.tsx @@ -296,10 +296,7 @@ export const VcoreMongoQuickstartGuide: React.FC = (): JSX.Element => {
Modernize your data seamlessly from an existing MongoDB cluster, whether it's on-premises or hosted in the cloud, to Azure DocumentDB.  - + Learn more diff --git a/src/Explorer/SplashScreen/SplashScreen.tsx b/src/Explorer/SplashScreen/SplashScreen.tsx index 1c2e9550e..aeb599f67 100644 --- a/src/Explorer/SplashScreen/SplashScreen.tsx +++ b/src/Explorer/SplashScreen/SplashScreen.tsx @@ -33,8 +33,14 @@ import QuickStartIcon from "../../../images/Quickstart_Lightning.svg"; import VisualStudioIcon from "../../../images/VisualStudio.svg"; import CollectionIcon from "../../../images/tree-collection.svg"; import * as Constants from "../../Common/Constants"; -import { userContext } from "../../UserContext"; +import { + isVCoreMongoNativeAuthDisabled, + userContext, + VCoreMongoNativeAuthDisabledMessage, + VCoreMongoNativeAuthLearnMoreUrl, +} from "../../UserContext"; import { getCollectionName } from "../../Utils/APITypeUtils"; +import { useDialog } from "../Controls/Dialog"; import Explorer from "../Explorer"; import * as MostRecentActivity from "../MostRecentActivity/MostRecentActivity"; import { useNotebook } from "../Notebook/useNotebook"; @@ -413,11 +419,23 @@ export const SplashScreen: React.FC = ({ explorer }) => { } if (userContext.apiType === "VCoreMongo") { + const isNativeAuthDisabled = isVCoreMongoNativeAuthDisabled(); return { iconSrc: PowerShellIcon, title: t(Keys.splashScreen.shell.vcoreMongo.title), description: t(Keys.splashScreen.shell.vcoreMongo.description), - 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); + } + }, }; } @@ -791,7 +809,7 @@ export const SplashScreen: React.FC = ({ explorer }) => { const vcoreMongoNextStepItems: { link: string; title: string; description: string }[] = [ { - link: "https://learn.microsoft.com/azure/cosmos-db/mongodb/vcore/migration-options", + link: "https://learn.microsoft.com/azure/documentdb/migration-options", title: t(Keys.splashScreen.nextStepItems.vcoreMongo.migrateData), description: "", }, diff --git a/src/Explorer/Tabs/VCoreMongoQuickstartTab.tsx b/src/Explorer/Tabs/VCoreMongoQuickstartTab.tsx index 6cbcb856a..72c38e15b 100644 --- a/src/Explorer/Tabs/VCoreMongoQuickstartTab.tsx +++ b/src/Explorer/Tabs/VCoreMongoQuickstartTab.tsx @@ -1,24 +1,44 @@ -import { Stack } from "@fluentui/react"; +import { Link, MessageBar, MessageBarType, Stack, Text } from "@fluentui/react"; import { TerminalKind } from "Contracts/ViewModels"; import { VcoreMongoQuickstartGuide } from "Explorer/Quickstart/VCoreMongoQuickstartGuide"; import { CloudShellTerminalComponent } from "Explorer/Tabs/CloudShellTab/CloudShellTerminalComponent"; -import { userContext } from "UserContext"; +import { + isVCoreMongoNativeAuthDisabled, + userContext, + VCoreMongoNativeAuthDisabledMessage, + VCoreMongoNativeAuthLearnMoreUrl, +} from "UserContext"; import React from "react"; export const VcoreMongoQuickstartTab: React.FC = (): JSX.Element => { + const isNativeAuthDisabled = isVCoreMongoNativeAuthDisabled(); + return ( - + {isNativeAuthDisabled ? ( + + + + {VCoreMongoNativeAuthDisabledMessage}{" "} + + Learn more + + + + + ) : ( + + )} ); diff --git a/src/Platform/Hosted/extractFeatures.ts b/src/Platform/Hosted/extractFeatures.ts index ee1855818..88aaac1ca 100644 --- a/src/Platform/Hosted/extractFeatures.ts +++ b/src/Platform/Hosted/extractFeatures.ts @@ -36,6 +36,7 @@ export type Features = { readonly enableContainerCopy: boolean; readonly enableCloudShell: boolean; readonly enableRestoreContainer: boolean; // only for Fabric + readonly mongoDisableNativeAuth: boolean; // can be set via both flight and feature flag autoscaleDefault: boolean; @@ -103,6 +104,7 @@ export function extractFeatures(given = new URLSearchParams(window.location.sear enableContainerCopy: "true" === get("enablecontainercopy"), enableRestoreContainer: "true" === get("enablerestorecontainer"), enableCloudShell: true, + mongoDisableNativeAuth: "true" === get("mongodisablenativeauth"), }; } diff --git a/src/UserContext.ts b/src/UserContext.ts index 5c83341fd..036ed322e 100644 --- a/src/UserContext.ts +++ b/src/UserContext.ts @@ -42,9 +42,37 @@ export interface PostgresConnectionStrParams { isFreeTier: boolean; } +export type VCoreMongoAuthMode = "NativeAuth" | "MicrosoftEntraID"; + +export interface VCoreMongoAuthConfig { + allowedModes?: VCoreMongoAuthMode[]; +} + export interface VCoreMongoConnectionParams { adminLogin: string; connectionString: string; + authConfig?: VCoreMongoAuthConfig; + isNativeAuthDisabled?: boolean; +} + +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 { + if (userContext.features?.mongoDisableNativeAuth) { + return true; + } + const params = userContext.vcoreMongoConnectionParams; + if (!params) { + return false; + } + if (params.isNativeAuthDisabled) { + return true; + } + const allowedModes = params.authConfig?.allowedModes || []; + return allowedModes.length > 0 && !allowedModes.includes("NativeAuth"); } export interface FabricArtifactInfo { diff --git a/src/Utils/AuthorizationUtils.test.ts b/src/Utils/AuthorizationUtils.test.ts index 6eb5f761f..68d448ba7 100644 --- a/src/Utils/AuthorizationUtils.test.ts +++ b/src/Utils/AuthorizationUtils.test.ts @@ -48,6 +48,7 @@ describe("AuthorizationUtils", () => { partitionKeyDefault2: false, notebooksDownBanner: false, enableRestoreContainer: false, + mongoDisableNativeAuth: false, }, }); };