Fix Mongo AAD bug where collections are not load (#552)

This commit is contained in:
Steve Faulkner 2021-03-16 18:04:26 -05:00 committed by GitHub
parent 3530633fa2
commit 6582d3be37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -78,18 +78,22 @@ async function configureHosted(explorerParams: ExplorerParams): Promise<Explorer
}
async function configureHostedWithAAD(config: AAD, explorerParams: ExplorerParams): Promise<Explorer> {
// TODO: Refactor. updateUserContext needs to be called twice because listKeys below depends on userContext.authorizationToken
updateUserContext({
authType: AuthType.AAD,
authorizationToken: `Bearer ${config.authorizationToken}`,
});
const account = config.databaseAccount;
const accountResourceId = account.id;
const subscriptionId = accountResourceId && accountResourceId.split("subscriptions/")[1].split("/")[0];
const resourceGroup = accountResourceId && accountResourceId.split("resourceGroups/")[1].split("/")[0];
const keys = await listKeys(subscriptionId, resourceGroup, account.name);
updateUserContext({
subscriptionId,
resourceGroup,
authType: AuthType.AAD,
authorizationToken: `Bearer ${config.authorizationToken}`,
databaseAccount: config.databaseAccount,
masterKey: keys.primaryMasterKey,
});
const keys = await listKeys(subscriptionId, resourceGroup, account.name);
const explorer = new Explorer(explorerParams);
explorer.configure({
databaseAccount: account,