From c42a10faa5527c712aab6fcd0c29180081b96160 Mon Sep 17 00:00:00 2001 From: Zachary Foster Date: Tue, 25 May 2021 00:21:52 -0400 Subject: [PATCH] Rollback DB endpoint use by AAD (#822) --- src/HostedExplorer.tsx | 7 +++---- src/hooks/useAADAuth.ts | 20 -------------------- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/src/HostedExplorer.tsx b/src/HostedExplorer.tsx index 9ae06f844..4751ea5fa 100644 --- a/src/HostedExplorer.tsx +++ b/src/HostedExplorer.tsx @@ -1,5 +1,5 @@ -import { initializeIcons } from "@fluentui/react"; import { useBoolean } from "@fluentui/react-hooks"; +import { initializeIcons } from "@fluentui/react"; import * as React from "react"; import { render } from "react-dom"; import ChevronRight from "../images/chevron-right.svg"; @@ -7,7 +7,7 @@ import "../less/hostedexplorer.less"; import { AuthType } from "./AuthType"; import { DatabaseAccount } from "./Contracts/DataModels"; import "./Explorer/Menus/NavBar/MeControlComponent.less"; -import { useAADAuth, useAADDataPlane } from "./hooks/useAADAuth"; +import { useAADAuth } from "./hooks/useAADAuth"; import { useTokenMetadata } from "./hooks/usePortalAccessToken"; import { HostedExplorerChildFrame } from "./HostedExplorerChildFrame"; import { AccountSwitcher } from "./Platform/Hosted/Components/AccountSwitcher"; @@ -31,9 +31,8 @@ const App: React.FunctionComponent = () => { // For showing/hiding panel const [isOpen, { setTrue: openPanel, setFalse: dismissPanel }] = useBoolean(false); - const { isLoggedIn, armToken, graphToken, account, tenantId, logout, login, switchTenant } = useAADAuth(); + const { isLoggedIn, armToken, graphToken, aadToken, account, tenantId, logout, login, switchTenant } = useAADAuth(); const [databaseAccount, setDatabaseAccount] = React.useState(); - const { aadToken } = useAADDataPlane(databaseAccount); const [authType, setAuthType] = React.useState(encryptedToken ? AuthType.EncryptedToken : undefined); const [connectionString, setConnectionString] = React.useState(); diff --git a/src/hooks/useAADAuth.ts b/src/hooks/useAADAuth.ts index 9defd7d96..1c6e946b2 100644 --- a/src/hooks/useAADAuth.ts +++ b/src/hooks/useAADAuth.ts @@ -1,7 +1,6 @@ import * as msal from "@azure/msal-browser"; import { useBoolean } from "@fluentui/react-hooks"; import * as React from "react"; -import { DatabaseAccount } from "../Contracts/DataModels"; const config: msal.Configuration = { cache: { @@ -105,22 +104,3 @@ export function useAADAuth(): ReturnType { switchTenant, }; } - -export function useAADDataPlane(databaseAccount: DatabaseAccount): { aadToken: string } { - const [aadToken, setAadToken] = React.useState(); - - React.useEffect(() => { - if (databaseAccount?.properties?.documentEndpoint) { - const hrefEndpoint = new URL(databaseAccount.properties.documentEndpoint).href.replace(/\/$/, "/.default"); - msalInstance - .acquireTokenSilent({ - scopes: [hrefEndpoint], - }) - .then((aadTokenResponse) => { - setAadToken(aadTokenResponse.accessToken); - }); - } - }, [databaseAccount]); - - return { aadToken }; -}