Leave the encrypted token login path as it is on master

The direct connection string login work does not change how Mongo and Cassandra logins fail, so drop the 401/403 handling this branch added around fetchEncryptedToken along with the now unused isAuthorizationError helper.
This commit is contained in:
Asier Isayas
2026-08-19 14:29:24 -07:00
parent 5218c75ca0
commit 16126995f7
3 changed files with 4 additions and 42 deletions
@@ -6,13 +6,8 @@ import ConnectImage from "../../../../images/HdeConnectCosmosDB.svg";
import ErrorImage from "../../../../images/error.svg";
import { AuthType } from "../../../AuthType";
import { AccessInputMetadata } from "../../../Contracts/DataModels";
import { isAuthorizationError } from "../../../Utils/AuthorizationUtils";
import { parseConnectionString } from "../Helpers/ConnectionStringParser";
import {
fetchEncryptedToken,
isAccountRestrictedForConnectionStringLogin,
PortalBackendError,
} from "../Helpers/PortalBackendClient";
import { fetchEncryptedToken, isAccountRestrictedForConnectionStringLogin } from "../Helpers/PortalBackendClient";
import { isResourceTokenConnectionString } from "../Helpers/ResourceTokenUtils";
import { isDirectConnectionStringLoginApi } from "../HostedUtils";
@@ -78,22 +73,9 @@ export const ConnectExplorer: React.FunctionComponent<Props> = ({
return;
}
try {
const encryptedToken = await fetchEncryptedToken(connectionString);
setEncryptedToken(encryptedToken);
setAuthType(AuthType.ConnectionString);
} catch (error) {
// A 401 or 403 means the credentials or Portal Backend were not authorized.
// Any other failure is on the backend, so rather than block the login
// we sign in with the metadata parsed from the connection string.
if (!metadata || (error instanceof PortalBackendError && isAuthorizationError(error.statusCode))) {
setErrorMessage(getErrorMessage(error));
return;
}
setAccountMetadata(metadata);
setAuthType(AuthType.ConnectionString);
}
}}
>
<p className="connectExplorerContent connectStringText">Connect to your account with connection string</p>
-16
View File
@@ -76,22 +76,6 @@ describe("AuthorizationUtils", () => {
});
});
describe("isAuthorizationError()", () => {
it("should return true for 401 and 403", () => {
expect(AuthorizationUtils.isAuthorizationError(401)).toBe(true);
expect(AuthorizationUtils.isAuthorizationError(403)).toBe(true);
});
it("should return false for other statuses", () => {
expect(AuthorizationUtils.isAuthorizationError(404)).toBe(false);
expect(AuthorizationUtils.isAuthorizationError(500)).toBe(false);
});
it("should return false when there is no status", () => {
expect(AuthorizationUtils.isAuthorizationError(undefined)).toBe(false);
});
});
describe("decryptJWTToken()", () => {
it("should throw an error if token is undefined", () => {
expect(() => AuthorizationUtils.decryptJWTToken(undefined)).toThrow();
-4
View File
@@ -28,10 +28,6 @@ export function getAuthorizationHeader(): ViewModels.AuthorizationTokenHeaderMet
}
}
export function isAuthorizationError(statusCode: number): boolean {
return statusCode === Constants.HttpStatusCodes.Unauthorized || statusCode === Constants.HttpStatusCodes.Forbidden;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function decryptJWTToken(token: string) {
if (!token) {