1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00

PM-16653 remove idp auto submit login step 1 (#14847)

* PM-16653 remove idp auto submit login step 1

* remove config service mock

* remove configservice from main.ts

* edit test describes to be accurate

* Update apps/browser/src/autofill/background/auto-submit-login.background.ts

Co-authored-by: Jonathan Prusik <jprusik@users.noreply.github.com>

---------

Co-authored-by: Jonathan Prusik <jprusik@users.noreply.github.com>
This commit is contained in:
Daniel Riera
2025-06-02 13:37:28 -04:00
committed by GitHub
parent 4ceba4841b
commit f77bd8c554
5 changed files with 15 additions and 40 deletions

View File

@@ -5,7 +5,6 @@ import { PolicyService } from "@bitwarden/common/admin-console/abstractions/poli
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
@@ -35,7 +34,6 @@ describe("AutoSubmitLoginBackground", () => {
let scriptInjectorService: MockProxy<ScriptInjectorService>;
let authStatus$: BehaviorSubject<AuthenticationStatus>;
let authService: MockProxy<AuthService>;
let configService: MockProxy<ConfigService>;
let platformUtilsService: MockProxy<PlatformUtilsService>;
let policyDetails: MockProxy<Policy>;
let automaticAppLogInPolicy$: BehaviorSubject<Policy[]>;
@@ -56,9 +54,6 @@ describe("AutoSubmitLoginBackground", () => {
authStatus$ = new BehaviorSubject(AuthenticationStatus.Unlocked);
authService = mock<AuthService>();
authService.activeAccountStatus$ = authStatus$;
configService = mock<ConfigService>({
getFeatureFlag: jest.fn().mockResolvedValue(true),
});
platformUtilsService = mock<PlatformUtilsService>();
policyDetails = mock<Policy>({
enabled: true,
@@ -78,7 +73,6 @@ describe("AutoSubmitLoginBackground", () => {
autofillService,
scriptInjectorService,
authService,
configService,
platformUtilsService,
policyService,
accountService,
@@ -89,7 +83,7 @@ describe("AutoSubmitLoginBackground", () => {
jest.clearAllMocks();
});
describe("when the AutoSubmitLoginBackground feature is disabled", () => {
describe("when conditions prevent auto-submit policy activation", () => {
it("destroys all event listeners when the AutomaticAppLogIn policy is not enabled", async () => {
automaticAppLogInPolicy$.next([mock<Policy>({ ...policyDetails, enabled: false })]);
@@ -115,7 +109,7 @@ describe("AutoSubmitLoginBackground", () => {
});
});
describe("when the AutoSubmitLoginBackground feature is enabled", () => {
describe("when the AutomaticAppLogIn policy is valid and active", () => {
let webRequestDetails: chrome.webRequest.WebRequestBodyDetails;
describe("starting the auto-submit login workflow", () => {
@@ -268,7 +262,6 @@ describe("AutoSubmitLoginBackground", () => {
autofillService,
scriptInjectorService,
authService,
configService,
platformUtilsService,
policyService,
accountService,

View File

@@ -10,8 +10,6 @@ import { AccountService } from "@bitwarden/common/auth/abstractions/account.serv
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
import { getUserId } from "@bitwarden/common/auth/services/account.service";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
@@ -42,7 +40,6 @@ export class AutoSubmitLoginBackground implements AutoSubmitLoginBackgroundAbstr
private autofillService: AutofillService,
private scriptInjectorService: ScriptInjectorService,
private authService: AuthService,
private configService: ConfigService,
private platformUtilsService: PlatformUtilsService,
private policyService: PolicyService,
private accountService: AccountService,
@@ -51,25 +48,19 @@ export class AutoSubmitLoginBackground implements AutoSubmitLoginBackgroundAbstr
}
/**
* Initializes the auto-submit login policy. Will return early if
* the feature flag is not set. If the policy is not enabled, it
* Initializes the auto-submit login policy. If the policy is not enabled, it
* will trigger a removal of any established listeners.
*/
async init() {
const featureFlagEnabled = await this.configService.getFeatureFlag(
FeatureFlag.IdpAutoSubmitLogin,
);
if (featureFlagEnabled) {
this.accountService.activeAccount$
.pipe(
getUserId,
switchMap((userId) =>
this.policyService.policiesByType$(PolicyType.AutomaticAppLogIn, userId),
),
getFirstPolicy,
)
.subscribe(this.handleAutoSubmitLoginPolicySubscription.bind(this));
}
this.accountService.activeAccount$
.pipe(
getUserId,
switchMap((userId) =>
this.policyService.policiesByType$(PolicyType.AutomaticAppLogIn, userId),
),
getFirstPolicy,
)
.subscribe(this.handleAutoSubmitLoginPolicySubscription.bind(this));
}
/**

View File

@@ -1238,7 +1238,6 @@ export default class MainBackground {
this.autofillService,
this.scriptInjectorService,
this.authService,
this.configService,
this.platformUtilsService,
this.policyService,
this.accountService,

View File

@@ -1,6 +1,5 @@
import { Component, OnInit } from "@angular/core";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { AppComponent as BaseAppComponent } from "@bitwarden/web-vault/app/app.component";
import { ActivateAutofillPolicy } from "./admin-console/policies/activate-autofill.component";
@@ -25,13 +24,8 @@ export class AppComponent extends BaseAppComponent implements OnInit {
new ActivateAutofillPolicy(),
]);
this.configService.getFeatureFlag(FeatureFlag.IdpAutoSubmitLogin).then((enabled) => {
if (
enabled &&
!this.policyListService.getPolicies().some((p) => p instanceof AutomaticAppLoginPolicy)
) {
this.policyListService.addPolicies([new AutomaticAppLoginPolicy()]);
}
});
if (!this.policyListService.getPolicies().some((p) => p instanceof AutomaticAppLoginPolicy)) {
this.policyListService.addPolicies([new AutomaticAppLoginPolicy()]);
}
}
}

View File

@@ -22,7 +22,6 @@ export enum FeatureFlag {
/* Autofill */
BlockBrowserInjectionsByDomain = "block-browser-injections-by-domain",
EnableNewCardCombinedExpiryAutofill = "enable-new-card-combined-expiry-autofill",
IdpAutoSubmitLogin = "idp-auto-submit-login",
NotificationRefresh = "notification-refresh",
UseTreeWalkerApiForPageDetailsCollection = "use-tree-walker-api-for-page-details-collection",
MacOsNativeCredentialSync = "macos-native-credential-sync",
@@ -86,7 +85,6 @@ export const DefaultFeatureFlagValue = {
/* Autofill */
[FeatureFlag.BlockBrowserInjectionsByDomain]: FALSE,
[FeatureFlag.EnableNewCardCombinedExpiryAutofill]: FALSE,
[FeatureFlag.IdpAutoSubmitLogin]: FALSE,
[FeatureFlag.NotificationRefresh]: FALSE,
[FeatureFlag.UseTreeWalkerApiForPageDetailsCollection]: FALSE,
[FeatureFlag.MacOsNativeCredentialSync]: FALSE,