Compare commits

...

43 Commits

Author SHA1 Message Date
Senthamil Sindhu
caf4e9f51f Add fetchAndUpdate Keys 2024-07-03 16:01:23 -07:00
Senthamil Sindhu
22144982bd Merge branch 'users/sindhuba/rbac-fix' into users/sindhuba/fix-tables-api 2024-07-03 00:09:45 -07:00
Senthamil Sindhu
3e48393fbb Merge branch 'master' of https://github.com/Azure/cosmos-explorer 2024-07-03 00:07:17 -07:00
Senthamil Sindhu
9274f50500 Address bug in fetching data for Tables Account 2024-07-03 00:02:29 -07:00
Senthamil Sindhu
8b4d9bd354 Run format 2024-07-01 16:44:43 -07:00
Senthamil Sindhu
2c78625f83 Merge branch 'users/sindhuba/rbac' into users/sindhuba/rbac-fix 2024-07-01 16:32:56 -07:00
Senthamil Sindhu
0079a9147f Resolved merge conflict 2024-07-01 16:22:04 -07:00
Senthamil Sindhu
602a697fe9 Address lint error 2024-07-01 16:16:40 -07:00
Senthamil Sindhu
28d8216b32 Run npm format 2024-07-01 16:09:47 -07:00
Senthamil Sindhu
3b9261ef76 Address Local storage default setting issue 2024-07-01 16:08:08 -07:00
Senthamil Sindhu
6be839991f Run npm format 2024-07-01 08:22:12 -07:00
Senthamil Sindhu
72eca5ed79 Fix Tables test 2024-06-28 10:49:01 -07:00
Senthamil Sindhu
473a6d34bd Add new fixes 2024-06-27 23:20:05 -07:00
Senthamil Sindhu
912688dc14 Merge branch 'master' of https://github.com/Azure/cosmos-explorer 2024-06-27 11:00:31 -07:00
Senthamil Sindhu
805d72c55b Minor fix 2024-06-27 09:49:00 -07:00
Senthamil Sindhu
eb7c737066 Address feedback comments 2024-06-27 09:37:08 -07:00
Senthamil Sindhu
478467bda5 Fix enable AAD dataplane feature flag behavior 2024-06-25 16:27:40 -07:00
Senthamil Sindhu
fd3a83dcd8 Fix enableAadDataPlane feature flag behavior 2024-06-25 15:37:08 -07:00
Senthamil Sindhu
713df1869a Run npm format 2024-06-25 12:15:59 -07:00
Senthamil Sindhu
192a275139 Remove unnecessary code 2024-06-25 12:09:43 -07:00
Senthamil Sindhu
77ee359adb Fix unit tests 2024-06-25 10:23:01 -07:00
Senthamil Sindhu
a50108c375 Run format 2024-06-25 09:59:21 -07:00
Senthamil Sindhu
d3fb5eabdb Cleanup DP RBAC code 2024-06-25 09:28:08 -07:00
Senthamil Sindhu
4792e2d1c7 Address errors and checks 2024-06-19 21:00:55 -07:00
Senthamil Sindhu
8849526fab Merge branch 'add-dp-rbac' of https://github.com/Azure/cosmos-explorer 2024-06-19 15:20:20 -07:00
Senthamil Sindhu
24af64a66d Add additional changes for Portal RBAC functionality 2024-06-19 15:05:14 -07:00
Senthamil Sindhu
be871737ad Support data plane RBAC 2024-06-14 12:45:21 -07:00
Senthamil Sindhu
4d8bb5c3ea Merge branch 'master' of https://github.com/Azure/cosmos-explorer 2024-06-14 12:18:14 -07:00
Senthamil Sindhu
10a8505b9a Support data plane RBAC 2024-06-14 12:12:30 -07:00
Senthamil Sindhu
ef7c2fe2f7 Remove dev endpoint 2024-04-10 11:59:57 -07:00
Senthamil Sindhu
4c7aca95e1 Merge branch 'users/aisayas/mp-cp-activate-prod' of https://github.com/Azure/cosmos-explorer into users/sindhuba/activate-prod 2024-04-09 12:27:51 -07:00
Senthamil Sindhu
2243ad895a Remove prod endpoint 2024-04-09 12:16:13 -07:00
Senthamil Sindhu
b2d5f91fe1 Remove prod 2024-04-09 11:22:17 -07:00
Asier Isayas
a712193477 fix pr check tests 2024-04-09 11:43:24 -04:00
Senthamil Sindhu
5ee411693c Add prod endpoint 2024-04-09 08:41:47 -07:00
Asier Isayas
16c7b2567b fix bug that blocked local mongo proxy and cassandra proxy development 2024-04-09 11:39:11 -04:00
Senthamil Sindhu
78d9a0cd8d Revert code 2024-04-08 16:20:40 -07:00
Senthamil Sindhu
c6ad538559 Run npm format and tests 2024-04-08 15:58:10 -07:00
Senthamil Sindhu
2bc09a6efe Add CP Prod endpoint 2024-04-08 15:37:19 -07:00
Senthamil Sindhu
d3a3033b25 Merge branch 'master' of https://github.com/Azure/cosmos-explorer 2024-04-08 15:32:50 -07:00
Asier Isayas
6bdc714e11 activate Mongo Proxy and Cassandra Proxy in Prod 2024-04-08 16:52:09 -04:00
Senthamil Sindhu
5042f28229 Merge branch 'master' of https://github.com/Azure/cosmos-explorer 2024-03-25 15:11:53 -07:00
Senthamil Sindhu
e1430fd06f Fix API endpoint for CassandraProxy query API 2024-03-18 10:25:17 -07:00
4 changed files with 50 additions and 27 deletions

