mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 15:06:55 +00:00
Fix enable AAD dataplane feature flag behavior
This commit is contained in:
parent
fd3a83dcd8
commit
478467bda5
@ -19,10 +19,10 @@ 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;
|
||||||
|
|
||||||
if (
|
const aadDataPlaneFeatureEnabled =
|
||||||
(userContext.features.enableAadDataPlane && userContext.databaseAccount.properties.disableLocalAuth) ||
|
userContext.features.enableAadDataPlane && userContext.databaseAccount.properties.disableLocalAuth;
|
||||||
(userContext.dataPlaneRbacEnabled && userContext.apiType === "SQL")
|
const dataPlaneRBACOptionEnabled = userContext.dataPlaneRbacEnabled && userContext.apiType === "SQL";
|
||||||
) {
|
if (aadDataPlaneFeatureEnabled || (!userContext.features.enableAadDataPlane && dataPlaneRBACOptionEnabled)) {
|
||||||
if (!userContext.aadToken) {
|
if (!userContext.aadToken) {
|
||||||
logConsoleError(
|
logConsoleError(
|
||||||
`AAD token does not exist. Please use "Login for Entra ID" prior to performing Entra ID RBAC operations`,
|
`AAD token does not exist. Please use "Login for Entra ID" prior to performing Entra ID RBAC operations`,
|
||||||
|
@ -276,24 +276,26 @@ async function configureHostedWithAAD(config: AAD): Promise<Explorer> {
|
|||||||
databaseAccount: config.databaseAccount,
|
databaseAccount: config.databaseAccount,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (userContext.apiType === "SQL") {
|
if (!userContext.features.enableAadDataPlane) {
|
||||||
if (LocalStorageUtility.hasItem(StorageKey.DataPlaneRbacEnabled)) {
|
if (userContext.apiType === "SQL") {
|
||||||
const isDataPlaneRbacSetting = LocalStorageUtility.getEntryString(StorageKey.DataPlaneRbacEnabled);
|
if (LocalStorageUtility.hasItem(StorageKey.DataPlaneRbacEnabled)) {
|
||||||
|
const isDataPlaneRbacSetting = LocalStorageUtility.getEntryString(StorageKey.DataPlaneRbacEnabled);
|
||||||
|
|
||||||
let dataPlaneRbacEnabled;
|
let dataPlaneRbacEnabled;
|
||||||
if (isDataPlaneRbacSetting === Constants.RBACOptions.setAutomaticRBACOption) {
|
if (isDataPlaneRbacSetting === Constants.RBACOptions.setAutomaticRBACOption) {
|
||||||
dataPlaneRbacEnabled = account.properties.disableLocalAuth;
|
dataPlaneRbacEnabled = account.properties.disableLocalAuth;
|
||||||
} else {
|
} else {
|
||||||
dataPlaneRbacEnabled = isDataPlaneRbacSetting === Constants.RBACOptions.setTrueRBACOption;
|
dataPlaneRbacEnabled = isDataPlaneRbacSetting === Constants.RBACOptions.setTrueRBACOption;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateUserContext({ dataPlaneRbacEnabled });
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
updateUserContext({ dataPlaneRbacEnabled });
|
const keys: DatabaseAccountListKeysResult = await listKeys(subscriptionId, resourceGroup, account.name);
|
||||||
|
updateUserContext({
|
||||||
|
masterKey: keys.primaryMasterKey,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
const keys: DatabaseAccountListKeysResult = await listKeys(subscriptionId, resourceGroup, account.name);
|
|
||||||
updateUserContext({
|
|
||||||
masterKey: keys.primaryMasterKey,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (userContext.features.enableAadDataPlane) {
|
if (userContext.features.enableAadDataPlane) {
|
||||||
|
Loading…
Reference in New Issue
Block a user