Fetch aad token against tenant's authority (#1004)

This commit is contained in:
Zachary Foster 2021-08-30 15:21:32 -04:00 committed by GitHub
parent 8eeda41021
commit 39dd293fc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View File

@ -56,6 +56,7 @@ export function useAADAuth(): ReturnType {
}); });
setTenantId(response.tenantId); setTenantId(response.tenantId);
setAccount(response.account); setAccount(response.account);
localStorage.setItem("cachedTenantId", response.tenantId);
}, },
[account, tenantId] [account, tenantId]
); );

View File

@ -98,9 +98,11 @@ async function configureHostedWithAAD(config: AAD): Promise<Explorer> {
const msalInstance = getMsalInstance(); const msalInstance = getMsalInstance();
const cachedAccount = msalInstance.getAllAccounts()?.[0]; const cachedAccount = msalInstance.getAllAccounts()?.[0];
msalInstance.setActiveAccount(cachedAccount); msalInstance.setActiveAccount(cachedAccount);
const cachedTenantId = localStorage.getItem("cachedTenantId");
const aadTokenResponse = await msalInstance.acquireTokenSilent({ const aadTokenResponse = await msalInstance.acquireTokenSilent({
forceRefresh: true, forceRefresh: true,
scopes: [hrefEndpoint], scopes: [hrefEndpoint],
authority: `${configContext.AAD_ENDPOINT}${cachedTenantId}`,
}); });
aadToken = aadTokenResponse.accessToken; aadToken = aadTokenResponse.accessToken;
} }