Remove connection string validation for connection string login

- Remove validateDirectConnectionStringLogin and its helpers (extractEndpointHostFromConnectionString, extractHostToken, directLoginAllowlistedEndpointZones)
- Remove old extractMasterKeyfromConnectionString (Gremlin-specific), rename extractAccountKeyFromConnectionString to extractMasterKeyfromConnectionString
- Change validateDirectConnectionStringConnectivity to throw on error instead of returning string|undefined
- Simplify direct-login flow: submit connection string to CosmosClient as-is, no format or endpoint validation
- Keep connectivity pre-check (throws if CosmosClient cannot reach account)
- Remove 6 unused localization keys for validation errors
- Update tests to match new behavior
This commit is contained in:
Asier Isayas
2026-08-17 06:47:22 -07:00
parent a2d24cc972
commit ea42796379
7 changed files with 29 additions and 266 deletions
+4 -28
View File
@@ -23,12 +23,7 @@ import { SignInButton } from "./Platform/Hosted/Components/SignInButton";
import "./Platform/Hosted/ConnectScreen.less";
import { parseConnectionString } from "./Platform/Hosted/Helpers/ConnectionStringParser";
import { isResourceTokenConnectionString } from "./Platform/Hosted/Helpers/ResourceTokenUtils";
import {
extractAccountKeyFromConnectionString,
extractMasterKeyfromConnectionString,
isDirectConnectionStringLoginApi,
validateDirectConnectionStringLogin,
} from "./Platform/Hosted/HostedUtils";
import { extractMasterKeyfromConnectionString, isDirectConnectionStringLoginApi } from "./Platform/Hosted/HostedUtils";
import "./Shared/appInsights";
import { allowedHostedExplorerEndpoints } from "./Utils/EndpointUtils";
import { useAADAuth } from "./hooks/useAADAuth";
@@ -74,31 +69,14 @@ const App: React.FunctionComponent = () => {
if (metadata && isDirectConnectionStringLoginApi(metadata.apiKind)) {
// SQL, Tables, and Gremlin sign data-plane requests client-side with the account key, so we skip
// the Portal Backend proxy and use the metadata derived from the connection string directly.
// Validate the host and account client-side (mirrors the backend's ValidateHostAndAccount).
const validationError = validateDirectConnectionStringLogin(connStr, metadata);
if (validationError) {
logError(
`Rejected connection string for direct login: ${validationError}`,
"HostedExplorer/connectWithConnectionString",
);
return;
}
// Only open the view once we confirm the Cosmos client can actually connect.
validateDirectConnectionStringConnectivity(connStr, metadata)
.then((connectivityError) => {
if (connectivityError) {
logError(
`Rejected connection string for direct login: ${connectivityError}`,
"HostedExplorer/connectWithConnectionString",
);
return;
}
.then(() => {
setDirectLoginMetadata(metadata);
setAuthType(AuthType.ConnectionString);
})
.catch((error) => {
logError(
`Failed to validate connection string for direct login: ${error}`,
`Failed to connect with connection string: ${error}`,
"HostedExplorer/connectWithConnectionString",
);
});
@@ -167,9 +145,7 @@ const App: React.FunctionComponent = () => {
authType: AuthType.ConnectionString,
encryptedToken,
encryptedTokenMetadata: accountMetadata,
masterKey: directLoginMetadata
? extractAccountKeyFromConnectionString(connectionString)
: extractMasterKeyfromConnectionString(connectionString),
masterKey: extractMasterKeyfromConnectionString(connectionString),
};
} else if (authType === AuthType.ResourceToken) {
frameWindow.hostedConfig = {