mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 15:06:55 +00:00
Address errors and checks
This commit is contained in:
parent
8849526fab
commit
4792e2d1c7
@ -26,10 +26,9 @@ export const tokenProvider = async (requestInfo: Cosmos.RequestInfo) => {
|
||||
return authorizationToken;
|
||||
}
|
||||
|
||||
if ((userContext.dataPlaneRbacEnabled) && userContext.authorizationToken) {
|
||||
console.log(` Getting Portal Auth token `)
|
||||
const AUTH_PREFIX = `type=aad&ver=1.0&sig=`;
|
||||
const authorizationToken = `${AUTH_PREFIX}${userContext.authorizationToken}`;
|
||||
if (userContext.dataPlaneRbacEnabled && userContext.authorizationToken) {
|
||||
console.log(` Getting Portal Auth token `);
|
||||
const authorizationToken = `${userContext.authorizationToken}`;
|
||||
console.log(`Returning Portal Auth token`);
|
||||
return authorizationToken;
|
||||
}
|
||||
|
@ -710,4 +710,3 @@ async function errorHandling(response: Response, action: string, params: unknown
|
||||
export function getARMCreateCollectionEndpoint(params: DataModels.MongoParameters): string {
|
||||
return `subscriptions/${params.sid}/resourceGroups/${params.rg}/providers/Microsoft.DocumentDB/databaseAccounts/${userContext.databaseAccount.name}/mongodbDatabases/${params.db}/collections/${params.coll}`;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
||||
? Constants.RBACOptions.setAutomaticRBACOption
|
||||
: LocalStorageUtility.getEntryString(StorageKey.DataPlaneRbacEnabled) === Constants.RBACOptions.setTrueRBACOption
|
||||
? Constants.RBACOptions.setTrueRBACOption
|
||||
: Constants.RBACOptions.setFalseRBACOption
|
||||
: Constants.RBACOptions.setFalseRBACOption,
|
||||
);
|
||||
const [ruThresholdEnabled, setRUThresholdEnabled] = useState<boolean>(isRUThresholdEnabled());
|
||||
const [ruThreshold, setRUThreshold] = useState<number>(getRUThreshold());
|
||||
@ -129,16 +129,7 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
||||
|
||||
LocalStorageUtility.setEntryNumber(StorageKey.CustomItemPerPage, customItemPerPage);
|
||||
|
||||
LocalStorageUtility.setEntryString(
|
||||
StorageKey.DataPlaneRbacEnabled,
|
||||
enableDataPlaneRBACOption
|
||||
);
|
||||
|
||||
|
||||
LocalStorageUtility.setEntryString(
|
||||
StorageKey.DataPlaneRbacEnabled,
|
||||
enableDataPlaneRBACOption
|
||||
);
|
||||
LocalStorageUtility.setEntryString(StorageKey.DataPlaneRbacEnabled, enableDataPlaneRBACOption);
|
||||
|
||||
LocalStorageUtility.setEntryBoolean(StorageKey.RUThresholdEnabled, ruThresholdEnabled);
|
||||
LocalStorageUtility.setEntryBoolean(StorageKey.QueryTimeoutEnabled, queryTimeoutEnabled);
|
||||
@ -230,7 +221,7 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
||||
const dataPlaneRBACOptionsList: IChoiceGroupOption[] = [
|
||||
{ key: Constants.RBACOptions.setAutomaticRBACOption, text: "Automatic" },
|
||||
{ key: Constants.RBACOptions.setTrueRBACOption, text: "True" },
|
||||
{ key: Constants.RBACOptions.setFalseRBACOption, text: "False"}
|
||||
{ key: Constants.RBACOptions.setFalseRBACOption, text: "False" },
|
||||
];
|
||||
|
||||
const defaultQueryResultsViewOptionList: IChoiceGroupOption[] = [
|
||||
@ -249,7 +240,10 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
||||
setPageOption(option.key);
|
||||
};
|
||||
|
||||
const handleOnDataPlaneRBACOptionChange = (ev: React.FormEvent<HTMLInputElement>, option: IChoiceGroupOption): void => {
|
||||
const handleOnDataPlaneRBACOptionChange = (
|
||||
ev: React.FormEvent<HTMLInputElement>,
|
||||
option: IChoiceGroupOption,
|
||||
): void => {
|
||||
setEnableDataPlaneRBACOption(option.key);
|
||||
};
|
||||
|
||||
@ -413,7 +407,7 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{(
|
||||
{
|
||||
<div className="settingsSection">
|
||||
<div className="settingsSectionPart">
|
||||
<fieldset>
|
||||
@ -421,7 +415,8 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
||||
Enable DataPlane RBAC
|
||||
</legend>
|
||||
<InfoTooltip>
|
||||
Choose Automatic to enable DataPlane RBAC automatically. True/False to voluntarily enable/disable DataPlane RBAC
|
||||
Choose Automatic to enable DataPlane RBAC automatically. True/False to voluntarily enable/disable
|
||||
DataPlane RBAC
|
||||
</InfoTooltip>
|
||||
<ChoiceGroup
|
||||
ariaLabelledBy="enableDataPlaneRBACOptions"
|
||||
@ -433,28 +428,7 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
||||
</fieldset>
|
||||
</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" && (
|
||||
<>
|
||||
<div className="settingsSection">
|
||||
|
@ -749,10 +749,6 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
CassandraProxyEndpoints.Prod,
|
||||
];
|
||||
let canAccessCassandraProxy: boolean = userContext.databaseAccount.properties.publicNetworkAccess === "Enabled";
|
||||
if (
|
||||
configContext.CASSANDRA_PROXY_ENDPOINT !== CassandraProxyEndpoints.Development &&
|
||||
userContext.databaseAccount.properties.ipRules?.length > 0
|
||||
) {
|
||||
if (
|
||||
configContext.CASSANDRA_PROXY_ENDPOINT !== CassandraProxyEndpoints.Development &&
|
||||
userContext.databaseAccount.properties.ipRules?.length > 0
|
||||
@ -767,4 +763,3 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -274,27 +274,23 @@ async function configureHostedWithAAD(config: AAD): Promise<Explorer> {
|
||||
}
|
||||
try {
|
||||
if (LocalStorageUtility.hasItem(StorageKey.DataPlaneRbacEnabled)) {
|
||||
var isDataPlaneRbacSetting = LocalStorageUtility.getEntryString(StorageKey.DataPlaneRbacEnabled);
|
||||
if (isDataPlaneRbacSetting == Constants.RBACOptions.setAutomaticRBACOption)
|
||||
{
|
||||
const isDataPlaneRbacSetting = LocalStorageUtility.getEntryString(StorageKey.DataPlaneRbacEnabled);
|
||||
if (isDataPlaneRbacSetting === Constants.RBACOptions.setAutomaticRBACOption) {
|
||||
if (!account.properties.disableLocalAuth) {
|
||||
keys = await listKeys(subscriptionId, resourceGroup, account.name);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
updateUserContext({
|
||||
dataPlaneRbacEnabled: true
|
||||
dataPlaneRbacEnabled: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
else if(isDataPlaneRbacSetting == Constants.RBACOptions.setTrueRBACOption) {
|
||||
} else if (isDataPlaneRbacSetting === Constants.RBACOptions.setTrueRBACOption) {
|
||||
updateUserContext({
|
||||
dataPlaneRbacEnabled: true
|
||||
dataPlaneRbacEnabled: true,
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
keys = await listKeys(subscriptionId, resourceGroup, account.name);
|
||||
updateUserContext({
|
||||
dataPlaneRbacEnabled: false
|
||||
dataPlaneRbacEnabled: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -419,9 +415,8 @@ async function configurePortal(): Promise<Explorer> {
|
||||
authType: AuthType.AAD,
|
||||
});
|
||||
|
||||
|
||||
let explorer: Explorer;
|
||||
return new Promise(async (resolve) => {
|
||||
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
|
||||
if (process.env.NODE_ENV === "development" && !window.location.search.includes("disablePortalInitCache")) {
|
||||
@ -435,7 +430,6 @@ async function configurePortal(): Promise<Explorer> {
|
||||
updateContextsFromPortalMessage(message);
|
||||
explorer = new Explorer();
|
||||
|
||||
|
||||
// In development mode, save the iframe message from the portal in session storage.
|
||||
// This allows webpack hot reload to funciton properly
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
@ -478,35 +472,30 @@ async function configurePortal(): Promise<Explorer> {
|
||||
setTimeout(() => explorer.openNPSSurveyDialog(), 3000);
|
||||
}
|
||||
|
||||
let keys: DatabaseAccountListKeysResult = {};
|
||||
const account = userContext.databaseAccount;
|
||||
const subscriptionId = userContext.subscriptionId;
|
||||
const resourceGroup = userContext.resourceGroup;
|
||||
|
||||
if (LocalStorageUtility.hasItem(StorageKey.DataPlaneRbacEnabled)) {
|
||||
var isDataPlaneRbacSetting = LocalStorageUtility.getEntryString(StorageKey.DataPlaneRbacEnabled);
|
||||
if (isDataPlaneRbacSetting == Constants.RBACOptions.setAutomaticRBACOption)
|
||||
{
|
||||
const isDataPlaneRbacSetting = LocalStorageUtility.getEntryString(StorageKey.DataPlaneRbacEnabled);
|
||||
if (isDataPlaneRbacSetting === Constants.RBACOptions.setAutomaticRBACOption) {
|
||||
if (!account.properties.disableLocalAuth) {
|
||||
keys = await listKeys(subscriptionId, resourceGroup, account.name);
|
||||
}
|
||||
else {
|
||||
await listKeys(subscriptionId, resourceGroup, account.name);
|
||||
} else {
|
||||
updateUserContext({
|
||||
dataPlaneRbacEnabled: true,
|
||||
authorizationToken: message.inputs.authorizationToken
|
||||
authorizationToken: message.inputs.authorizationToken,
|
||||
});
|
||||
}
|
||||
}
|
||||
else if(isDataPlaneRbacSetting == Constants.RBACOptions.setTrueRBACOption) {
|
||||
} else if (isDataPlaneRbacSetting === Constants.RBACOptions.setTrueRBACOption) {
|
||||
updateUserContext({
|
||||
dataPlaneRbacEnabled: true,
|
||||
authorizationToken: message.inputs.authorizationToken
|
||||
authorizationToken: message.inputs.authorizationToken,
|
||||
});
|
||||
}
|
||||
else {
|
||||
keys = await listKeys(subscriptionId, resourceGroup, account.name);
|
||||
} else {
|
||||
await listKeys(subscriptionId, resourceGroup, account.name);
|
||||
updateUserContext({
|
||||
dataPlaneRbacEnabled: false
|
||||
dataPlaneRbacEnabled: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -533,9 +522,7 @@ async function configurePortal(): Promise<Explorer> {
|
||||
);
|
||||
|
||||
sendReadyMessage();
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function shouldForwardMessage(message: PortalMessage, messageOrigin: string) {
|
||||
|
Loading…
Reference in New Issue
Block a user