[PM-11619] Replace client-side feature flag with server-side flag (#10709)
This commit is contained in:
parent
f0fe397307
commit
03b3345bf6
|
@ -2,7 +2,6 @@
|
|||
"devFlags": {},
|
||||
"flags": {
|
||||
"showPasswordless": true,
|
||||
"enableCipherKeyEncryption": false,
|
||||
"accountSwitching": false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
},
|
||||
"flags": {
|
||||
"showPasswordless": true,
|
||||
"enableCipherKeyEncryption": false,
|
||||
"accountSwitching": true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
"flags": {
|
||||
"enableCipherKeyEncryption": false,
|
||||
"accountSwitching": true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
{
|
||||
"flags": {
|
||||
"enableCipherKeyEncryption": false
|
||||
}
|
||||
"flags": {}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
{
|
||||
"flags": {
|
||||
"enableCipherKeyEncryption": false
|
||||
}
|
||||
"flags": {}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
{
|
||||
"devFlags": {},
|
||||
"flags": {
|
||||
"enableCipherKeyEncryption": false
|
||||
}
|
||||
"flags": {}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
{
|
||||
"devFlags": {},
|
||||
"flags": {
|
||||
"enableCipherKeyEncryption": false
|
||||
}
|
||||
"flags": {}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
{
|
||||
"flags": {
|
||||
"enableCipherKeyEncryption": false
|
||||
}
|
||||
"flags": {}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
"allowedHosts": "auto"
|
||||
},
|
||||
"flags": {
|
||||
"showPasswordless": false,
|
||||
"enableCipherKeyEncryption": false
|
||||
"showPasswordless": false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
"proxyNotifications": "https://notifications.bitwarden.com"
|
||||
},
|
||||
"flags": {
|
||||
"showPasswordless": true,
|
||||
"enableCipherKeyEncryption": false
|
||||
"showPasswordless": true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
}
|
||||
],
|
||||
"flags": {
|
||||
"showPasswordless": true,
|
||||
"enableCipherKeyEncryption": false
|
||||
"showPasswordless": true
|
||||
},
|
||||
"devFlags": {}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
"buttonAction": "https://www.paypal.com/cgi-bin/webscr"
|
||||
},
|
||||
"flags": {
|
||||
"showPasswordless": true,
|
||||
"enableCipherKeyEncryption": false
|
||||
"showPasswordless": true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
}
|
||||
],
|
||||
"flags": {
|
||||
"showPasswordless": true,
|
||||
"enableCipherKeyEncryption": false
|
||||
"showPasswordless": true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
"port": 8081
|
||||
},
|
||||
"flags": {
|
||||
"showPasswordless": true,
|
||||
"enableCipherKeyEncryption": false
|
||||
"showPasswordless": true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ export enum FeatureFlag {
|
|||
AccountDeprovisioning = "pm-10308-account-deprovisioning",
|
||||
NotificationBarAddLoginImprovements = "notification-bar-add-login-improvements",
|
||||
AC2476_DeprecateStripeSourcesAPI = "AC-2476-deprecate-stripe-sources-api",
|
||||
CipherKeyEncryption = "cipher-key-encryption",
|
||||
}
|
||||
|
||||
export type AllowedFeatureFlagTypes = boolean | number | string;
|
||||
|
@ -78,6 +79,7 @@ export const DefaultFeatureFlagValue = {
|
|||
[FeatureFlag.AccountDeprovisioning]: FALSE,
|
||||
[FeatureFlag.NotificationBarAddLoginImprovements]: FALSE,
|
||||
[FeatureFlag.AC2476_DeprecateStripeSourcesAPI]: FALSE,
|
||||
[FeatureFlag.CipherKeyEncryption]: FALSE,
|
||||
} satisfies Record<FeatureFlag, AllowedFeatureFlagTypes>;
|
||||
|
||||
export type DefaultFeatureFlagValueType = typeof DefaultFeatureFlagValue;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
export type SharedFlags = {
|
||||
showPasswordless?: boolean;
|
||||
enableCipherKeyEncryption?: boolean;
|
||||
};
|
||||
|
||||
// required to avoid linting errors when there are no flags
|
||||
|
|
|
@ -166,7 +166,7 @@ describe("Cipher Service", () => {
|
|||
);
|
||||
|
||||
configService.checkServerMeetsVersionRequirement$.mockReturnValue(of(false));
|
||||
setEncryptionKeyFlag(false);
|
||||
configService.getFeatureFlag.mockResolvedValue(false);
|
||||
|
||||
const spy = jest.spyOn(cipherFileUploadService, "upload");
|
||||
|
||||
|
@ -298,16 +298,16 @@ describe("Cipher Service", () => {
|
|||
});
|
||||
|
||||
describe("cipher.key", () => {
|
||||
it("is null when enableCipherKeyEncryption flag is false", async () => {
|
||||
setEncryptionKeyFlag(false);
|
||||
it("is null when feature flag is false", async () => {
|
||||
configService.getFeatureFlag.mockResolvedValue(false);
|
||||
|
||||
const cipher = await cipherService.encrypt(cipherView, userId);
|
||||
|
||||
expect(cipher.key).toBeNull();
|
||||
});
|
||||
|
||||
it("is defined when enableCipherKeyEncryption flag is true", async () => {
|
||||
setEncryptionKeyFlag(true);
|
||||
it("is defined when feature flag flag is true", async () => {
|
||||
configService.getFeatureFlag.mockResolvedValue(true);
|
||||
|
||||
const cipher = await cipherService.encrypt(cipherView, userId);
|
||||
|
||||
|
@ -320,16 +320,16 @@ describe("Cipher Service", () => {
|
|||
jest.spyOn<any, string>(cipherService, "encryptCipherWithCipherKey");
|
||||
});
|
||||
|
||||
it("is not called when enableCipherKeyEncryption is false", async () => {
|
||||
setEncryptionKeyFlag(false);
|
||||
it("is not called when feature flag is false", async () => {
|
||||
configService.getFeatureFlag.mockResolvedValue(false);
|
||||
|
||||
await cipherService.encrypt(cipherView, userId);
|
||||
|
||||
expect(cipherService["encryptCipherWithCipherKey"]).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("is called when enableCipherKeyEncryption is true", async () => {
|
||||
setEncryptionKeyFlag(true);
|
||||
it("is called when feature flag is true", async () => {
|
||||
configService.getFeatureFlag.mockResolvedValue(true);
|
||||
|
||||
await cipherService.encrypt(cipherView, userId);
|
||||
|
||||
|
@ -345,7 +345,7 @@ describe("Cipher Service", () => {
|
|||
let encryptedKey: EncString;
|
||||
|
||||
beforeEach(() => {
|
||||
setEncryptionKeyFlag(true);
|
||||
configService.getFeatureFlag.mockResolvedValue(true);
|
||||
configService.checkServerMeetsVersionRequirement$.mockReturnValue(of(true));
|
||||
|
||||
searchService.indexedEntityId$ = of(null);
|
||||
|
@ -398,9 +398,3 @@ describe("Cipher Service", () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
function setEncryptionKeyFlag(value: boolean) {
|
||||
process.env.FLAGS = JSON.stringify({
|
||||
enableCipherKeyEncryption: value,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import { CryptoService } from "../../platform/abstractions/crypto.service";
|
|||
import { EncryptService } from "../../platform/abstractions/encrypt.service";
|
||||
import { I18nService } from "../../platform/abstractions/i18n.service";
|
||||
import { StateService } from "../../platform/abstractions/state.service";
|
||||
import { flagEnabled } from "../../platform/misc/flags";
|
||||
import { sequentialize } from "../../platform/misc/sequentialize";
|
||||
import { Utils } from "../../platform/misc/utils";
|
||||
import Domain from "../../platform/models/domain/domain-base";
|
||||
|
@ -1662,11 +1661,10 @@ export class CipherService implements CipherServiceAbstraction {
|
|||
}
|
||||
|
||||
private async getCipherKeyEncryptionEnabled(): Promise<boolean> {
|
||||
return (
|
||||
flagEnabled("enableCipherKeyEncryption") &&
|
||||
(await firstValueFrom(
|
||||
this.configService.checkServerMeetsVersionRequirement$(CIPHER_KEY_ENC_MIN_SERVER_VER),
|
||||
))
|
||||
const featureEnabled = await this.configService.getFeatureFlag(FeatureFlag.CipherKeyEncryption);
|
||||
const meetsServerVersion = await firstValueFrom(
|
||||
this.configService.checkServerMeetsVersionRequirement$(CIPHER_KEY_ENC_MIN_SERVER_VER),
|
||||
);
|
||||
return featureEnabled && meetsServerVersion;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue