Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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[]>;
Expand All @@ -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,
Expand All @@ -78,7 +73,6 @@ describe("AutoSubmitLoginBackground", () => {
autofillService,
scriptInjectorService,
authService,
configService,
platformUtilsService,
policyService,
accountService,
Expand All @@ -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 })]);

Expand All @@ -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", () => {
Expand Down Expand Up @@ -268,7 +262,6 @@ describe("AutoSubmitLoginBackground", () => {
autofillService,
scriptInjectorService,
authService,
configService,
platformUtilsService,
policyService,
accountService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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,
Expand All @@ -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));
}

/**
Expand Down
1 change: 0 additions & 1 deletion apps/browser/src/background/main.background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,6 @@ export default class MainBackground {
this.autofillService,
this.scriptInjectorService,
this.authService,
this.configService,
this.platformUtilsService,
this.policyService,
this.accountService,
Expand Down
12 changes: 3 additions & 9 deletions bitwarden_license/bit-web/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -25,13 +24,8 @@
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()]);

Check warning on line 28 in bitwarden_license/bit-web/src/app/app.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/app.component.ts#L28

Added line #L28 was not covered by tests
}
}
}
2 changes: 0 additions & 2 deletions libs/common/src/enums/feature-flag.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export enum FeatureFlag {
DelayFido2PageScriptInitWithinMv2 = "delay-fido2-page-script-init-within-mv2",
EnableNewCardCombinedExpiryAutofill = "enable-new-card-combined-expiry-autofill",
GenerateIdentityFillScriptRefactor = "generate-identity-fill-script-refactor",
IdpAutoSubmitLogin = "idp-auto-submit-login",
NotificationRefresh = "notification-refresh",
UseTreeWalkerApiForPageDetailsCollection = "use-tree-walker-api-for-page-details-collection",
MacOsNativeCredentialSync = "macos-native-credential-sync",
Expand Down Expand Up @@ -92,7 +91,6 @@ export const DefaultFeatureFlagValue = {
[FeatureFlag.DelayFido2PageScriptInitWithinMv2]: FALSE,
[FeatureFlag.EnableNewCardCombinedExpiryAutofill]: FALSE,
[FeatureFlag.GenerateIdentityFillScriptRefactor]: FALSE,
[FeatureFlag.IdpAutoSubmitLogin]: FALSE,
[FeatureFlag.NotificationRefresh]: FALSE,
[FeatureFlag.UseTreeWalkerApiForPageDetailsCollection]: FALSE,
[FeatureFlag.MacOsNativeCredentialSync]: FALSE,
Expand Down
Loading