mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-04-19 04:48:59 +01:00
Merge branch 'master' into users/aisayas/default-throughput-bucket
This commit is contained in:
5
package-lock.json
generated
5
package-lock.json
generated
@@ -15861,7 +15861,6 @@
|
|||||||
"version": "2.3.2",
|
"version": "2.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||||
"dev": true,
|
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -23861,7 +23860,9 @@
|
|||||||
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="
|
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="
|
||||||
},
|
},
|
||||||
"node_modules/picomatch": {
|
"node_modules/picomatch": {
|
||||||
"version": "2.3.1",
|
"version": "2.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz",
|
||||||
|
"integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8.6"
|
"node": ">=8.6"
|
||||||
|
|||||||
@@ -163,4 +163,42 @@ describe("AuthorizationUtils", () => {
|
|||||||
expect((instance as any)._config.auth.redirectUri).toBe("http://localhost/redirectBridge.html");
|
expect((instance as any)._config.auth.redirectUri).toBe("http://localhost/redirectBridge.html");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("getRedirectBridgeUrl()", () => {
|
||||||
|
const originalNodeEnv = process.env.NODE_ENV;
|
||||||
|
const originalPathname = window.location.pathname;
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
process.env.NODE_ENV = originalNodeEnv;
|
||||||
|
Object.defineProperty(window, "location", {
|
||||||
|
value: { ...window.location, pathname: originalPathname },
|
||||||
|
writable: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should use dev URL in development mode", () => {
|
||||||
|
process.env.NODE_ENV = "development";
|
||||||
|
expect(AuthorizationUtils.getRedirectBridgeUrl()).toBe(
|
||||||
|
"https://dataexplorer-dev.azurewebsites.net/redirectBridge.html",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should use MPAC path when on /mpac/", () => {
|
||||||
|
process.env.NODE_ENV = "production";
|
||||||
|
Object.defineProperty(window, "location", {
|
||||||
|
value: { origin: "https://cosmos.azure.com", pathname: "/mpac/explorer.html" },
|
||||||
|
writable: true,
|
||||||
|
});
|
||||||
|
expect(AuthorizationUtils.getRedirectBridgeUrl()).toBe("https://cosmos.azure.com/mpac/redirectBridge.html");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should use root path when not on /mpac/", () => {
|
||||||
|
process.env.NODE_ENV = "production";
|
||||||
|
Object.defineProperty(window, "location", {
|
||||||
|
value: { origin: "https://cosmos.azure.com", pathname: "/explorer.html" },
|
||||||
|
writable: true,
|
||||||
|
});
|
||||||
|
expect(AuthorizationUtils.getRedirectBridgeUrl()).toBe("https://cosmos.azure.com/redirectBridge.html");
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -50,12 +50,25 @@ export function decryptJWTToken(token: string) {
|
|||||||
return JSON.parse(tokenPayload);
|
return JSON.parse(tokenPayload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getRedirectBridgeUrl(): string {
|
||||||
|
if (process.env.NODE_ENV === "development") {
|
||||||
|
return "https://dataexplorer-dev.azurewebsites.net/redirectBridge.html";
|
||||||
|
}
|
||||||
|
const basePath = window.location.pathname.startsWith("/mpac/") ? "/mpac" : "";
|
||||||
|
return `${window.location.origin}${basePath}/redirectBridge.html`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getPostLogoutRedirectUrl(): string {
|
||||||
|
if (process.env.NODE_ENV === "development") {
|
||||||
|
return "https://dataexplorer-dev.azurewebsites.net/hostedExplorer.html";
|
||||||
|
}
|
||||||
|
const basePath = window.location.pathname.startsWith("/mpac/") ? "/mpac" : "";
|
||||||
|
return `${window.location.origin}${basePath}`;
|
||||||
|
}
|
||||||
|
|
||||||
export async function getMsalInstance() {
|
export async function getMsalInstance() {
|
||||||
// Compute the redirect bridge URL for MSAL v5 COOP handling
|
// Compute the redirect bridge URL for MSAL v5 COOP handling
|
||||||
const redirectBridgeUrl =
|
const redirectBridgeUrl = getRedirectBridgeUrl();
|
||||||
process.env.NODE_ENV === "development"
|
|
||||||
? "https://dataexplorer-dev.azurewebsites.net/redirectBridge.html"
|
|
||||||
: `${window.location.origin}/redirectBridge.html`;
|
|
||||||
|
|
||||||
const msalConfig: msal.Configuration = {
|
const msalConfig: msal.Configuration = {
|
||||||
cache: {
|
cache: {
|
||||||
|
|||||||
@@ -2,7 +2,12 @@ import * as msal from "@azure/msal-browser";
|
|||||||
import { useBoolean } from "@fluentui/react-hooks";
|
import { useBoolean } from "@fluentui/react-hooks";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { ConfigContext } from "../ConfigContext";
|
import { ConfigContext } from "../ConfigContext";
|
||||||
import { acquireTokenWithMsal, getMsalInstance } from "../Utils/AuthorizationUtils";
|
import {
|
||||||
|
acquireTokenWithMsal,
|
||||||
|
getMsalInstance,
|
||||||
|
getPostLogoutRedirectUrl,
|
||||||
|
getRedirectBridgeUrl,
|
||||||
|
} from "../Utils/AuthorizationUtils";
|
||||||
|
|
||||||
const cachedTenantId = localStorage.getItem("cachedTenantId");
|
const cachedTenantId = localStorage.getItem("cachedTenantId");
|
||||||
|
|
||||||
@@ -59,10 +64,7 @@ export function useAADAuth(config?: ConfigContext): ReturnType {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Use redirect bridge for MSAL v5 COOP handling
|
// Use redirect bridge for MSAL v5 COOP handling
|
||||||
const redirectBridgeUrl =
|
const redirectBridgeUrl = getRedirectBridgeUrl();
|
||||||
process.env.NODE_ENV === "development"
|
|
||||||
? "https://dataexplorer-dev.azurewebsites.net/redirectBridge.html"
|
|
||||||
: `${window.location.origin}/redirectBridge.html`;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await msalInstance.loginPopup({
|
const response = await msalInstance.loginPopup({
|
||||||
@@ -87,10 +89,7 @@ export function useAADAuth(config?: ConfigContext): ReturnType {
|
|||||||
setLoggedOut();
|
setLoggedOut();
|
||||||
localStorage.removeItem("cachedTenantId");
|
localStorage.removeItem("cachedTenantId");
|
||||||
// Redirect back to the hosted explorer after logout
|
// Redirect back to the hosted explorer after logout
|
||||||
const postLogoutRedirectUri =
|
const postLogoutRedirectUri = getPostLogoutRedirectUrl();
|
||||||
process.env.NODE_ENV === "development"
|
|
||||||
? "https://dataexplorer-dev.azurewebsites.net/hostedExplorer.html"
|
|
||||||
: `${window.location.origin}`;
|
|
||||||
msalInstance.logoutRedirect({ postLogoutRedirectUri });
|
msalInstance.logoutRedirect({ postLogoutRedirectUri });
|
||||||
}, [msalInstance]);
|
}, [msalInstance]);
|
||||||
|
|
||||||
@@ -100,10 +99,7 @@ export function useAADAuth(config?: ConfigContext): ReturnType {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Use redirect bridge for MSAL v5 COOP handling
|
// Use redirect bridge for MSAL v5 COOP handling
|
||||||
const redirectBridgeUrl =
|
const redirectBridgeUrl = getRedirectBridgeUrl();
|
||||||
process.env.NODE_ENV === "development"
|
|
||||||
? "https://dataexplorer-dev.azurewebsites.net/redirectBridge.html"
|
|
||||||
: `${window.location.origin}/redirectBridge.html`;
|
|
||||||
try {
|
try {
|
||||||
const response = await msalInstance.loginPopup({
|
const response = await msalInstance.loginPopup({
|
||||||
redirectUri: redirectBridgeUrl,
|
redirectUri: redirectBridgeUrl,
|
||||||
|
|||||||
Reference in New Issue
Block a user