mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-16 17:25:58 +00:00
Remove one indirection for ConfigContext
Things like ConfigContext.BACKEND_ENDPOINT are dynamically changed, and assigning them statically like this only bypasses that mechanism :( Co-authored-by: Steve Faulkner <471400+southpolesteve@users.noreply.github.com>
This commit is contained in:
parent
f5bbd52311
commit
0cc38868a6
@ -1,5 +1,4 @@
|
|||||||
import { AutopilotTier } from "../Contracts/DataModels";
|
import { AutopilotTier } from "../Contracts/DataModels";
|
||||||
import { configContext } from "../ConfigContext";
|
|
||||||
import { HashMap } from "./HashMap";
|
import { HashMap } from "./HashMap";
|
||||||
|
|
||||||
export class AuthorizationEndpoints {
|
export class AuthorizationEndpoints {
|
||||||
@ -13,12 +12,6 @@ export class CodeOfConductEndpoints {
|
|||||||
public static termsOfUse: string = "https://aka.ms/ms-terms-of-use";
|
public static termsOfUse: string = "https://aka.ms/ms-terms-of-use";
|
||||||
}
|
}
|
||||||
|
|
||||||
export class BackendEndpoints {
|
|
||||||
public static localhost: string = "https://localhost:12900";
|
|
||||||
public static dev: string = "https://ext.documents-dev.windows-int.net";
|
|
||||||
public static productionPortal: string = configContext.BACKEND_ENDPOINT || "https://main.documentdb.ext.azure.com";
|
|
||||||
}
|
|
||||||
|
|
||||||
export class EndpointsRegex {
|
export class EndpointsRegex {
|
||||||
public static readonly cassandra = [
|
public static readonly cassandra = [
|
||||||
"AccountEndpoint=(.*).cassandra.cosmosdb.azure.com",
|
"AccountEndpoint=(.*).cassandra.cosmosdb.azure.com",
|
||||||
|
@ -14,7 +14,9 @@ describe("tokenProvider", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
window.dataExplorer = { extensionEndpoint: () => "https://main.documentdb.ext.azure.com" } as any;
|
updateConfigContext({
|
||||||
|
BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com"
|
||||||
|
});
|
||||||
window.fetch = jest.fn().mockImplementation(() => {
|
window.fetch = jest.fn().mockImplementation(() => {
|
||||||
return {
|
return {
|
||||||
json: () => "{}",
|
json: () => "{}",
|
||||||
@ -58,7 +60,9 @@ describe("getTokenFromAuthService", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("builds the correct URL in production", () => {
|
it("builds the correct URL in production", () => {
|
||||||
window.dataExplorer = { extensionEndpoint: () => "https://main.documentdb.ext.azure.com" } as any;
|
updateConfigContext({
|
||||||
|
BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com"
|
||||||
|
});
|
||||||
getTokenFromAuthService("GET", "dbs", "foo");
|
getTokenFromAuthService("GET", "dbs", "foo");
|
||||||
expect(window.fetch).toHaveBeenCalledWith(
|
expect(window.fetch).toHaveBeenCalledWith(
|
||||||
"https://main.documentdb.ext.azure.com/api/guest/runtimeproxy/authorizationTokens",
|
"https://main.documentdb.ext.azure.com/api/guest/runtimeproxy/authorizationTokens",
|
||||||
|
@ -52,7 +52,7 @@ export const endpoint = () => {
|
|||||||
|
|
||||||
export async function getTokenFromAuthService(verb: string, resourceType: string, resourceId?: string): Promise<any> {
|
export async function getTokenFromAuthService(verb: string, resourceType: string, resourceId?: string): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const host = configContext.BACKEND_ENDPOINT || _global.dataExplorer.extensionEndpoint();
|
const host = configContext.BACKEND_ENDPOINT;
|
||||||
const response = await _global.fetch(host + "/api/guest/runtimeproxy/authorizationTokens", {
|
const response = await _global.fetch(host + "/api/guest/runtimeproxy/authorizationTokens", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@ -85,8 +85,7 @@ export function client(): Cosmos.CosmosClient {
|
|||||||
userAgentSuffix: "Azure Portal"
|
userAgentSuffix: "Azure Portal"
|
||||||
};
|
};
|
||||||
|
|
||||||
// In development we proxy requests to the backend via webpack. This is removed in production bundles.
|
if (configContext.PROXY_PATH !== undefined) {
|
||||||
if (process.env.NODE_ENV === "development") {
|
|
||||||
(options as any).plugins = [{ on: "request", plugin: requestPlugin }];
|
(options as any).plugins = [{ on: "request", plugin: requestPlugin }];
|
||||||
}
|
}
|
||||||
return new Cosmos.CosmosClient(options);
|
return new Cosmos.CosmosClient(options);
|
||||||
|
@ -63,10 +63,9 @@ describe("MongoProxyClient", () => {
|
|||||||
updateUserContext({
|
updateUserContext({
|
||||||
databaseAccount
|
databaseAccount
|
||||||
});
|
});
|
||||||
window.dataExplorer = {
|
updateConfigContext({
|
||||||
extensionEndpoint: () => "https://main.documentdb.ext.azure.com",
|
BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com"
|
||||||
serverId: () => ""
|
});
|
||||||
} as any;
|
|
||||||
window.fetch = jest.fn().mockImplementation(fetchMock);
|
window.fetch = jest.fn().mockImplementation(fetchMock);
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -96,10 +95,9 @@ describe("MongoProxyClient", () => {
|
|||||||
updateUserContext({
|
updateUserContext({
|
||||||
databaseAccount
|
databaseAccount
|
||||||
});
|
});
|
||||||
window.dataExplorer = {
|
updateConfigContext({
|
||||||
extensionEndpoint: () => "https://main.documentdb.ext.azure.com",
|
BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com"
|
||||||
serverId: () => ""
|
});
|
||||||
} as any;
|
|
||||||
window.fetch = jest.fn().mockImplementation(fetchMock);
|
window.fetch = jest.fn().mockImplementation(fetchMock);
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -129,10 +127,9 @@ describe("MongoProxyClient", () => {
|
|||||||
updateUserContext({
|
updateUserContext({
|
||||||
databaseAccount
|
databaseAccount
|
||||||
});
|
});
|
||||||
window.dataExplorer = {
|
updateConfigContext({
|
||||||
extensionEndpoint: () => "https://main.documentdb.ext.azure.com",
|
BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com"
|
||||||
serverId: () => ""
|
});
|
||||||
} as any;
|
|
||||||
window.fetch = jest.fn().mockImplementation(fetchMock);
|
window.fetch = jest.fn().mockImplementation(fetchMock);
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -162,10 +159,9 @@ describe("MongoProxyClient", () => {
|
|||||||
updateUserContext({
|
updateUserContext({
|
||||||
databaseAccount
|
databaseAccount
|
||||||
});
|
});
|
||||||
window.dataExplorer = {
|
updateConfigContext({
|
||||||
extensionEndpoint: () => "https://main.documentdb.ext.azure.com",
|
BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com"
|
||||||
serverId: () => ""
|
});
|
||||||
} as any;
|
|
||||||
window.fetch = jest.fn().mockImplementation(fetchMock);
|
window.fetch = jest.fn().mockImplementation(fetchMock);
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -195,10 +191,9 @@ describe("MongoProxyClient", () => {
|
|||||||
updateUserContext({
|
updateUserContext({
|
||||||
databaseAccount
|
databaseAccount
|
||||||
});
|
});
|
||||||
window.dataExplorer = {
|
updateConfigContext({
|
||||||
extensionEndpoint: () => "https://main.documentdb.ext.azure.com",
|
BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com"
|
||||||
serverId: () => ""
|
});
|
||||||
} as any;
|
|
||||||
window.fetch = jest.fn().mockImplementation(fetchMock);
|
window.fetch = jest.fn().mockImplementation(fetchMock);
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -229,10 +224,9 @@ describe("MongoProxyClient", () => {
|
|||||||
updateUserContext({
|
updateUserContext({
|
||||||
databaseAccount
|
databaseAccount
|
||||||
});
|
});
|
||||||
window.dataExplorer = {
|
updateConfigContext({
|
||||||
extensionEndpoint: () => "https://main.documentdb.ext.azure.com",
|
BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com"
|
||||||
serverId: () => ""
|
});
|
||||||
} as any;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns a production endpoint", () => {
|
it("returns a production endpoint", () => {
|
||||||
|
@ -327,8 +327,7 @@ export function createMongoCollectionWithProxy(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getEndpoint(): string {
|
export function getEndpoint(): string {
|
||||||
const extensionEndpoint = window.dataExplorer.extensionEndpoint();
|
let url = (configContext.MONGO_BACKEND_ENDPOINT || configContext.BACKEND_ENDPOINT) + "/api/mongo/explorer";
|
||||||
let url = (configContext.MONGO_BACKEND_ENDPOINT || extensionEndpoint) + "/api/mongo/explorer";
|
|
||||||
|
|
||||||
if (window.authType === AuthType.EncryptedToken) {
|
if (window.authType === AuthType.EncryptedToken) {
|
||||||
url = url.replace("api/mongo", "api/guest/mongo");
|
url = url.replace("api/mongo", "api/guest/mongo");
|
||||||
|
@ -9,8 +9,7 @@ describe("updateOfferThroughputBeyondLimit", () => {
|
|||||||
});
|
});
|
||||||
window.dataExplorer = {
|
window.dataExplorer = {
|
||||||
logConsoleData: jest.fn(),
|
logConsoleData: jest.fn(),
|
||||||
deleteInProgressConsoleDataWithId: jest.fn(),
|
deleteInProgressConsoleDataWithId: jest.fn()
|
||||||
extensionEndpoint: jest.fn()
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
} as any;
|
} as any;
|
||||||
await updateOfferThroughputBeyondLimit({
|
await updateOfferThroughputBeyondLimit({
|
||||||
|
@ -28,8 +28,7 @@ export async function updateOfferThroughputBeyondLimit(request: UpdateOfferThrou
|
|||||||
`Requesting increase in throughput to ${request.throughput} for ${resourceDescriptionInfo}`
|
`Requesting increase in throughput to ${request.throughput} for ${resourceDescriptionInfo}`
|
||||||
);
|
);
|
||||||
|
|
||||||
const explorer = window.dataExplorer;
|
const url = `${configContext.BACKEND_ENDPOINT}/api/offerthroughputrequest/updatebeyondspecifiedlimit`;
|
||||||
const url = `${explorer.extensionEndpoint()}/api/offerthroughputrequest/updatebeyondspecifiedlimit`;
|
|
||||||
const authorizationHeader = getAuthorizationHeader();
|
const authorizationHeader = getAuthorizationHeader();
|
||||||
|
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
|
@ -953,7 +953,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"validPartitionKeyValue": [Function],
|
"validPartitionKeyValue": [Function],
|
||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
"extensionEndpoint": [Function],
|
|
||||||
"features": [Function],
|
"features": [Function],
|
||||||
"flight": [Function],
|
"flight": [Function],
|
||||||
"graphStylingPane": GraphStylingPane {
|
"graphStylingPane": GraphStylingPane {
|
||||||
@ -2268,7 +2267,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"validPartitionKeyValue": [Function],
|
"validPartitionKeyValue": [Function],
|
||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
"extensionEndpoint": [Function],
|
|
||||||
"features": [Function],
|
"features": [Function],
|
||||||
"flight": [Function],
|
"flight": [Function],
|
||||||
"graphStylingPane": GraphStylingPane {
|
"graphStylingPane": GraphStylingPane {
|
||||||
@ -3596,7 +3594,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"validPartitionKeyValue": [Function],
|
"validPartitionKeyValue": [Function],
|
||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
"extensionEndpoint": [Function],
|
|
||||||
"features": [Function],
|
"features": [Function],
|
||||||
"flight": [Function],
|
"flight": [Function],
|
||||||
"graphStylingPane": GraphStylingPane {
|
"graphStylingPane": GraphStylingPane {
|
||||||
@ -4911,7 +4908,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"validPartitionKeyValue": [Function],
|
"validPartitionKeyValue": [Function],
|
||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
"extensionEndpoint": [Function],
|
|
||||||
"features": [Function],
|
"features": [Function],
|
||||||
"flight": [Function],
|
"flight": [Function],
|
||||||
"graphStylingPane": GraphStylingPane {
|
"graphStylingPane": GraphStylingPane {
|
||||||
|
@ -140,7 +140,6 @@ export default class Explorer {
|
|||||||
public canSaveQueries: ko.Computed<boolean>;
|
public canSaveQueries: ko.Computed<boolean>;
|
||||||
public features: ko.Observable<any>;
|
public features: ko.Observable<any>;
|
||||||
public serverId: ko.Observable<string>;
|
public serverId: ko.Observable<string>;
|
||||||
public extensionEndpoint: ko.Observable<string>;
|
|
||||||
public armEndpoint: ko.Observable<string>;
|
public armEndpoint: ko.Observable<string>;
|
||||||
public isTryCosmosDBSubscription: ko.Observable<boolean>;
|
public isTryCosmosDBSubscription: ko.Observable<boolean>;
|
||||||
public notificationsClient: NotificationsClientBase;
|
public notificationsClient: NotificationsClientBase;
|
||||||
@ -383,7 +382,6 @@ export default class Explorer {
|
|||||||
|
|
||||||
this.features = ko.observable();
|
this.features = ko.observable();
|
||||||
this.serverId = ko.observable<string>();
|
this.serverId = ko.observable<string>();
|
||||||
this.extensionEndpoint = ko.observable<string>(undefined);
|
|
||||||
this.armEndpoint = ko.observable<string>(undefined);
|
this.armEndpoint = ko.observable<string>(undefined);
|
||||||
this.queriesClient = new QueriesClient(this);
|
this.queriesClient = new QueriesClient(this);
|
||||||
this.isTryCosmosDBSubscription = ko.observable<boolean>(false);
|
this.isTryCosmosDBSubscription = ko.observable<boolean>(false);
|
||||||
@ -1912,9 +1910,8 @@ export default class Explorer {
|
|||||||
}
|
}
|
||||||
this.features(inputs.features);
|
this.features(inputs.features);
|
||||||
this.serverId(inputs.serverId);
|
this.serverId(inputs.serverId);
|
||||||
this.extensionEndpoint(inputs.extensionEndpoint || "");
|
|
||||||
this.armEndpoint(EnvironmentUtility.normalizeArmEndpointUri(inputs.csmEndpoint || configContext.ARM_ENDPOINT));
|
this.armEndpoint(EnvironmentUtility.normalizeArmEndpointUri(inputs.csmEndpoint || configContext.ARM_ENDPOINT));
|
||||||
this.notificationsClient.setExtensionEndpoint(this.extensionEndpoint());
|
this.notificationsClient.setExtensionEndpoint(configContext.BACKEND_ENDPOINT);
|
||||||
this.databaseAccount(databaseAccount);
|
this.databaseAccount(databaseAccount);
|
||||||
this.subscriptionType(inputs.subscriptionType);
|
this.subscriptionType(inputs.subscriptionType);
|
||||||
this.quotaId(inputs.quotaId);
|
this.quotaId(inputs.quotaId);
|
||||||
@ -1930,6 +1927,7 @@ export default class Explorer {
|
|||||||
this._importExplorerConfigComplete = true;
|
this._importExplorerConfigComplete = true;
|
||||||
|
|
||||||
updateConfigContext({
|
updateConfigContext({
|
||||||
|
BACKEND_ENDPOINT: inputs.extensionEndpoint || "",
|
||||||
ARM_ENDPOINT: this.armEndpoint()
|
ARM_ENDPOINT: this.armEndpoint()
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -2633,7 +2631,7 @@ export default class Explorer {
|
|||||||
|
|
||||||
const databaseAccount = this.databaseAccount();
|
const databaseAccount = this.databaseAccount();
|
||||||
const databaseAccountLocation = databaseAccount && databaseAccount.location.toLowerCase();
|
const databaseAccountLocation = databaseAccount && databaseAccount.location.toLowerCase();
|
||||||
const disallowedLocationsUri = `${this.extensionEndpoint()}/api/disallowedLocations`;
|
const disallowedLocationsUri = `${configContext.BACKEND_ENDPOINT}/api/disallowedLocations`;
|
||||||
const authorizationHeader = getAuthorizationHeader();
|
const authorizationHeader = getAuthorizationHeader();
|
||||||
try {
|
try {
|
||||||
const response = await fetch(disallowedLocationsUri, {
|
const response = await fetch(disallowedLocationsUri, {
|
||||||
|
@ -22,6 +22,7 @@ import {
|
|||||||
updateDocument,
|
updateDocument,
|
||||||
createDocument
|
createDocument
|
||||||
} from "../../Common/DocumentClientUtilityBase";
|
} from "../../Common/DocumentClientUtilityBase";
|
||||||
|
import { configContext } from "../../ConfigContext";
|
||||||
|
|
||||||
export interface CassandraTableKeys {
|
export interface CassandraTableKeys {
|
||||||
partitionKeys: CassandraTableKey[];
|
partitionKeys: CassandraTableKey[];
|
||||||
@ -307,7 +308,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
|||||||
authType === AuthType.EncryptedToken
|
authType === AuthType.EncryptedToken
|
||||||
? Constants.CassandraBackend.guestQueryApi
|
? Constants.CassandraBackend.guestQueryApi
|
||||||
: Constants.CassandraBackend.queryApi;
|
: Constants.CassandraBackend.queryApi;
|
||||||
$.ajax(`${collection.container.extensionEndpoint()}/${apiEndpoint}`, {
|
$.ajax(`${configContext.BACKEND_ENDPOINT}/${apiEndpoint}`, {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: {
|
data: {
|
||||||
accountName: collection && collection.container.databaseAccount && collection.container.databaseAccount().name,
|
accountName: collection && collection.container.databaseAccount && collection.container.databaseAccount().name,
|
||||||
@ -558,7 +559,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
|||||||
authType === AuthType.EncryptedToken
|
authType === AuthType.EncryptedToken
|
||||||
? Constants.CassandraBackend.guestKeysApi
|
? Constants.CassandraBackend.guestKeysApi
|
||||||
: Constants.CassandraBackend.keysApi;
|
: Constants.CassandraBackend.keysApi;
|
||||||
let endpoint = `${collection.container.extensionEndpoint()}/${apiEndpoint}`;
|
let endpoint = `${configContext.BACKEND_ENDPOINT}/${apiEndpoint}`;
|
||||||
const deferred = Q.defer<CassandraTableKeys>();
|
const deferred = Q.defer<CassandraTableKeys>();
|
||||||
$.ajax(endpoint, {
|
$.ajax(endpoint, {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@ -613,7 +614,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
|||||||
authType === AuthType.EncryptedToken
|
authType === AuthType.EncryptedToken
|
||||||
? Constants.CassandraBackend.guestSchemaApi
|
? Constants.CassandraBackend.guestSchemaApi
|
||||||
: Constants.CassandraBackend.schemaApi;
|
: Constants.CassandraBackend.schemaApi;
|
||||||
let endpoint = `${collection.container.extensionEndpoint()}/${apiEndpoint}`;
|
let endpoint = `${configContext.BACKEND_ENDPOINT}/${apiEndpoint}`;
|
||||||
const deferred = Q.defer<CassandraTableKey[]>();
|
const deferred = Q.defer<CassandraTableKey[]>();
|
||||||
$.ajax(endpoint, {
|
$.ajax(endpoint, {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@ -667,7 +668,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
|||||||
authType === AuthType.EncryptedToken
|
authType === AuthType.EncryptedToken
|
||||||
? Constants.CassandraBackend.guestCreateOrDeleteApi
|
? Constants.CassandraBackend.guestCreateOrDeleteApi
|
||||||
: Constants.CassandraBackend.createOrDeleteApi;
|
: Constants.CassandraBackend.createOrDeleteApi;
|
||||||
$.ajax(`${explorer.extensionEndpoint()}/${apiEndpoint}`, {
|
$.ajax(`${configContext.BACKEND_ENDPOINT}/${apiEndpoint}`, {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: {
|
data: {
|
||||||
accountName: explorer.databaseAccount() && explorer.databaseAccount().name,
|
accountName: explorer.databaseAccount() && explorer.databaseAccount().name,
|
||||||
|
@ -13,6 +13,7 @@ import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"
|
|||||||
import { PlatformType } from "../../PlatformType";
|
import { PlatformType } from "../../PlatformType";
|
||||||
import Explorer from "../Explorer";
|
import Explorer from "../Explorer";
|
||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
|
import { configContext } from "../../ConfigContext";
|
||||||
|
|
||||||
export default class MongoShellTab extends TabsBase {
|
export default class MongoShellTab extends TabsBase {
|
||||||
public url: ko.Computed<string>;
|
public url: ko.Computed<string>;
|
||||||
@ -30,9 +31,8 @@ export default class MongoShellTab extends TabsBase {
|
|||||||
const accountName = account && account.name;
|
const accountName = account && account.name;
|
||||||
const mongoEndpoint = account && (account.properties.mongoEndpoint || account.properties.documentEndpoint);
|
const mongoEndpoint = account && (account.properties.mongoEndpoint || account.properties.documentEndpoint);
|
||||||
|
|
||||||
this._runtimeEndpoint =
|
this._runtimeEndpoint = window.dataExplorerPlatform === PlatformType.Hosted ? configContext.BACKEND_ENDPOINT : "";
|
||||||
window.dataExplorerPlatform == PlatformType.Hosted ? AuthHeadersUtil.extensionEndpoint : "";
|
const extensionEndpoint: string = configContext.BACKEND_ENDPOINT || this._runtimeEndpoint || "";
|
||||||
const extensionEndpoint: string = this._container.extensionEndpoint() || this._runtimeEndpoint || "";
|
|
||||||
let baseUrl = "/content/mongoshell/dist/";
|
let baseUrl = "/content/mongoshell/dist/";
|
||||||
if (this._container.serverId() === "localhost") {
|
if (this._container.serverId() === "localhost") {
|
||||||
baseUrl = "/content/mongoshell/";
|
baseUrl = "/content/mongoshell/";
|
||||||
@ -108,7 +108,7 @@ export default class MongoShellTab extends TabsBase {
|
|||||||
) + Constants.MongoDBAccounts.defaultPort.toString();
|
) + Constants.MongoDBAccounts.defaultPort.toString();
|
||||||
const databaseId = this.collection.databaseId;
|
const databaseId = this.collection.databaseId;
|
||||||
const collectionId = this.collection.id();
|
const collectionId = this.collection.id();
|
||||||
const apiEndpoint = this._container.extensionEndpoint();
|
const apiEndpoint = configContext.BACKEND_ENDPOINT;
|
||||||
const encryptedAuthToken: string = userContext.accessToken;
|
const encryptedAuthToken: string = userContext.accessToken;
|
||||||
|
|
||||||
shellIframe.contentWindow.postMessage(
|
shellIframe.contentWindow.postMessage(
|
||||||
@ -125,7 +125,7 @@ export default class MongoShellTab extends TabsBase {
|
|||||||
apiEndpoint: apiEndpoint
|
apiEndpoint: apiEndpoint
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
this._container.extensionEndpoint()
|
configContext.BACKEND_ENDPOINT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,8 +12,6 @@ import { configContext } from "../../ConfigContext";
|
|||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
|
|
||||||
export default class AuthHeadersUtil {
|
export default class AuthHeadersUtil {
|
||||||
// TODO: Figure out a way to determine the extension endpoint and serverId at runtime
|
|
||||||
public static extensionEndpoint: string = Constants.BackendEndpoints.productionPortal;
|
|
||||||
public static serverId: string = Constants.ServerIds.productionPortal;
|
public static serverId: string = Constants.ServerIds.productionPortal;
|
||||||
|
|
||||||
private static readonly _firstPartyAppId: string = "203f1145-856a-4232-83d4-a43568fba23d";
|
private static readonly _firstPartyAppId: string = "203f1145-856a-4232-83d4-a43568fba23d";
|
||||||
@ -41,7 +39,7 @@ export default class AuthHeadersUtil {
|
|||||||
|
|
||||||
public static getAccessInputMetadata(accessInput: string): Q.Promise<DataModels.AccessInputMetadata> {
|
public static getAccessInputMetadata(accessInput: string): Q.Promise<DataModels.AccessInputMetadata> {
|
||||||
const deferred: Q.Deferred<DataModels.AccessInputMetadata> = Q.defer<DataModels.AccessInputMetadata>();
|
const deferred: Q.Deferred<DataModels.AccessInputMetadata> = Q.defer<DataModels.AccessInputMetadata>();
|
||||||
const url: string = `${AuthHeadersUtil.extensionEndpoint}${Constants.ApiEndpoints.guestRuntimeProxy}/accessinputmetadata`;
|
const url = `${configContext.BACKEND_ENDPOINT}${Constants.ApiEndpoints.guestRuntimeProxy}/accessinputmetadata`;
|
||||||
const authType: string = (<any>window).authType;
|
const authType: string = (<any>window).authType;
|
||||||
const headers: { [headerName: string]: string } = {};
|
const headers: { [headerName: string]: string } = {};
|
||||||
|
|
||||||
@ -86,9 +84,7 @@ export default class AuthHeadersUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static generateEncryptedToken(): Q.Promise<DataModels.GenerateTokenResponse> {
|
public static generateEncryptedToken(): Q.Promise<DataModels.GenerateTokenResponse> {
|
||||||
const url: string = `${
|
const url = configContext.BACKEND_ENDPOINT + "/api/tokens/generateToken" + AuthHeadersUtil._generateResourceUrl();
|
||||||
AuthHeadersUtil.extensionEndpoint
|
|
||||||
}/api/tokens/generateToken${AuthHeadersUtil._generateResourceUrl()}`;
|
|
||||||
const explorer = window.dataExplorer;
|
const explorer = window.dataExplorer;
|
||||||
const headers: any = { authorization: userContext.authorizationToken };
|
const headers: any = { authorization: userContext.authorizationToken };
|
||||||
headers[Constants.HttpHeaders.getReadOnlyKey] = !explorer.hasWriteAccess();
|
headers[Constants.HttpHeaders.getReadOnlyKey] = !explorer.hasWriteAccess();
|
||||||
@ -109,7 +105,7 @@ export default class AuthHeadersUtil {
|
|||||||
return Q.reject("None or empty connection string specified");
|
return Q.reject("None or empty connection string specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
const url: string = `${AuthHeadersUtil.extensionEndpoint}/api/guest/tokens/generateToken`;
|
const url = configContext.BACKEND_ENDPOINT + "/api/guest/tokens/generateToken";
|
||||||
const headers: any = {};
|
const headers: any = {};
|
||||||
headers[Constants.HttpHeaders.connectionString] = connectionString;
|
headers[Constants.HttpHeaders.connectionString] = connectionString;
|
||||||
|
|
||||||
|
@ -24,12 +24,12 @@ import { SubscriptionUtilMappings } from "../../Shared/Constants";
|
|||||||
import "../../Explorer/Tables/DataTable/DataTableBindingManager";
|
import "../../Explorer/Tables/DataTable/DataTableBindingManager";
|
||||||
import Explorer from "../../Explorer/Explorer";
|
import Explorer from "../../Explorer/Explorer";
|
||||||
import { updateUserContext } from "../../UserContext";
|
import { updateUserContext } from "../../UserContext";
|
||||||
|
import { configContext } from "../../ConfigContext";
|
||||||
|
|
||||||
export default class Main {
|
export default class Main {
|
||||||
private static _databaseAccountId: string;
|
private static _databaseAccountId: string;
|
||||||
private static _encryptedToken: string;
|
private static _encryptedToken: string;
|
||||||
private static _accessInputMetadata: AccessInputMetadata;
|
private static _accessInputMetadata: AccessInputMetadata;
|
||||||
private static _defaultSubscriptionType: ViewModels.SubscriptionType = ViewModels.SubscriptionType.Free;
|
|
||||||
private static _features: { [key: string]: string };
|
private static _features: { [key: string]: string };
|
||||||
// For AAD, Need to post message to hosted frame to do the auth
|
// For AAD, Need to post message to hosted frame to do the auth
|
||||||
// Use local deferred variable as work around until we find better solution
|
// Use local deferred variable as work around until we find better solution
|
||||||
@ -315,7 +315,7 @@ export default class Main {
|
|||||||
csmEndpoint: undefined,
|
csmEndpoint: undefined,
|
||||||
dnsSuffix: null,
|
dnsSuffix: null,
|
||||||
serverId: serverId,
|
serverId: serverId,
|
||||||
extensionEndpoint: AuthHeadersUtil.extensionEndpoint,
|
extensionEndpoint: configContext.BACKEND_ENDPOINT,
|
||||||
subscriptionType: CollectionCreation.DefaultSubscriptionType,
|
subscriptionType: CollectionCreation.DefaultSubscriptionType,
|
||||||
quotaId: undefined,
|
quotaId: undefined,
|
||||||
addCollectionDefaultFlight: explorer.flight(),
|
addCollectionDefaultFlight: explorer.flight(),
|
||||||
@ -335,7 +335,7 @@ export default class Main {
|
|||||||
csmEndpoint: undefined,
|
csmEndpoint: undefined,
|
||||||
dnsSuffix: null,
|
dnsSuffix: null,
|
||||||
serverId: serverId,
|
serverId: serverId,
|
||||||
extensionEndpoint: AuthHeadersUtil.extensionEndpoint,
|
extensionEndpoint: configContext.BACKEND_ENDPOINT,
|
||||||
subscriptionType: CollectionCreation.DefaultSubscriptionType,
|
subscriptionType: CollectionCreation.DefaultSubscriptionType,
|
||||||
quotaId: undefined,
|
quotaId: undefined,
|
||||||
addCollectionDefaultFlight: explorer.flight(),
|
addCollectionDefaultFlight: explorer.flight(),
|
||||||
@ -365,7 +365,7 @@ export default class Main {
|
|||||||
csmEndpoint: undefined,
|
csmEndpoint: undefined,
|
||||||
dnsSuffix: null,
|
dnsSuffix: null,
|
||||||
serverId: serverId,
|
serverId: serverId,
|
||||||
extensionEndpoint: AuthHeadersUtil.extensionEndpoint,
|
extensionEndpoint: configContext.BACKEND_ENDPOINT,
|
||||||
subscriptionType: CollectionCreation.DefaultSubscriptionType,
|
subscriptionType: CollectionCreation.DefaultSubscriptionType,
|
||||||
quotaId: undefined,
|
quotaId: undefined,
|
||||||
addCollectionDefaultFlight: explorer.flight(),
|
addCollectionDefaultFlight: explorer.flight(),
|
||||||
@ -453,11 +453,6 @@ export default class Main {
|
|||||||
return connectionString && connectionString.includes("type=resource");
|
return connectionString && connectionString.includes("type=resource");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static _getSubscriptionTypeFromQuotaId(quotaId: string): ViewModels.SubscriptionType {
|
|
||||||
const subscriptionType: ViewModels.SubscriptionType = SubscriptionUtilMappings.SubscriptionTypeMap[quotaId];
|
|
||||||
return subscriptionType || Main._defaultSubscriptionType;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static _renewExplorerAccessWithResourceToken = (
|
private static _renewExplorerAccessWithResourceToken = (
|
||||||
explorer: Explorer,
|
explorer: Explorer,
|
||||||
connectionString: string
|
connectionString: string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user