mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-09-19 17:12:47 +01:00
Drop unused mongodb:// branch from endpoint host extraction
This commit is contained in:
@@ -64,8 +64,9 @@ export const validateDirectConnectionStringConnectivity = async (
|
|||||||
return t(Keys.connectExplorer.errors.connectivityInvalid);
|
return t(Keys.connectExplorer.errors.connectivityInvalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure the client the same way the Data Explorer will, then issue a lightweight authenticated
|
// The Cosmos client reads its connection settings from userContext, so write the master key and
|
||||||
// request. The Cosmos client signs locally with the master key and routes through the same proxy.
|
// endpoint there. Then we issue a lightweight authenticated read to confirm the
|
||||||
|
// credentials work.
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
authType: AuthType.ConnectionString,
|
authType: AuthType.ConnectionString,
|
||||||
masterKey,
|
masterKey,
|
||||||
|
|||||||
@@ -45,9 +45,7 @@ export function parseConnectionString(connectionString: string): AccessInputMeta
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For the APIs that log in directly through the Cosmos client (SQL, Tables, Gremlin), derive the
|
// For the APIs that log in directly through the Cosmos client (SQL, Tables, Gremlin), derive the
|
||||||
// endpoints client-side instead of Portal Backend's accessinputmetadata call. Tables
|
// endpoints client-side instead of Portal Backend's accessinputmetadata call.
|
||||||
// connection strings only carry the table endpoint, so the document endpoint is always constructed
|
|
||||||
// from the account name. Gremlin also needs its graph endpoint for websocket queries.
|
|
||||||
if (accessInput.accountName) {
|
if (accessInput.accountName) {
|
||||||
if (
|
if (
|
||||||
accessInput.apiKind === ApiKind.SQL ||
|
accessInput.apiKind === ApiKind.SQL ||
|
||||||
|
|||||||
@@ -55,8 +55,7 @@ export function extractAccountKeyFromConnectionString(connectionString: string):
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SQL, Tables, and Gremlin can sign data-plane requests client-side with the account key, so they do
|
// SQL, Tables, and Gremlin can sign data-plane requests client-side with the account key, so they do
|
||||||
// not need the Portal Backend proxy for connection-string login. Mongo and Cassandra still require the
|
// not need the Portal Backend proxy for connection-string login. Mongo and Cassandra still require the proxy.
|
||||||
// proxy because they use wire protocols the browser cannot speak directly.
|
|
||||||
export function isDirectConnectionStringLoginApi(apiKind: ApiKind): boolean {
|
export function isDirectConnectionStringLoginApi(apiKind: ApiKind): boolean {
|
||||||
return apiKind === ApiKind.SQL || apiKind === ApiKind.Table || apiKind === ApiKind.Graph;
|
return apiKind === ApiKind.SQL || apiKind === ApiKind.Table || apiKind === ApiKind.Graph;
|
||||||
}
|
}
|
||||||
@@ -86,19 +85,11 @@ function extractHostToken(value: string, startIndex: number): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Extracts the endpoint host from a connection string, mirroring ExtractEndpointHost in the Portal
|
// Extracts the endpoint host from a connection string, mirroring ExtractEndpointHost in the Portal
|
||||||
// Backend. Handles AccountEndpoint/TableEndpoint (URI or bare host), HostName, and mongodb:// segments.
|
// Backend. Handles AccountEndpoint/TableEndpoint (URI or bare host) and HostName.
|
||||||
export function extractEndpointHostFromConnectionString(connectionString: string): string | undefined {
|
export function extractEndpointHostFromConnectionString(connectionString: string): string | undefined {
|
||||||
for (const part of connectionString.split(";")) {
|
for (const part of connectionString.split(";")) {
|
||||||
const trimmed = part.trim();
|
const trimmed = part.trim();
|
||||||
|
|
||||||
if (trimmed.toLowerCase().startsWith("mongodb://")) {
|
|
||||||
const atIndex = trimmed.indexOf("@");
|
|
||||||
if (atIndex >= 0 && atIndex < trimmed.length - 1) {
|
|
||||||
return extractHostToken(trimmed, atIndex + 1);
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const equalsIndex = trimmed.indexOf("=");
|
const equalsIndex = trimmed.indexOf("=");
|
||||||
if (equalsIndex < 0 || equalsIndex === trimmed.length - 1) {
|
if (equalsIndex < 0 || equalsIndex === trimmed.length - 1) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user