1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-07 12:13:45 +00:00

[PM-2207], [PM-1245], [PM-3302] Make browser login, lock, and 2fa components handle configurable redirect routes (#5989)

* Initial work

* Added lock and login redirect and added functionality to abort when in login or locked state

* uncommented cipher row

* added query params to logi component

* Proof of concept for change detection fix

* Remove leftover comment

* Refactored message listener observable to handle angular change detection

* cleanup and removed unused references

* Refactored the connect method be seperating to the pop out logic to a seperate method

* Added comment to explain code change on the message listener

* Removed unused types

* Initial work

* Added lock and login redirect and added functionality to abort when in login or locked state

* uncommented cipher row

* added query params to logi component

* Proof of concept for change detection fix

* Remove leftover comment

* Refactored message listener observable to handle angular change detection

* cleanup and removed unused references

* Refactored the connect method be seperating to the pop out logic to a seperate method

* Added comment to explain code change on the message listener

* Removed unused types

* Added full synce service to the fido2 authenticator to ensure the full sync is completed before getting all decrypted ciphers

* Added full synce service to the fido2 authenticator to ensure the full sync is completed before getting all decrypted ciphers

* Code cleanup to remove sessionId from login component

* Refactored components to make the redirectUrl more generic, fixed code review comments

* Commented out ensureUnlockedVault for this PR

* Fixed destroy subject inheritance issue on the login componenet

* Fixed lock component error

* Added function to run inside angular zone

* Merged branch with master and fixed conflicts

* Changed redirect logic on login and 2fa to use callbacks

* fixed pr comments

* Updated the messageListener observable version to use same logic from the callback version and added comment on the callback version

* Refactored fido2 popup to use auth guard when routing to component, added BrowserRouterService to track previous page and route using that

* Updated components to use browserRouterService for routing to previous page

* Removed auth status reference from browser-fido2-user-interface service

* Removed activated route from lock component

* Removed route in base class constructor

* removed unused comments and method

* refactored router service to not store on the disk

* [PM-3783] feat: patch `chrome.runtime.onMessage` event listeners

(cherry picked from commit 2ca241a0d4)

* Fixed PR comments

* Fixed PR comments

* Revert "[PM-3783] feat: patch `chrome.runtime.onMessage` event listeners"

This reverts commit ed6a713688.

---------

Co-authored-by: Thomas Rittson <trittson@bitwarden.com>
Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com>
This commit is contained in:
SmithThe4th
2023-09-12 17:19:16 -04:00
committed by GitHub
parent be620a935d
commit dbbbae2f52
15 changed files with 247 additions and 43 deletions

View File

@@ -28,6 +28,7 @@ export abstract class Fido2UserInterfaceSession {
params: NewCredentialParams,
abortController?: AbortController
) => Promise<{ cipherId: string; userVerified: boolean }>;
ensureUnlockedVault: () => Promise<void>;
informExcludedCredential: (
existingCipherIds: string[],
abortController?: AbortController

View File

@@ -14,6 +14,7 @@ import {
Fido2UserInterfaceSession,
NewCredentialParams,
} from "../../abstractions/fido2/fido2-user-interface.service.abstraction";
import { SyncService } from "../../abstractions/sync/sync.service.abstraction";
import { CipherType } from "../../enums/cipher-type";
import { Cipher } from "../../models/domain/cipher";
import { CipherView } from "../../models/view/cipher.view";
@@ -31,6 +32,7 @@ describe("FidoAuthenticatorService", () => {
let cipherService!: MockProxy<CipherService>;
let userInterface!: MockProxy<Fido2UserInterfaceService>;
let userInterfaceSession!: MockProxy<Fido2UserInterfaceSession>;
let syncService!: MockProxy<SyncService>;
let authenticator!: Fido2AuthenticatorService;
beforeEach(async () => {
@@ -38,7 +40,8 @@ describe("FidoAuthenticatorService", () => {
userInterface = mock<Fido2UserInterfaceService>();
userInterfaceSession = mock<Fido2UserInterfaceSession>();
userInterface.newSession.mockResolvedValue(userInterfaceSession);
authenticator = new Fido2AuthenticatorService(cipherService, userInterface);
syncService = mock<SyncService>();
authenticator = new Fido2AuthenticatorService(cipherService, userInterface, syncService);
});
describe("makeCredential", () => {

View File

@@ -13,6 +13,7 @@ import {
PublicKeyCredentialDescriptor,
} from "../../abstractions/fido2/fido2-authenticator.service.abstraction";
import { Fido2UserInterfaceService } from "../../abstractions/fido2/fido2-user-interface.service.abstraction";
import { SyncService } from "../../abstractions/sync/sync.service.abstraction";
import { CipherType } from "../../enums/cipher-type";
import { CipherView } from "../../models/view/cipher.view";
import { Fido2KeyView } from "../../models/view/fido2-key.view";
@@ -37,6 +38,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr
constructor(
private cipherService: CipherService,
private userInterface: Fido2UserInterfaceService,
private syncService: SyncService,
private logService?: LogService
) {}
async makeCredential(
@@ -81,6 +83,8 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr
throw new Fido2AutenticatorError(Fido2AutenticatorErrorCode.Unknown);
}
await userInterfaceSession.ensureUnlockedVault();
const existingCipherIds = await this.findExcludedCredentials(
params.excludeCredentialDescriptorList
);
@@ -173,7 +177,6 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr
params.fallbackSupported,
abortController
);
try {
if (
params.requireUserVerification != undefined &&
@@ -188,6 +191,8 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr
}
let cipherOptions: CipherView[];
await userInterfaceSession.ensureUnlockedVault();
if (params.allowCredentialDescriptorList?.length > 0) {
cipherOptions = await this.findCredentialsById(
params.allowCredentialDescriptorList,
@@ -293,6 +298,11 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr
return [];
}
//ensure full sync has completed before getting the ciphers
if ((await this.syncService.getLastSync()) == null) {
await this.syncService.fullSync(false);
}
const ciphers = await this.cipherService.getAllDecrypted();
return ciphers
.filter(
@@ -323,6 +333,11 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr
return [];
}
//ensure full sync has completed before getting the ciphers
if ((await this.syncService.getLastSync()) == null) {
await this.syncService.fullSync(false);
}
const ciphers = await this.cipherService.getAllDecrypted();
return ciphers.filter(
(cipher) =>
@@ -335,6 +350,11 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr
}
private async findCredentialsByRp(rpId: string): Promise<CipherView[]> {
//ensure full sync has completed before getting the ciphers
if ((await this.syncService.getLastSync()) == null) {
await this.syncService.fullSync(false);
}
const ciphers = await this.cipherService.getAllDecrypted();
return ciphers.filter(
(cipher) =>