View File

@@ -3,12 +3,10 @@ import { getAuthorizationTokenUsingResourceTokens } from "Common/getAuthorizatio
import { AuthorizationToken } from "Contracts/FabricMessageTypes";
import { checkDatabaseResourceTokensValidity } from "Platform/Fabric/FabricUtil";
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 { PriorityLevel } from "../Common/Constants";
import { Platform, configContext } from "../ConfigContext";
import { updateUserContext, userContext } from "../UserContext";
import { userContext } from "../UserContext";
import { logConsoleError } from "../Utils/NotificationConsoleUtils";
import * as PriorityBasedExecutionUtils from "../Utils/PriorityBasedExecutionUtils";
import { EmulatorMasterKey, HttpHeaders } from "./Constants";
@@ -91,22 +89,6 @@ export const tokenProvider = async (requestInfo: Cosmos.RequestInfo) => {
userContext.masterKey,
);
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) {
@@ -190,6 +172,7 @@ export function client(): Cosmos.CosmosClient {
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
key: userContext.dataPlaneRbacEnabled ? "" : userContext.masterKey,
tokenProvider,
userAgentSuffix: "Azure Portal",
defaultHeaders: _defaultHeaders,

View File

@@ -36,6 +36,8 @@ import Explorer from "../../Explorer";
import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneForm";
import { AuthType } from "AuthType";
import create, { UseStore } from "zustand";
import { DatabaseAccountListKeysResult } from "@azure/arm-cosmosdb/esm/models";
import { listKeys } from "Utils/arm/generatedClients/cosmos/databaseAccounts";
export interface DataPlaneRbacState {
dataPlaneRbacEnabled: boolean;
@@ -166,8 +168,15 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
updateUserContext({
dataPlaneRbacEnabled: false,
});
const { databaseAccount: account, subscriptionId, resourceGroup } = userContext;
const keys: DatabaseAccountListKeysResult = await listKeys(subscriptionId, resourceGroup, account.name);
if (keys.primaryMasterKey) {
updateUserContext({ masterKey: keys.primaryMasterKey });
useDataPlaneRbac.setState({ dataPlaneRbacEnabled: false });
}
}
LocalStorageUtility.setEntryBoolean(StorageKey.RUThresholdEnabled, ruThresholdEnabled);
LocalStorageUtility.setEntryBoolean(StorageKey.QueryTimeoutEnabled, queryTimeoutEnabled);

View File

@@ -73,6 +73,7 @@ export interface UserContext {
readonly fabricContext?: FabricContext;
readonly authType?: AuthType;
readonly masterKey?: string;
readonly listKeysFetchInProgress?: boolean;
readonly subscriptionId?: string;
readonly resourceGroup?: string;
readonly databaseAccount?: DatabaseAccount;

View File

@@ -417,11 +417,24 @@ function configureEmulator(): Explorer {
return explorer;
}
async function fetchAndUpdateKeys(subscriptionId: string, resourceGroup: string, account: string) {
try {
updateUserContext({ listKeysFetchInProgress: true });
const keys = await listKeys(subscriptionId, resourceGroup, account);
updateUserContext({ masterKey: keys.primaryMasterKey, listKeysFetchInProgress: false });
} catch (error) {
updateUserContext({ listKeysFetchInProgress: false });
console.error("Error during fetching keys or updating user context:", error);
}
}
async function configurePortal(): Promise<Explorer> {
updateUserContext({
authType: AuthType.AAD,
});
let explorer: Explorer;
return new Promise((resolve) => {
// In development mode, try to load the iframe message from session storage.
// This allows webpack hot reload to function properly in the portal
@@ -489,20 +502,31 @@ async function configurePortal(): Promise<Explorer> {
} else {
dataPlaneRbacEnabled = isDataPlaneRbacSetting === Constants.RBACOptions.setTrueRBACOption;
}
if(!dataPlaneRbacEnabled) {
(async () => {
await fetchAndUpdateKeys(subscriptionId, resourceGroup, account.name);
})();
}
updateUserContext({ dataPlaneRbacEnabled });
useDataPlaneRbac.setState({ dataPlaneRbacEnabled: dataPlaneRbacEnabled });
} else {
const dataPlaneRbacEnabled = account.properties.disableLocalAuth;
if(!dataPlaneRbacEnabled) {
(async () => {
await fetchAndUpdateKeys(subscriptionId, resourceGroup, account.name);
})();
}
updateUserContext({ dataPlaneRbacEnabled });
useDataPlaneRbac.setState({ dataPlaneRbacEnabled: dataPlaneRbacEnabled });
}
} else {
const keys: DatabaseAccountListKeysResult = await listKeys(subscriptionId, resourceGroup, account.name);
updateUserContext({
masterKey: keys.primaryMasterKey,
});
}
else {
(async () => {
await fetchAndUpdateKeys(subscriptionId, resourceGroup, account.name);
})();
}
if (openAction) {
@@ -547,6 +571,11 @@ function updateContextsFromPortalMessage(inputs: DataExplorerInputsFrame) {
const authorizationToken = inputs.authorizationToken || "";
const databaseAccount = inputs.databaseAccount;
if(userContext.apiType !== "SQL") {
const masterKey = inputs.masterKey || "";
updateUserContext({masterKey});
}
updateConfigContext({
BACKEND_ENDPOINT: inputs.extensionEndpoint || configContext.BACKEND_ENDPOINT,
ARM_ENDPOINT: normalizeArmEndpoint(inputs.csmEndpoint || configContext.ARM_ENDPOINT),
@@ -567,6 +596,7 @@ function updateContextsFromPortalMessage(inputs: DataExplorerInputsFrame) {
collectionCreationDefaults: inputs.defaultCollectionThroughput,
isTryCosmosDBSubscription: inputs.isTryCosmosDBSubscription,
feedbackPolicies: inputs.feedbackPolicies,
listKeysFetchInProgress: false,
});
if (inputs.isPostgresAccount) {