mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00: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:
@@ -179,7 +179,11 @@ describe("WebAuthnLoginStrategy", () => {
|
|||||||
// Act
|
// Act
|
||||||
await webAuthnLoginStrategy.logIn(webAuthnCredentials);
|
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).toHaveBeenCalledTimes(1);
|
||||||
expect(cryptoService.decryptToBytes).toHaveBeenCalledWith(
|
expect(cryptoService.decryptToBytes).toHaveBeenCalledWith(
|
||||||
idTokenResponse.userDecryptionOptions.webAuthnPrfOption.encryptedPrivateKey,
|
idTokenResponse.userDecryptionOptions.webAuthnPrfOption.encryptedPrivateKey,
|
||||||
|
|||||||
@@ -15,6 +15,13 @@ export class WebAuthnLoginStrategy extends LoginStrategy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override async setUserKey(idTokenResponse: IdentityTokenResponse) {
|
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;
|
const userDecryptionOptions = idTokenResponse?.userDecryptionOptions;
|
||||||
|
|
||||||
if (userDecryptionOptions?.webAuthnPrfOption) {
|
if (userDecryptionOptions?.webAuthnPrfOption) {
|
||||||
|
|||||||
Reference in New Issue
Block a user