1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-22 04:14:04 +00:00

Wrapped phishing detection feature behind feature flag (#13915)

This commit is contained in:
Conner Turnbull
2025-03-20 09:56:08 -04:00
committed by GitHub
parent e84470571a
commit 47913b8920
4 changed files with 35 additions and 11 deletions

View File

@@ -1284,12 +1284,21 @@ export default class MainBackground {
this.inlineMenuFieldQualificationService = new InlineMenuFieldQualificationService();
PhishingDetectionService.initialize(
this.auditService,
this.logService,
this.storageService,
this.taskSchedulerService,
);
this.configService
.getFeatureFlag(FeatureFlag.PhishingDetection)
.then((enabled) => {
if (enabled) {
PhishingDetectionService.initialize(
this.auditService,
this.logService,
this.storageService,
this.taskSchedulerService,
);
}
})
.catch((error) =>
this.logService.error("Failed to check phishing detection feature flag", error),
);
}
async bootstrap() {

View File

@@ -5,6 +5,8 @@ import { firstValueFrom } from "rxjs";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { reports, ReportType } from "../reports";
import { ReportEntry, ReportVariant } from "../shared";
@@ -19,6 +21,7 @@ export class ReportsHomeComponent implements OnInit {
constructor(
private billingAccountProfileStateService: BillingAccountProfileStateService,
private accountService: AccountService,
private configService: ConfigService,
) {}
async ngOnInit(): Promise<void> {
@@ -30,6 +33,10 @@ export class ReportsHomeComponent implements OnInit {
? ReportVariant.Enabled
: ReportVariant.RequiresPremium;
const phishingDetectionEnabled = await this.configService.getFeatureFlag(
FeatureFlag.PhishingDetection,
);
this.reports = [
{
...reports[ReportType.ExposedPasswords],
@@ -47,10 +54,14 @@ export class ReportsHomeComponent implements OnInit {
...reports[ReportType.UnsecuredWebsites],
variant: reportRequiresPremium,
},
{
...reports[ReportType.PhishingWebsitesReport],
variant: reportRequiresPremium,
},
...(phishingDetectionEnabled
? [
{
...reports[ReportType.PhishingWebsitesReport],
variant: ReportVariant.Enabled,
},
]
: []),
{
...reports[ReportType.Inactive2fa],
variant: reportRequiresPremium,

View File

@@ -2,6 +2,8 @@ import { NgModule } from "@angular/core";
import { RouterModule, Routes } from "@angular/router";
import { authGuard } from "@bitwarden/angular/auth/guards";
import { canAccessFeature } from "@bitwarden/angular/platform/guard/feature-flag.guard";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { hasPremiumGuard } from "../../billing/guards/has-premium.guard";
@@ -66,7 +68,7 @@ const routes: Routes = [
path: "phishing-website-report",
component: PhishingWebsiteReport,
data: { titleId: "phishingWebsiteReport" },
canActivate: [hasPremiumGuard()],
canActivate: [canAccessFeature(FeatureFlag.PhishingDetection)],
},
],
},

View File

@@ -45,6 +45,7 @@ export enum FeatureFlag {
PM15179_AddExistingOrgsFromProviderPortal = "pm-15179-add-existing-orgs-from-provider-portal",
RecoveryCodeLogin = "pm-17128-recovery-code-login",
PM12276_BreadcrumbEventLogs = "pm-12276-breadcrumbing-for-business-features",
PhishingDetection = "phishing-detection",
}
export type AllowedFeatureFlagTypes = boolean | number | string;
@@ -100,6 +101,7 @@ export const DefaultFeatureFlagValue = {
[FeatureFlag.PM15179_AddExistingOrgsFromProviderPortal]: FALSE,
[FeatureFlag.RecoveryCodeLogin]: FALSE,
[FeatureFlag.PM12276_BreadcrumbEventLogs]: FALSE,
[FeatureFlag.PhishingDetection]: FALSE,
} satisfies Record<FeatureFlag, AllowedFeatureFlagTypes>;
export type DefaultFeatureFlagValueType = typeof DefaultFeatureFlagValue;