mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
[PM-10059] alert server if device trust is lost (#10235)
* alert server if device trust is lost * add test * add tests for extra errors * fix build --------- Co-authored-by: Jared Snider <116684653+JaredSnider-Bitwarden@users.noreply.github.com>
This commit is contained in:
@@ -312,6 +312,27 @@ describe("SsoLoginStrategy", () => {
|
||||
expect(cryptoService.setUserKey).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("logs when a device key is found but no decryption keys were recieved in token response", async () => {
|
||||
// Arrange
|
||||
const userDecryptionOpts = userDecryptionOptsServerResponseWithTdeOption;
|
||||
userDecryptionOpts.TrustedDeviceOption.EncryptedPrivateKey = null;
|
||||
userDecryptionOpts.TrustedDeviceOption.EncryptedUserKey = null;
|
||||
|
||||
const idTokenResponse: IdentityTokenResponse = identityTokenResponseFactory(
|
||||
null,
|
||||
userDecryptionOpts,
|
||||
);
|
||||
|
||||
apiService.postIdentityToken.mockResolvedValue(idTokenResponse);
|
||||
deviceTrustService.getDeviceKey.mockResolvedValue(mockDeviceKey);
|
||||
|
||||
// Act
|
||||
await ssoLoginStrategy.logIn(credentials);
|
||||
|
||||
// Assert
|
||||
expect(deviceTrustService.recordDeviceTrustLoss).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
describe("AdminAuthRequest", () => {
|
||||
let tokenResponse: IdentityTokenResponse;
|
||||
|
||||
|
||||
@@ -296,16 +296,20 @@ export class SsoLoginStrategy extends LoginStrategy {
|
||||
|
||||
if (!deviceKey || !encDevicePrivateKey || !encUserKey) {
|
||||
if (!deviceKey) {
|
||||
await this.logService.warning("Unable to set user key due to missing device key.");
|
||||
this.logService.warning("Unable to set user key due to missing device key.");
|
||||
} else if (!encDevicePrivateKey || !encUserKey) {
|
||||
// Tell the server that we have a device key, but received no decryption keys
|
||||
await this.deviceTrustService.recordDeviceTrustLoss();
|
||||
}
|
||||
if (!encDevicePrivateKey) {
|
||||
await this.logService.warning(
|
||||
this.logService.warning(
|
||||
"Unable to set user key due to missing encrypted device private key.",
|
||||
);
|
||||
}
|
||||
if (!encUserKey) {
|
||||
await this.logService.warning("Unable to set user key due to missing encrypted user key.");
|
||||
this.logService.warning("Unable to set user key due to missing encrypted user key.");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user