mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 06:13:38 +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:
@@ -5,7 +5,6 @@ import { PolicyService } from "@bitwarden/common/admin-console/abstractions/poli
|
|||||||
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
|
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
|
||||||
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
||||||
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
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 { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
@@ -35,7 +34,6 @@ describe("AutoSubmitLoginBackground", () => {
|
|||||||
let scriptInjectorService: MockProxy<ScriptInjectorService>;
|
let scriptInjectorService: MockProxy<ScriptInjectorService>;
|
||||||
let authStatus$: BehaviorSubject<AuthenticationStatus>;
|
let authStatus$: BehaviorSubject<AuthenticationStatus>;
|
||||||
let authService: MockProxy<AuthService>;
|
let authService: MockProxy<AuthService>;
|
||||||
let configService: MockProxy<ConfigService>;
|
|
||||||
let platformUtilsService: MockProxy<PlatformUtilsService>;
|
let platformUtilsService: MockProxy<PlatformUtilsService>;
|
||||||
let policyDetails: MockProxy<Policy>;
|
let policyDetails: MockProxy<Policy>;
|
||||||
let automaticAppLogInPolicy$: BehaviorSubject<Policy[]>;
|
let automaticAppLogInPolicy$: BehaviorSubject<Policy[]>;
|
||||||
@@ -56,9 +54,6 @@ describe("AutoSubmitLoginBackground", () => {
|
|||||||
authStatus$ = new BehaviorSubject(AuthenticationStatus.Unlocked);
|
authStatus$ = new BehaviorSubject(AuthenticationStatus.Unlocked);
|
||||||
authService = mock<AuthService>();
|
authService = mock<AuthService>();
|
||||||
authService.activeAccountStatus$ = authStatus$;
|
authService.activeAccountStatus$ = authStatus$;
|
||||||
configService = mock<ConfigService>({
|
|
||||||
getFeatureFlag: jest.fn().mockResolvedValue(true),
|
|
||||||
});
|
|
||||||
platformUtilsService = mock<PlatformUtilsService>();
|
platformUtilsService = mock<PlatformUtilsService>();
|
||||||
policyDetails = mock<Policy>({
|
policyDetails = mock<Policy>({
|
||||||
enabled: true,
|
enabled: true,
|
||||||
@@ -78,7 +73,6 @@ describe("AutoSubmitLoginBackground", () => {
|
|||||||
autofillService,
|
autofillService,
|
||||||
scriptInjectorService,
|
scriptInjectorService,
|
||||||
authService,
|
authService,
|
||||||
configService,
|
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
policyService,
|
policyService,
|
||||||
accountService,
|
accountService,
|
||||||
@@ -89,7 +83,7 @@ describe("AutoSubmitLoginBackground", () => {
|
|||||||
jest.clearAllMocks();
|
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 () => {
|
it("destroys all event listeners when the AutomaticAppLogIn policy is not enabled", async () => {
|
||||||
automaticAppLogInPolicy$.next([mock<Policy>({ ...policyDetails, enabled: false })]);
|
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;
|
let webRequestDetails: chrome.webRequest.WebRequestBodyDetails;
|
||||||
|
|
||||||
describe("starting the auto-submit login workflow", () => {
|
describe("starting the auto-submit login workflow", () => {
|
||||||
@@ -268,7 +262,6 @@ describe("AutoSubmitLoginBackground", () => {
|
|||||||
autofillService,
|
autofillService,
|
||||||
scriptInjectorService,
|
scriptInjectorService,
|
||||||
authService,
|
authService,
|
||||||
configService,
|
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
policyService,
|
policyService,
|
||||||
accountService,
|
accountService,
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ import { AccountService } from "@bitwarden/common/auth/abstractions/account.serv
|
|||||||
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
||||||
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
||||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
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 { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
|
|
||||||
@@ -42,7 +40,6 @@ export class AutoSubmitLoginBackground implements AutoSubmitLoginBackgroundAbstr
|
|||||||
private autofillService: AutofillService,
|
private autofillService: AutofillService,
|
||||||
private scriptInjectorService: ScriptInjectorService,
|
private scriptInjectorService: ScriptInjectorService,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private configService: ConfigService,
|
|
||||||
private platformUtilsService: PlatformUtilsService,
|
private platformUtilsService: PlatformUtilsService,
|
||||||
private policyService: PolicyService,
|
private policyService: PolicyService,
|
||||||
private accountService: AccountService,
|
private accountService: AccountService,
|
||||||
@@ -51,15 +48,10 @@ export class AutoSubmitLoginBackground implements AutoSubmitLoginBackgroundAbstr
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the auto-submit login policy. Will return early if
|
* Initializes the auto-submit login policy. If the policy is not enabled, it
|
||||||
* the feature flag is not set. If the policy is not enabled, it
|
|
||||||
* will trigger a removal of any established listeners.
|
* will trigger a removal of any established listeners.
|
||||||
*/
|
*/
|
||||||
async init() {
|
async init() {
|
||||||
const featureFlagEnabled = await this.configService.getFeatureFlag(
|
|
||||||
FeatureFlag.IdpAutoSubmitLogin,
|
|
||||||
);
|
|
||||||
if (featureFlagEnabled) {
|
|
||||||
this.accountService.activeAccount$
|
this.accountService.activeAccount$
|
||||||
.pipe(
|
.pipe(
|
||||||
getUserId,
|
getUserId,
|
||||||
@@ -70,7 +62,6 @@ export class AutoSubmitLoginBackground implements AutoSubmitLoginBackgroundAbstr
|
|||||||
)
|
)
|
||||||
.subscribe(this.handleAutoSubmitLoginPolicySubscription.bind(this));
|
.subscribe(this.handleAutoSubmitLoginPolicySubscription.bind(this));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles changes to the AutomaticAppLogIn policy. If the policy is not enabled, trigger
|
* Handles changes to the AutomaticAppLogIn policy. If the policy is not enabled, trigger
|
||||||
|
|||||||
@@ -1238,7 +1238,6 @@ export default class MainBackground {
|
|||||||
this.autofillService,
|
this.autofillService,
|
||||||
this.scriptInjectorService,
|
this.scriptInjectorService,
|
||||||
this.authService,
|
this.authService,
|
||||||
this.configService,
|
|
||||||
this.platformUtilsService,
|
this.platformUtilsService,
|
||||||
this.policyService,
|
this.policyService,
|
||||||
this.accountService,
|
this.accountService,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Component, OnInit } from "@angular/core";
|
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 { AppComponent as BaseAppComponent } from "@bitwarden/web-vault/app/app.component";
|
||||||
|
|
||||||
import { ActivateAutofillPolicy } from "./admin-console/policies/activate-autofill.component";
|
import { ActivateAutofillPolicy } from "./admin-console/policies/activate-autofill.component";
|
||||||
@@ -25,13 +24,8 @@ export class AppComponent extends BaseAppComponent implements OnInit {
|
|||||||
new ActivateAutofillPolicy(),
|
new ActivateAutofillPolicy(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
this.configService.getFeatureFlag(FeatureFlag.IdpAutoSubmitLogin).then((enabled) => {
|
if (!this.policyListService.getPolicies().some((p) => p instanceof AutomaticAppLoginPolicy)) {
|
||||||
if (
|
|
||||||
enabled &&
|
|
||||||
!this.policyListService.getPolicies().some((p) => p instanceof AutomaticAppLoginPolicy)
|
|
||||||
) {
|
|
||||||
this.policyListService.addPolicies([new AutomaticAppLoginPolicy()]);
|
this.policyListService.addPolicies([new AutomaticAppLoginPolicy()]);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ export enum FeatureFlag {
|
|||||||
/* Autofill */
|
/* Autofill */
|
||||||
BlockBrowserInjectionsByDomain = "block-browser-injections-by-domain",
|
BlockBrowserInjectionsByDomain = "block-browser-injections-by-domain",
|
||||||
EnableNewCardCombinedExpiryAutofill = "enable-new-card-combined-expiry-autofill",
|
EnableNewCardCombinedExpiryAutofill = "enable-new-card-combined-expiry-autofill",
|
||||||
IdpAutoSubmitLogin = "idp-auto-submit-login",
|
|
||||||
NotificationRefresh = "notification-refresh",
|
NotificationRefresh = "notification-refresh",
|
||||||
UseTreeWalkerApiForPageDetailsCollection = "use-tree-walker-api-for-page-details-collection",
|
UseTreeWalkerApiForPageDetailsCollection = "use-tree-walker-api-for-page-details-collection",
|
||||||
MacOsNativeCredentialSync = "macos-native-credential-sync",
|
MacOsNativeCredentialSync = "macos-native-credential-sync",
|
||||||
@@ -86,7 +85,6 @@ export const DefaultFeatureFlagValue = {
|
|||||||
/* Autofill */
|
/* Autofill */
|
||||||
[FeatureFlag.BlockBrowserInjectionsByDomain]: FALSE,
|
[FeatureFlag.BlockBrowserInjectionsByDomain]: FALSE,
|
||||||
[FeatureFlag.EnableNewCardCombinedExpiryAutofill]: FALSE,
|
[FeatureFlag.EnableNewCardCombinedExpiryAutofill]: FALSE,
|
||||||
[FeatureFlag.IdpAutoSubmitLogin]: FALSE,
|
|
||||||
[FeatureFlag.NotificationRefresh]: FALSE,
|
[FeatureFlag.NotificationRefresh]: FALSE,
|
||||||
[FeatureFlag.UseTreeWalkerApiForPageDetailsCollection]: FALSE,
|
[FeatureFlag.UseTreeWalkerApiForPageDetailsCollection]: FALSE,
|
||||||
[FeatureFlag.MacOsNativeCredentialSync]: FALSE,
|
[FeatureFlag.MacOsNativeCredentialSync]: FALSE,
|
||||||
|
|||||||
Reference in New Issue
Block a user