1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-22 11:45:59 +01:00

PM-5001 - WebAuthn-Login.strategy - set user key should set the master key encrypted user key if it exists so that the passkey authN + MP decryption flow can work. (#6978)

This commit is contained in:
Jared Snider 2023-11-27 13:33:15 -05:00 committed by GitHub
parent aac4177a6c
commit 687ec0c4c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -179,7 +179,11 @@ describe("WebAuthnLoginStrategy", () => {
// Act
await webAuthnLoginStrategy.logIn(webAuthnCredentials);
// // Assert
// Assert
// Master key encrypted user key should be set
expect(cryptoService.setMasterKeyEncryptedUserKey).toHaveBeenCalledTimes(1);
expect(cryptoService.setMasterKeyEncryptedUserKey).toHaveBeenCalledWith(idTokenResponse.key);
expect(cryptoService.decryptToBytes).toHaveBeenCalledTimes(1);
expect(cryptoService.decryptToBytes).toHaveBeenCalledWith(
idTokenResponse.userDecryptionOptions.webAuthnPrfOption.encryptedPrivateKey,

View File

@ -15,6 +15,13 @@ export class WebAuthnLoginStrategy extends LoginStrategy {
}
protected override async setUserKey(idTokenResponse: IdentityTokenResponse) {
const masterKeyEncryptedUserKey = idTokenResponse.key;
if (masterKeyEncryptedUserKey) {
// set the master key encrypted user key if it exists
await this.cryptoService.setMasterKeyEncryptedUserKey(masterKeyEncryptedUserKey);
}
const userDecryptionOptions = idTokenResponse?.userDecryptionOptions;
if (userDecryptionOptions?.webAuthnPrfOption) {