mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 15:06:55 +00:00
Resolved merge conflict
This commit is contained in:
commit
0079a9147f
9
images/EntraID.svg
Normal file
9
images/EntraID.svg
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg id="uuid-f8d4d392-7c12-4bd9-baff-66fbf7814b91" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18">
|
||||||
|
<path d="m3.802,14.032c.388.242,1.033.511,1.715.511.621,0,1.198-.18,1.676-.487,0,0,.001,0,.002-.001l1.805-1.128v4.073c-.286,0-.574-.078-.824-.234l-4.374-2.734Z" fill="#225086"/>
|
||||||
|
<path d="m7.853,1.507L.353,9.967c-.579.654-.428,1.642.323,2.111,0,0,2.776,1.735,3.126,1.954.388.242,1.033.511,1.715.511.621,0,1.198-.18,1.676-.487,0,0,.001,0,.002-.001l1.805-1.128-4.364-2.728,4.365-4.924V1s0,0,0,0c-.424,0-.847.169-1.147.507Z" fill="#6df"/>
|
||||||
|
<polygon points="4.636 10.199 4.688 10.231 9 12.927 9.001 12.927 9.001 12.927 9.001 5.276 9 5.275 4.636 10.199" fill="#cbf8ff"/>
|
||||||
|
<path d="m17.324,12.078c.751-.469.902-1.457.323-2.111l-4.921-5.551c-.397-.185-.842-.291-1.313-.291-.925,0-1.752.399-2.302,1.026l-.109.123h0s4.364,4.924,4.364,4.924h0s0,0,0,0l-4.365,2.728v4.073c.287,0,.573-.078.823-.234l7.5-4.688Z" fill="#074793"/>
|
||||||
|
<path d="m9.001,1v4.275s.109-.123.109-.123c.55-.627,1.377-1.026,2.302-1.026.472,0,.916.107,1.313.291l-2.579-2.909c-.299-.338-.723-.507-1.146-.507Z" fill="#0294e4"/>
|
||||||
|
<polygon points="13.365 10.199 13.365 10.199 13.365 10.199 9.001 5.276 9.001 12.926 13.365 10.199" fill="#96bcc2"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.3 KiB |
@ -28,19 +28,6 @@ describe("tokenProvider", () => {
|
|||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.restoreAllMocks();
|
jest.restoreAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("calls the auth token service if no master key is set", async () => {
|
|
||||||
await tokenProvider(options);
|
|
||||||
expect((window.fetch as any).mock.calls.length).toBe(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("does not call the auth service if a master key is set", async () => {
|
|
||||||
updateUserContext({
|
|
||||||
masterKey: "foo",
|
|
||||||
});
|
|
||||||
await tokenProvider(options);
|
|
||||||
expect((window.fetch as any).mock.calls.length).toBe(0);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("getTokenFromAuthService", () => {
|
describe("getTokenFromAuthService", () => {
|
||||||
|
@ -3,10 +3,12 @@ import { getAuthorizationTokenUsingResourceTokens } from "Common/getAuthorizatio
|
|||||||
import { AuthorizationToken } from "Contracts/FabricMessageTypes";
|
import { AuthorizationToken } from "Contracts/FabricMessageTypes";
|
||||||
import { checkDatabaseResourceTokensValidity } from "Platform/Fabric/FabricUtil";
|
import { checkDatabaseResourceTokensValidity } from "Platform/Fabric/FabricUtil";
|
||||||
import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility";
|
import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility";
|
||||||
|
import { listKeys } from "Utils/arm/generatedClients/cosmos/databaseAccounts";
|
||||||
|
import { DatabaseAccountListKeysResult } from "Utils/arm/generatedClients/cosmos/types";
|
||||||
import { AuthType } from "../AuthType";
|
import { AuthType } from "../AuthType";
|
||||||
import { PriorityLevel } from "../Common/Constants";
|
import { PriorityLevel } from "../Common/Constants";
|
||||||
import { Platform, configContext } from "../ConfigContext";
|
import { Platform, configContext } from "../ConfigContext";
|
||||||
import { userContext } from "../UserContext";
|
import { updateUserContext, userContext } from "../UserContext";
|
||||||
import { logConsoleError } from "../Utils/NotificationConsoleUtils";
|
import { logConsoleError } from "../Utils/NotificationConsoleUtils";
|
||||||
import * as PriorityBasedExecutionUtils from "../Utils/PriorityBasedExecutionUtils";
|
import * as PriorityBasedExecutionUtils from "../Utils/PriorityBasedExecutionUtils";
|
||||||
import { EmulatorMasterKey, HttpHeaders } from "./Constants";
|
import { EmulatorMasterKey, HttpHeaders } from "./Constants";
|
||||||
@ -17,9 +19,16 @@ const _global = typeof self === "undefined" ? window : self;
|
|||||||
export const tokenProvider = async (requestInfo: Cosmos.RequestInfo) => {
|
export const tokenProvider = async (requestInfo: Cosmos.RequestInfo) => {
|
||||||
const { verb, resourceId, resourceType, headers } = requestInfo;
|
const { verb, resourceId, resourceType, headers } = requestInfo;
|
||||||
|
|
||||||
console.log(`AAD Data Plane RBAC enabled "${userContext.dataPlaneRbacEnabled}" `);
|
const aadDataPlaneFeatureEnabled =
|
||||||
if ((userContext.features.enableAadDataPlane || userContext.dataPlaneRbacEnabled) && userContext.aadToken) {
|
userContext.features.enableAadDataPlane && userContext.databaseAccount.properties.disableLocalAuth;
|
||||||
console.log(` Getting Auth token `);
|
const dataPlaneRBACOptionEnabled = userContext.dataPlaneRbacEnabled && userContext.apiType === "SQL";
|
||||||
|
if (aadDataPlaneFeatureEnabled || (!userContext.features.enableAadDataPlane && dataPlaneRBACOptionEnabled)) {
|
||||||
|
if (!userContext.aadToken) {
|
||||||
|
logConsoleError(
|
||||||
|
`AAD token does not exist. Please use "Login for Entra ID" prior to performing Entra ID RBAC operations`,
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
const AUTH_PREFIX = `type=aad&ver=1.0&sig=`;
|
const AUTH_PREFIX = `type=aad&ver=1.0&sig=`;
|
||||||
const authorizationToken = `${AUTH_PREFIX}${userContext.aadToken}`;
|
const authorizationToken = `${AUTH_PREFIX}${userContext.aadToken}`;
|
||||||
console.log(`Returning Auth token`);
|
console.log(`Returning Auth token`);
|
||||||
@ -83,8 +92,30 @@ export const tokenProvider = async (requestInfo: Cosmos.RequestInfo) => {
|
|||||||
|
|
||||||
if (userContext.masterKey) {
|
if (userContext.masterKey) {
|
||||||
// TODO This SDK method mutates the headers object. Find a better one or fix the SDK.
|
// TODO This SDK method mutates the headers object. Find a better one or fix the SDK.
|
||||||
await Cosmos.setAuthorizationTokenHeaderUsingMasterKey(verb, resourceId, resourceType, headers, EmulatorMasterKey);
|
await Cosmos.setAuthorizationTokenHeaderUsingMasterKey(
|
||||||
|
verb,
|
||||||
|
resourceId,
|
||||||
|
resourceType,
|
||||||
|
headers,
|
||||||
|
userContext.masterKey,
|
||||||
|
);
|
||||||
return decodeURIComponent(headers.authorization);
|
return decodeURIComponent(headers.authorization);
|
||||||
|
} else if (userContext.dataPlaneRbacEnabled == false) {
|
||||||
|
const { databaseAccount: account, subscriptionId, resourceGroup } = userContext;
|
||||||
|
const keys: DatabaseAccountListKeysResult = await listKeys(subscriptionId, resourceGroup, account.name);
|
||||||
|
|
||||||
|
if (keys.primaryMasterKey) {
|
||||||
|
updateUserContext({ masterKey: keys.primaryMasterKey });
|
||||||
|
// TODO This SDK method mutates the headers object. Find a better one or fix the SDK.
|
||||||
|
await Cosmos.setAuthorizationTokenHeaderUsingMasterKey(
|
||||||
|
verb,
|
||||||
|
resourceId,
|
||||||
|
resourceType,
|
||||||
|
headers,
|
||||||
|
keys.primaryMasterKey,
|
||||||
|
);
|
||||||
|
return decodeURIComponent(headers.authorization);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userContext.resourceToken) {
|
if (userContext.resourceToken) {
|
||||||
@ -168,7 +199,6 @@ export function client(): Cosmos.CosmosClient {
|
|||||||
|
|
||||||
const options: Cosmos.CosmosClientOptions = {
|
const options: Cosmos.CosmosClientOptions = {
|
||||||
endpoint: endpoint() || "https://cosmos.azure.com", // CosmosClient gets upset if we pass a bad URL. This should never actually get called
|
endpoint: endpoint() || "https://cosmos.azure.com", // CosmosClient gets upset if we pass a bad URL. This should never actually get called
|
||||||
key: userContext.masterKey,
|
|
||||||
tokenProvider,
|
tokenProvider,
|
||||||
userAgentSuffix: "Azure Portal",
|
userAgentSuffix: "Azure Portal",
|
||||||
defaultHeaders: _defaultHeaders,
|
defaultHeaders: _defaultHeaders,
|
||||||
|
@ -109,14 +109,14 @@ let configContext: Readonly<ConfigContext> = {
|
|||||||
PORTAL_BACKEND_ENDPOINT: PortalBackendEndpoints.Prod,
|
PORTAL_BACKEND_ENDPOINT: PortalBackendEndpoints.Prod,
|
||||||
MONGO_PROXY_ENDPOINT: MongoProxyEndpoints.Prod,
|
MONGO_PROXY_ENDPOINT: MongoProxyEndpoints.Prod,
|
||||||
NEW_MONGO_APIS: [
|
NEW_MONGO_APIS: [
|
||||||
"resourcelist",
|
// "resourcelist",
|
||||||
"queryDocuments",
|
// "queryDocuments",
|
||||||
"createDocument",
|
// "createDocument",
|
||||||
"readDocument",
|
// "readDocument",
|
||||||
"updateDocument",
|
// "updateDocument",
|
||||||
"deleteDocument",
|
// "deleteDocument",
|
||||||
"createCollectionWithProxy",
|
// "createCollectionWithProxy",
|
||||||
"legacyMongoShell",
|
// "legacyMongoShell",
|
||||||
],
|
],
|
||||||
MONGO_PROXY_OUTBOUND_IPS_ALLOWLISTED: false,
|
MONGO_PROXY_OUTBOUND_IPS_ALLOWLISTED: false,
|
||||||
CASSANDRA_PROXY_ENDPOINT: CassandraProxyEndpoints.Prod,
|
CASSANDRA_PROXY_ENDPOINT: CassandraProxyEndpoints.Prod,
|
||||||
|
@ -7,11 +7,13 @@ import { getCopilotEnabled, isCopilotFeatureRegistered } from "Explorer/QueryCop
|
|||||||
import { IGalleryItem } from "Juno/JunoClient";
|
import { IGalleryItem } from "Juno/JunoClient";
|
||||||
import { scheduleRefreshDatabaseResourceToken } from "Platform/Fabric/FabricUtil";
|
import { scheduleRefreshDatabaseResourceToken } from "Platform/Fabric/FabricUtil";
|
||||||
import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility";
|
import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility";
|
||||||
|
import { acquireTokenWithMsal, getMsalInstance } from "Utils/AuthorizationUtils";
|
||||||
import { allowedNotebookServerUrls, validateEndpoint } from "Utils/EndpointUtils";
|
import { allowedNotebookServerUrls, validateEndpoint } from "Utils/EndpointUtils";
|
||||||
import { useQueryCopilot } from "hooks/useQueryCopilot";
|
import { useQueryCopilot } from "hooks/useQueryCopilot";
|
||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import _ from "underscore";
|
import _ from "underscore";
|
||||||
|
import * as msal from "@azure/msal-browser";
|
||||||
import shallow from "zustand/shallow";
|
import shallow from "zustand/shallow";
|
||||||
import { AuthType } from "../AuthType";
|
import { AuthType } from "../AuthType";
|
||||||
import { BindingHandlersRegisterer } from "../Bindings/BindingHandlersRegisterer";
|
import { BindingHandlersRegisterer } from "../Bindings/BindingHandlersRegisterer";
|
||||||
@ -30,14 +32,13 @@ import { PhoenixClient } from "../Phoenix/PhoenixClient";
|
|||||||
import * as ExplorerSettings from "../Shared/ExplorerSettings";
|
import * as ExplorerSettings from "../Shared/ExplorerSettings";
|
||||||
import { Action, ActionModifiers } from "../Shared/Telemetry/TelemetryConstants";
|
import { Action, ActionModifiers } from "../Shared/Telemetry/TelemetryConstants";
|
||||||
import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor";
|
import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor";
|
||||||
import { isAccountNewerThanThresholdInMs, userContext } from "../UserContext";
|
import { isAccountNewerThanThresholdInMs, updateUserContext, userContext } from "../UserContext";
|
||||||
import { getCollectionName, getUploadName } from "../Utils/APITypeUtils";
|
import { getCollectionName, getUploadName } from "../Utils/APITypeUtils";
|
||||||
import { stringToBlob } from "../Utils/BlobUtils";
|
import { stringToBlob } from "../Utils/BlobUtils";
|
||||||
import { isCapabilityEnabled } from "../Utils/CapabilityUtils";
|
import { isCapabilityEnabled } from "../Utils/CapabilityUtils";
|
||||||
import { fromContentUri, toRawContentUri } from "../Utils/GitHubUtils";
|
import { fromContentUri, toRawContentUri } from "../Utils/GitHubUtils";
|
||||||
import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils";
|
import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils";
|
||||||
import { logConsoleError, logConsoleInfo, logConsoleProgress } from "../Utils/NotificationConsoleUtils";
|
import { logConsoleError, logConsoleInfo, logConsoleProgress } from "../Utils/NotificationConsoleUtils";
|
||||||
import { update } from "../Utils/arm/generatedClients/cosmos/databaseAccounts";
|
|
||||||
import { useSidePanel } from "../hooks/useSidePanel";
|
import { useSidePanel } from "../hooks/useSidePanel";
|
||||||
import { useTabs } from "../hooks/useTabs";
|
import { useTabs } from "../hooks/useTabs";
|
||||||
import "./ComponentRegisterer";
|
import "./ComponentRegisterer";
|
||||||
@ -66,6 +67,8 @@ import { ResourceTreeAdapter } from "./Tree/ResourceTreeAdapter";
|
|||||||
import StoredProcedure from "./Tree/StoredProcedure";
|
import StoredProcedure from "./Tree/StoredProcedure";
|
||||||
import { useDatabases } from "./useDatabases";
|
import { useDatabases } from "./useDatabases";
|
||||||
import { useSelectedNode } from "./useSelectedNode";
|
import { useSelectedNode } from "./useSelectedNode";
|
||||||
|
import { update } from "Utils/arm/generatedClients/cosmos/databaseAccounts";
|
||||||
|
import { useDataPlaneRbac } from "Explorer/Panes/SettingsPane/SettingsPane";
|
||||||
|
|
||||||
BindingHandlersRegisterer.registerBindingHandlers();
|
BindingHandlersRegisterer.registerBindingHandlers();
|
||||||
|
|
||||||
@ -251,8 +254,44 @@ export default class Explorer {
|
|||||||
};
|
};
|
||||||
useDialog.getState().openDialog(addSynapseLinkDialogProps);
|
useDialog.getState().openDialog(addSynapseLinkDialogProps);
|
||||||
TelemetryProcessor.traceStart(Action.EnableAzureSynapseLink);
|
TelemetryProcessor.traceStart(Action.EnableAzureSynapseLink);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: return result
|
public async openLoginForEntraIDPopUp(): Promise<void> {
|
||||||
|
if (userContext.databaseAccount.properties?.documentEndpoint) {
|
||||||
|
const hrefEndpoint = new URL(userContext.databaseAccount.properties.documentEndpoint).href.replace(
|
||||||
|
/\/$/,
|
||||||
|
"/.default",
|
||||||
|
);
|
||||||
|
const msalInstance = await getMsalInstance();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await msalInstance.loginPopup({
|
||||||
|
redirectUri: configContext.msalRedirectURI,
|
||||||
|
scopes: [],
|
||||||
|
});
|
||||||
|
localStorage.setItem("cachedTenantId", response.tenantId);
|
||||||
|
const cachedAccount = msalInstance.getAllAccounts()?.[0];
|
||||||
|
msalInstance.setActiveAccount(cachedAccount);
|
||||||
|
const aadToken = await acquireTokenWithMsal(msalInstance, {
|
||||||
|
forceRefresh: true,
|
||||||
|
scopes: [hrefEndpoint],
|
||||||
|
authority: `${configContext.AAD_ENDPOINT}${localStorage.getItem("cachedTenantId")}`,
|
||||||
|
});
|
||||||
|
updateUserContext({ aadToken: aadToken });
|
||||||
|
useDataPlaneRbac.setState({ aadTokenUpdated: true });
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof msal.AuthError && error.errorCode === msal.BrowserAuthErrorMessage.popUpWindowError.code) {
|
||||||
|
logConsoleError(
|
||||||
|
"We were unable to establish authorization for this account, due to pop-ups being disabled in the browser.\nPlease enable pop-ups for this site and try again",
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const errorJson = JSON.stringify(error);
|
||||||
|
logConsoleError(
|
||||||
|
`Failed to perform authorization for this account, due to the following error: \n${errorJson}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public openNPSSurveyDialog(): void {
|
public openNPSSurveyDialog(): void {
|
||||||
|
@ -15,6 +15,7 @@ import OpenQueryFromDiskIcon from "../../../../images/OpenQueryFromDisk.svg";
|
|||||||
import OpenInTabIcon from "../../../../images/open-in-tab.svg";
|
import OpenInTabIcon from "../../../../images/open-in-tab.svg";
|
||||||
import SettingsIcon from "../../../../images/settings_15x15.svg";
|
import SettingsIcon from "../../../../images/settings_15x15.svg";
|
||||||
import SynapseIcon from "../../../../images/synapse-link.svg";
|
import SynapseIcon from "../../../../images/synapse-link.svg";
|
||||||
|
import EntraIDIcon from "../../../../images/EntraID.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 { Platform, configContext } from "../../../ConfigContext";
|
||||||
@ -30,9 +31,10 @@ import { OpenFullScreen } from "../../OpenFullScreen";
|
|||||||
import { AddDatabasePanel } from "../../Panes/AddDatabasePanel/AddDatabasePanel";
|
import { AddDatabasePanel } from "../../Panes/AddDatabasePanel/AddDatabasePanel";
|
||||||
import { BrowseQueriesPane } from "../../Panes/BrowseQueriesPane/BrowseQueriesPane";
|
import { BrowseQueriesPane } from "../../Panes/BrowseQueriesPane/BrowseQueriesPane";
|
||||||
import { LoadQueryPane } from "../../Panes/LoadQueryPane/LoadQueryPane";
|
import { LoadQueryPane } from "../../Panes/LoadQueryPane/LoadQueryPane";
|
||||||
import { SettingsPane } from "../../Panes/SettingsPane/SettingsPane";
|
import { SettingsPane, useDataPlaneRbac } from "../../Panes/SettingsPane/SettingsPane";
|
||||||
import { useDatabases } from "../../useDatabases";
|
import { useDatabases } from "../../useDatabases";
|
||||||
import { SelectedNodeState, useSelectedNode } from "../../useSelectedNode";
|
import { SelectedNodeState, useSelectedNode } from "../../useSelectedNode";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
|
|
||||||
@ -69,6 +71,22 @@ export function createStaticCommandBarButtons(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (userContext.apiType === "SQL") {
|
||||||
|
const [loginButtonProps, setLoginButtonProps] = useState<CommandButtonComponentProps | undefined>(undefined);
|
||||||
|
const dataPlaneRbacEnabled = useDataPlaneRbac((state) => state.dataPlaneRbacEnabled);
|
||||||
|
const aadTokenUpdated = useDataPlaneRbac((state) => state.aadTokenUpdated);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const buttonProps = createLoginForEntraIDButton(container);
|
||||||
|
setLoginButtonProps(buttonProps);
|
||||||
|
}, [dataPlaneRbacEnabled, aadTokenUpdated, container]);
|
||||||
|
|
||||||
|
if (loginButtonProps) {
|
||||||
|
addDivider();
|
||||||
|
buttons.push(loginButtonProps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (userContext.apiType !== "Tables") {
|
if (userContext.apiType !== "Tables") {
|
||||||
newCollectionBtn.children = [createNewCollectionGroup(container)];
|
newCollectionBtn.children = [createNewCollectionGroup(container)];
|
||||||
const newDatabaseBtn = createNewDatabase(container);
|
const newDatabaseBtn = createNewDatabase(container);
|
||||||
@ -275,6 +293,31 @@ function createOpenSynapseLinkDialogButton(container: Explorer): CommandButtonCo
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createLoginForEntraIDButton(container: Explorer): CommandButtonComponentProps {
|
||||||
|
if (configContext.platform !== Platform.Portal) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleCommandClick = async () => {
|
||||||
|
await container.openLoginForEntraIDPopUp();
|
||||||
|
useDataPlaneRbac.setState({ dataPlaneRbacEnabled: true });
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!userContext.dataPlaneRbacEnabled || userContext.aadToken) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const label = "Login for Entra ID RBAC";
|
||||||
|
return {
|
||||||
|
iconSrc: EntraIDIcon,
|
||||||
|
iconAlt: label,
|
||||||
|
onCommandClick: handleCommandClick,
|
||||||
|
commandButtonLabel: label,
|
||||||
|
hasPopup: true,
|
||||||
|
ariaLabel: label,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function createNewDatabase(container: Explorer): CommandButtonComponentProps {
|
function createNewDatabase(container: Explorer): CommandButtonComponentProps {
|
||||||
const label = "New " + getDatabaseName();
|
const label = "New " + getDatabaseName();
|
||||||
return {
|
return {
|
||||||
|
@ -4,14 +4,18 @@ import {
|
|||||||
IChoiceGroupOption,
|
IChoiceGroupOption,
|
||||||
ISpinButtonStyles,
|
ISpinButtonStyles,
|
||||||
IToggleStyles,
|
IToggleStyles,
|
||||||
|
Icon,
|
||||||
|
MessageBar,
|
||||||
|
MessageBarType,
|
||||||
Position,
|
Position,
|
||||||
SpinButton,
|
SpinButton,
|
||||||
Toggle,
|
Toggle,
|
||||||
|
TooltipHost,
|
||||||
} from "@fluentui/react";
|
} from "@fluentui/react";
|
||||||
import * as Constants from "Common/Constants";
|
import * as Constants from "Common/Constants";
|
||||||
import { SplitterDirection } from "Common/Splitter";
|
import { SplitterDirection } from "Common/Splitter";
|
||||||
import { InfoTooltip } from "Common/Tooltip/InfoTooltip";
|
import { InfoTooltip } from "Common/Tooltip/InfoTooltip";
|
||||||
import { configContext } from "ConfigContext";
|
import { Platform, configContext } from "ConfigContext";
|
||||||
import { useDatabases } from "Explorer/useDatabases";
|
import { useDatabases } from "Explorer/useDatabases";
|
||||||
import {
|
import {
|
||||||
DefaultRUThreshold,
|
DefaultRUThreshold,
|
||||||
@ -22,7 +26,7 @@ import {
|
|||||||
ruThresholdEnabled as isRUThresholdEnabled,
|
ruThresholdEnabled as isRUThresholdEnabled,
|
||||||
} from "Shared/StorageUtility";
|
} from "Shared/StorageUtility";
|
||||||
import * as StringUtility from "Shared/StringUtility";
|
import * as StringUtility from "Shared/StringUtility";
|
||||||
import { userContext } from "UserContext";
|
import { updateUserContext, userContext } from "UserContext";
|
||||||
import { logConsoleInfo } from "Utils/NotificationConsoleUtils";
|
import { logConsoleInfo } from "Utils/NotificationConsoleUtils";
|
||||||
import * as PriorityBasedExecutionUtils from "Utils/PriorityBasedExecutionUtils";
|
import * as PriorityBasedExecutionUtils from "Utils/PriorityBasedExecutionUtils";
|
||||||
import { useQueryCopilot } from "hooks/useQueryCopilot";
|
import { useQueryCopilot } from "hooks/useQueryCopilot";
|
||||||
@ -30,6 +34,24 @@ import { useSidePanel } from "hooks/useSidePanel";
|
|||||||
import React, { FunctionComponent, useState } from "react";
|
import React, { FunctionComponent, useState } from "react";
|
||||||
import Explorer from "../../Explorer";
|
import Explorer from "../../Explorer";
|
||||||
import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneForm";
|
import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneForm";
|
||||||
|
import { AuthType } from "AuthType";
|
||||||
|
import create, { UseStore } from "zustand";
|
||||||
|
|
||||||
|
export interface DataPlaneRbacState {
|
||||||
|
dataPlaneRbacEnabled: boolean;
|
||||||
|
aadTokenUpdated: boolean;
|
||||||
|
|
||||||
|
getState?: () => DataPlaneRbacState;
|
||||||
|
|
||||||
|
setDataPlaneRbacEnabled: (dataPlaneRbacEnabled: boolean) => void;
|
||||||
|
setAadDataPlaneUpdated: (aadTokenUpdated: boolean) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
type DataPlaneRbacStore = UseStore<Partial<DataPlaneRbacState>>;
|
||||||
|
|
||||||
|
export const useDataPlaneRbac: DataPlaneRbacStore = create(() => ({
|
||||||
|
dataPlaneRbacEnabled: false,
|
||||||
|
}));
|
||||||
|
|
||||||
export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
||||||
explorer,
|
explorer,
|
||||||
@ -44,13 +66,14 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
|||||||
? Constants.Queries.UnlimitedPageOption
|
? Constants.Queries.UnlimitedPageOption
|
||||||
: Constants.Queries.CustomPageOption,
|
: Constants.Queries.CustomPageOption,
|
||||||
);
|
);
|
||||||
|
|
||||||
const [enableDataPlaneRBACOption, setEnableDataPlaneRBACOption] = useState<string>(
|
const [enableDataPlaneRBACOption, setEnableDataPlaneRBACOption] = useState<string>(
|
||||||
LocalStorageUtility.getEntryString(StorageKey.DataPlaneRbacEnabled) === Constants.RBACOptions.setAutomaticRBACOption
|
LocalStorageUtility.hasItem(StorageKey.DataPlaneRbacEnabled)
|
||||||
? Constants.RBACOptions.setAutomaticRBACOption
|
? LocalStorageUtility.getEntryString(StorageKey.DataPlaneRbacEnabled)
|
||||||
: LocalStorageUtility.getEntryString(StorageKey.DataPlaneRbacEnabled) === Constants.RBACOptions.setTrueRBACOption
|
: Constants.RBACOptions.setAutomaticRBACOption,
|
||||||
? Constants.RBACOptions.setTrueRBACOption
|
|
||||||
: Constants.RBACOptions.setFalseRBACOption
|
|
||||||
);
|
);
|
||||||
|
const [showDataPlaneRBACWarning, setShowDataPlaneRBACWarning] = useState<boolean>(false);
|
||||||
|
|
||||||
const [ruThresholdEnabled, setRUThresholdEnabled] = useState<boolean>(isRUThresholdEnabled());
|
const [ruThresholdEnabled, setRUThresholdEnabled] = useState<boolean>(isRUThresholdEnabled());
|
||||||
const [ruThreshold, setRUThreshold] = useState<number>(getRUThreshold());
|
const [ruThreshold, setRUThreshold] = useState<number>(getRUThreshold());
|
||||||
const [queryTimeoutEnabled, setQueryTimeoutEnabled] = useState<boolean>(
|
const [queryTimeoutEnabled, setQueryTimeoutEnabled] = useState<boolean>(
|
||||||
@ -129,16 +152,22 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
|||||||
|
|
||||||
LocalStorageUtility.setEntryNumber(StorageKey.CustomItemPerPage, customItemPerPage);
|
LocalStorageUtility.setEntryNumber(StorageKey.CustomItemPerPage, customItemPerPage);
|
||||||
|
|
||||||
LocalStorageUtility.setEntryString(
|
LocalStorageUtility.setEntryString(StorageKey.DataPlaneRbacEnabled, enableDataPlaneRBACOption);
|
||||||
StorageKey.DataPlaneRbacEnabled,
|
if (
|
||||||
enableDataPlaneRBACOption
|
enableDataPlaneRBACOption === Constants.RBACOptions.setTrueRBACOption ||
|
||||||
);
|
(enableDataPlaneRBACOption === Constants.RBACOptions.setAutomaticRBACOption &&
|
||||||
|
userContext.databaseAccount.properties.disableLocalAuth)
|
||||||
|
) {
|
||||||
LocalStorageUtility.setEntryString(
|
updateUserContext({
|
||||||
StorageKey.DataPlaneRbacEnabled,
|
dataPlaneRbacEnabled: true,
|
||||||
enableDataPlaneRBACOption
|
});
|
||||||
);
|
useDataPlaneRbac.setState({ dataPlaneRbacEnabled: true });
|
||||||
|
} else {
|
||||||
|
updateUserContext({
|
||||||
|
dataPlaneRbacEnabled: false,
|
||||||
|
});
|
||||||
|
useDataPlaneRbac.setState({ dataPlaneRbacEnabled: false });
|
||||||
|
}
|
||||||
|
|
||||||
LocalStorageUtility.setEntryBoolean(StorageKey.RUThresholdEnabled, ruThresholdEnabled);
|
LocalStorageUtility.setEntryBoolean(StorageKey.RUThresholdEnabled, ruThresholdEnabled);
|
||||||
LocalStorageUtility.setEntryBoolean(StorageKey.QueryTimeoutEnabled, queryTimeoutEnabled);
|
LocalStorageUtility.setEntryBoolean(StorageKey.QueryTimeoutEnabled, queryTimeoutEnabled);
|
||||||
@ -230,7 +259,7 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
|||||||
const dataPlaneRBACOptionsList: IChoiceGroupOption[] = [
|
const dataPlaneRBACOptionsList: IChoiceGroupOption[] = [
|
||||||
{ key: Constants.RBACOptions.setAutomaticRBACOption, text: "Automatic" },
|
{ key: Constants.RBACOptions.setAutomaticRBACOption, text: "Automatic" },
|
||||||
{ key: Constants.RBACOptions.setTrueRBACOption, text: "True" },
|
{ key: Constants.RBACOptions.setTrueRBACOption, text: "True" },
|
||||||
{ key: Constants.RBACOptions.setFalseRBACOption, text: "False"}
|
{ key: Constants.RBACOptions.setFalseRBACOption, text: "False" },
|
||||||
];
|
];
|
||||||
|
|
||||||
const defaultQueryResultsViewOptionList: IChoiceGroupOption[] = [
|
const defaultQueryResultsViewOptionList: IChoiceGroupOption[] = [
|
||||||
@ -249,8 +278,18 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
|||||||
setPageOption(option.key);
|
setPageOption(option.key);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOnDataPlaneRBACOptionChange = (ev: React.FormEvent<HTMLInputElement>, option: IChoiceGroupOption): void => {
|
const handleOnDataPlaneRBACOptionChange = (
|
||||||
|
ev: React.FormEvent<HTMLInputElement>,
|
||||||
|
option: IChoiceGroupOption,
|
||||||
|
): void => {
|
||||||
setEnableDataPlaneRBACOption(option.key);
|
setEnableDataPlaneRBACOption(option.key);
|
||||||
|
|
||||||
|
const shouldShowWarning =
|
||||||
|
(option.key === Constants.RBACOptions.setTrueRBACOption ||
|
||||||
|
(option.key === Constants.RBACOptions.setAutomaticRBACOption &&
|
||||||
|
userContext.databaseAccount.properties.disableLocalAuth === true)) &&
|
||||||
|
!useDataPlaneRbac.getState().aadTokenUpdated;
|
||||||
|
setShowDataPlaneRBACWarning(shouldShowWarning);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOnRUThresholdToggleChange = (ev: React.MouseEvent<HTMLElement>, checked?: boolean): void => {
|
const handleOnRUThresholdToggleChange = (ev: React.MouseEvent<HTMLElement>, checked?: boolean): void => {
|
||||||
@ -413,47 +452,53 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{(
|
{userContext.apiType === "SQL" && userContext.authType === AuthType.AAD && (
|
||||||
<div className="settingsSection">
|
<>
|
||||||
<div className="settingsSectionPart">
|
<div className="settingsSection">
|
||||||
<fieldset>
|
<div className="settingsSectionPart">
|
||||||
<legend id="enableDataPlaneRBACOptions" className="settingsSectionLabel legendLabel">
|
<fieldset>
|
||||||
Enable DataPlane RBAC
|
<legend id="enableDataPlaneRBACOptions" className="settingsSectionLabel legendLabel">
|
||||||
</legend>
|
Enable Entra ID RBAC
|
||||||
<InfoTooltip>
|
</legend>
|
||||||
Choose Automatic to enable DataPlane RBAC automatically. True/False to voluntarily enable/disable DataPlane RBAC
|
<TooltipHost
|
||||||
</InfoTooltip>
|
content={
|
||||||
<ChoiceGroup
|
<>
|
||||||
ariaLabelledBy="enableDataPlaneRBACOptions"
|
Choose Automatic to enable Entra ID RBAC automatically. True/False to force enable/disable Entra
|
||||||
selectedKey={enableDataPlaneRBACOption}
|
ID RBAC.
|
||||||
options={dataPlaneRBACOptionsList}
|
<a
|
||||||
styles={choiceButtonStyles}
|
href="https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-setup-rbac#use-data-explorer"
|
||||||
onChange={handleOnDataPlaneRBACOptionChange}
|
target="_blank"
|
||||||
/>
|
rel="noopener noreferrer"
|
||||||
</fieldset>
|
>
|
||||||
|
{" "}
|
||||||
|
Learn more{" "}
|
||||||
|
</a>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Icon iconName="Info" ariaLabel="Info tooltip" className="panelInfoIcon" tabIndex={0} />
|
||||||
|
</TooltipHost>
|
||||||
|
{showDataPlaneRBACWarning && configContext.platform === Platform.Portal && (
|
||||||
|
<MessageBar
|
||||||
|
messageBarType={MessageBarType.warning}
|
||||||
|
isMultiline={true}
|
||||||
|
onDismiss={() => setShowDataPlaneRBACWarning(false)}
|
||||||
|
dismissButtonAriaLabel="Close"
|
||||||
|
>
|
||||||
|
Please click on "Login for Entra ID RBAC" prior to performing Entra ID RBAC operations
|
||||||
|
</MessageBar>
|
||||||
|
)}
|
||||||
|
<ChoiceGroup
|
||||||
|
ariaLabelledBy="enableDataPlaneRBACOptions"
|
||||||
|
options={dataPlaneRBACOptionsList}
|
||||||
|
styles={choiceButtonStyles}
|
||||||
|
selectedKey={enableDataPlaneRBACOption}
|
||||||
|
onChange={handleOnDataPlaneRBACOptionChange}
|
||||||
|
/>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</>
|
||||||
)}
|
|
||||||
{(
|
|
||||||
<div className="settingsSection">
|
|
||||||
<div className="settingsSectionPart">
|
|
||||||
<fieldset>
|
|
||||||
<legend id="enableDataPlaneRBACOptions" className="settingsSectionLabel legendLabel">
|
|
||||||
Enable DataPlane RBAC
|
|
||||||
</legend>
|
|
||||||
<InfoTooltip>
|
|
||||||
Choose Automatic to enable DataPlane RBAC automatically. True/False to voluntarily enable/disable DataPlane RBAC
|
|
||||||
</InfoTooltip>
|
|
||||||
<ChoiceGroup
|
|
||||||
ariaLabelledBy="enableDataPlaneRBACOptions"
|
|
||||||
selectedKey={enableDataPlaneRBACOption}
|
|
||||||
options={dataPlaneRBACOptionsList}
|
|
||||||
styles={choiceButtonStyles}
|
|
||||||
onChange={handleOnDataPlaneRBACOptionChange}
|
|
||||||
/>
|
|
||||||
</fieldset>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
{userContext.apiType === "SQL" && (
|
{userContext.apiType === "SQL" && (
|
||||||
<>
|
<>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { useMongoProxyEndpoint } from "Common/MongoProxyClient";
|
import { useMongoProxyEndpoint } from "Common/MongoProxyClient";
|
||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
|
import * as Constants from "../../../Common/Constants";
|
||||||
import { configContext } from "../../../ConfigContext";
|
import { configContext } from "../../../ConfigContext";
|
||||||
import * as ViewModels from "../../../Contracts/ViewModels";
|
import * as ViewModels from "../../../Contracts/ViewModels";
|
||||||
import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants";
|
import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants";
|
||||||
@ -112,6 +113,12 @@ export default class MongoShellTabComponent extends Component<
|
|||||||
const resourceId = databaseAccount?.id;
|
const resourceId = databaseAccount?.id;
|
||||||
const accountName = databaseAccount?.name;
|
const accountName = databaseAccount?.name;
|
||||||
const documentEndpoint = databaseAccount?.properties.mongoEndpoint || databaseAccount?.properties.documentEndpoint;
|
const documentEndpoint = databaseAccount?.properties.mongoEndpoint || databaseAccount?.properties.documentEndpoint;
|
||||||
|
const mongoEndpoint =
|
||||||
|
documentEndpoint.substr(
|
||||||
|
Constants.MongoDBAccounts.protocol.length + 3,
|
||||||
|
documentEndpoint.length -
|
||||||
|
(Constants.MongoDBAccounts.protocol.length + 2 + Constants.MongoDBAccounts.defaultPort.length),
|
||||||
|
) + Constants.MongoDBAccounts.defaultPort.toString();
|
||||||
const databaseId = this.props.collection.databaseId;
|
const databaseId = this.props.collection.databaseId;
|
||||||
const collectionId = this.props.collection.id();
|
const collectionId = this.props.collection.id();
|
||||||
const apiEndpoint = this._useMongoProxyEndpoint
|
const apiEndpoint = this._useMongoProxyEndpoint
|
||||||
@ -125,7 +132,7 @@ export default class MongoShellTabComponent extends Component<
|
|||||||
data: {
|
data: {
|
||||||
resourceId: resourceId,
|
resourceId: resourceId,
|
||||||
accountName: accountName,
|
accountName: accountName,
|
||||||
mongoEndpoint: documentEndpoint,
|
mongoEndpoint: this._useMongoProxyEndpoint ? documentEndpoint : mongoEndpoint,
|
||||||
authorization: authorization,
|
authorization: authorization,
|
||||||
databaseId: databaseId,
|
databaseId: databaseId,
|
||||||
collectionId: collectionId,
|
collectionId: collectionId,
|
||||||
|
@ -7,8 +7,6 @@ export { LocalStorageUtility, SessionStorageUtility };
|
|||||||
export enum StorageKey {
|
export enum StorageKey {
|
||||||
ActualItemPerPage,
|
ActualItemPerPage,
|
||||||
DataPlaneRbacEnabled,
|
DataPlaneRbacEnabled,
|
||||||
DataPlaneRbacDisabled,
|
|
||||||
isDataPlaneRbacAutomatic,
|
|
||||||
RUThresholdEnabled,
|
RUThresholdEnabled,
|
||||||
RUThreshold,
|
RUThreshold,
|
||||||
QueryTimeoutEnabled,
|
QueryTimeoutEnabled,
|
||||||
|
@ -43,6 +43,7 @@ import { isInvalidParentFrameOrigin, shouldProcessMessage } from "../Utils/Messa
|
|||||||
import { listKeys } from "../Utils/arm/generatedClients/cosmos/databaseAccounts";
|
import { listKeys } from "../Utils/arm/generatedClients/cosmos/databaseAccounts";
|
||||||
import { DatabaseAccountListKeysResult } from "../Utils/arm/generatedClients/cosmos/types";
|
import { DatabaseAccountListKeysResult } from "../Utils/arm/generatedClients/cosmos/types";
|
||||||
import { applyExplorerBindings } from "../applyExplorerBindings";
|
import { applyExplorerBindings } from "../applyExplorerBindings";
|
||||||
|
import { useDataPlaneRbac } from "Explorer/Panes/SettingsPane/SettingsPane";
|
||||||
|
|
||||||
// This hook will create a new instance of Explorer.ts and bind it to the DOM
|
// This hook will create a new instance of Explorer.ts and bind it to the DOM
|
||||||
// This hook has a LOT of magic, but ideally we can delete it once we have removed KO and switched entirely to React
|
// This hook has a LOT of magic, but ideally we can delete it once we have removed KO and switched entirely to React
|
||||||
@ -255,7 +256,6 @@ async function configureHostedWithAAD(config: AAD): Promise<Explorer> {
|
|||||||
const subscriptionId = accountResourceId && accountResourceId.split("subscriptions/")[1].split("/")[0];
|
const subscriptionId = accountResourceId && accountResourceId.split("subscriptions/")[1].split("/")[0];
|
||||||
const resourceGroup = accountResourceId && accountResourceId.split("resourceGroups/")[1].split("/")[0];
|
const resourceGroup = accountResourceId && accountResourceId.split("resourceGroups/")[1].split("/")[0];
|
||||||
let aadToken;
|
let aadToken;
|
||||||
let keys: DatabaseAccountListKeysResult = {};
|
|
||||||
if (account.properties?.documentEndpoint) {
|
if (account.properties?.documentEndpoint) {
|
||||||
const hrefEndpoint = new URL(account.properties.documentEndpoint).href.replace(/\/$/, "/.default");
|
const hrefEndpoint = new URL(account.properties.documentEndpoint).href.replace(/\/$/, "/.default");
|
||||||
const msalInstance = await getMsalInstance();
|
const msalInstance = await getMsalInstance();
|
||||||
@ -273,30 +273,30 @@ async function configureHostedWithAAD(config: AAD): Promise<Explorer> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if(LocalStorageUtility.hasItem(StorageKey.DataPlaneRbacEnabled)) {
|
updateUserContext({
|
||||||
var isDataPlaneRbacSetting = LocalStorageUtility.getEntryString(StorageKey.DataPlaneRbacEnabled);
|
databaseAccount: config.databaseAccount,
|
||||||
if (isDataPlaneRbacSetting == Constants.RBACOptions.setAutomaticRBACOption)
|
});
|
||||||
{
|
|
||||||
if (!account.properties.disableLocalAuth) {
|
if (!userContext.features.enableAadDataPlane) {
|
||||||
keys = await listKeys(subscriptionId, resourceGroup, account.name);
|
if (userContext.apiType === "SQL") {
|
||||||
}
|
if (LocalStorageUtility.hasItem(StorageKey.DataPlaneRbacEnabled)) {
|
||||||
else {
|
const isDataPlaneRbacSetting = LocalStorageUtility.getEntryString(StorageKey.DataPlaneRbacEnabled);
|
||||||
updateUserContext({
|
|
||||||
dataPlaneRbacEnabled: true
|
let dataPlaneRbacEnabled;
|
||||||
});
|
if (isDataPlaneRbacSetting === Constants.RBACOptions.setAutomaticRBACOption) {
|
||||||
|
dataPlaneRbacEnabled = account.properties.disableLocalAuth;
|
||||||
|
} else {
|
||||||
|
dataPlaneRbacEnabled = isDataPlaneRbacSetting === Constants.RBACOptions.setTrueRBACOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateUserContext({ dataPlaneRbacEnabled });
|
||||||
}
|
}
|
||||||
else if(isDataPlaneRbacSetting == Constants.RBACOptions.setTrueRBACOption) {
|
} else {
|
||||||
updateUserContext({
|
const keys: DatabaseAccountListKeysResult = await listKeys(subscriptionId, resourceGroup, account.name);
|
||||||
dataPlaneRbacEnabled: true
|
updateUserContext({
|
||||||
});
|
masterKey: keys.primaryMasterKey,
|
||||||
}
|
});
|
||||||
else {
|
}
|
||||||
keys = await listKeys(subscriptionId, resourceGroup, account.name);
|
|
||||||
updateUserContext({
|
|
||||||
dataPlaneRbacEnabled: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (userContext.features.enableAadDataPlane) {
|
if (userContext.features.enableAadDataPlane) {
|
||||||
@ -309,8 +309,6 @@ async function configureHostedWithAAD(config: AAD): Promise<Explorer> {
|
|||||||
subscriptionId,
|
subscriptionId,
|
||||||
resourceGroup,
|
resourceGroup,
|
||||||
aadToken,
|
aadToken,
|
||||||
databaseAccount: config.databaseAccount,
|
|
||||||
masterKey: keys.primaryMasterKey,
|
|
||||||
});
|
});
|
||||||
const explorer = new Explorer();
|
const explorer = new Explorer();
|
||||||
return explorer;
|
return explorer;
|
||||||
@ -478,37 +476,27 @@ async function configurePortal(): Promise<Explorer> {
|
|||||||
setTimeout(() => explorer.openNPSSurveyDialog(), 3000);
|
setTimeout(() => explorer.openNPSSurveyDialog(), 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
let keys: DatabaseAccountListKeysResult = {};
|
const { databaseAccount: account, subscriptionId, resourceGroup } = userContext;
|
||||||
const account = userContext.databaseAccount;
|
|
||||||
const subscriptionId = userContext.subscriptionId;
|
|
||||||
const resourceGroup = userContext.resourceGroup;
|
|
||||||
|
|
||||||
if(LocalStorageUtility.hasItem(StorageKey.DataPlaneRbacEnabled)) {
|
if (userContext.apiType === "SQL") {
|
||||||
var isDataPlaneRbacSetting = LocalStorageUtility.getEntryString(StorageKey.DataPlaneRbacEnabled);
|
if (LocalStorageUtility.hasItem(StorageKey.DataPlaneRbacEnabled)) {
|
||||||
if (isDataPlaneRbacSetting == Constants.RBACOptions.setAutomaticRBACOption)
|
const isDataPlaneRbacSetting = LocalStorageUtility.getEntryString(StorageKey.DataPlaneRbacEnabled);
|
||||||
{
|
|
||||||
if (!account.properties.disableLocalAuth) {
|
let dataPlaneRbacEnabled;
|
||||||
keys = await listKeys(subscriptionId, resourceGroup, account.name);
|
if (isDataPlaneRbacSetting === Constants.RBACOptions.setAutomaticRBACOption) {
|
||||||
}
|
dataPlaneRbacEnabled = account.properties.disableLocalAuth;
|
||||||
else {
|
} else {
|
||||||
updateUserContext({
|
dataPlaneRbacEnabled = isDataPlaneRbacSetting === Constants.RBACOptions.setTrueRBACOption;
|
||||||
dataPlaneRbacEnabled: true,
|
|
||||||
authorizationToken: message.inputs.authorizationToken
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(isDataPlaneRbacSetting == Constants.RBACOptions.setTrueRBACOption) {
|
|
||||||
updateUserContext({
|
|
||||||
dataPlaneRbacEnabled: true,
|
|
||||||
authorizationToken: message.inputs.authorizationToken
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
keys = await listKeys(subscriptionId, resourceGroup, account.name);
|
|
||||||
updateUserContext({
|
|
||||||
dataPlaneRbacEnabled: false
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateUserContext({ dataPlaneRbacEnabled });
|
||||||
|
useDataPlaneRbac.setState({ dataPlaneRbacEnabled: dataPlaneRbacEnabled });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const keys: DatabaseAccountListKeysResult = await listKeys(subscriptionId, resourceGroup, account.name);
|
||||||
|
updateUserContext({
|
||||||
|
masterKey: keys.primaryMasterKey,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openAction) {
|
if (openAction) {
|
||||||
@ -553,7 +541,6 @@ function updateContextsFromPortalMessage(inputs: DataExplorerInputsFrame) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const authorizationToken = inputs.authorizationToken || "";
|
const authorizationToken = inputs.authorizationToken || "";
|
||||||
const masterKey = inputs.masterKey || "";
|
|
||||||
const databaseAccount = inputs.databaseAccount;
|
const databaseAccount = inputs.databaseAccount;
|
||||||
|
|
||||||
updateConfigContext({
|
updateConfigContext({
|
||||||
@ -566,7 +553,6 @@ function updateContextsFromPortalMessage(inputs: DataExplorerInputsFrame) {
|
|||||||
|
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
authorizationToken,
|
authorizationToken,
|
||||||
masterKey,
|
|
||||||
databaseAccount,
|
databaseAccount,
|
||||||
resourceGroup: inputs.resourceGroup,
|
resourceGroup: inputs.resourceGroup,
|
||||||
subscriptionId: inputs.subscriptionId,
|
subscriptionId: inputs.subscriptionId,
|
||||||
|
@ -14,6 +14,9 @@ test("Tables CRUD", async ({ page }) => {
|
|||||||
await okButton.click();
|
await okButton.click();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const databaseNode = explorer.treeNode("DATA/TablesDB");
|
||||||
|
await databaseNode.expand();
|
||||||
|
|
||||||
const tableNode = explorer.treeNode(`DATA/TablesDB/${tableId}`);
|
const tableNode = explorer.treeNode(`DATA/TablesDB/${tableId}`);
|
||||||
await expect(tableNode.element).toBeAttached();
|
await expect(tableNode.element).toBeAttached();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user