From 07b074f1848839c24465199a8af3107f963c3f5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bispo?= Date: Mon, 13 Mar 2023 15:40:21 +0000 Subject: [PATCH] [PM-108] Login with Device - Change desktop to not get fingerprint from API (#4834) * [PM-108] Fingerprint is calculated based on pubKey * [PM-108] Change userId to userEmail. Remove fingerprint from AuthResponse --- .../desktop/src/auth/login/login-approval.component.html | 2 +- apps/desktop/src/auth/login/login-approval.component.ts | 9 ++++++++- .../src/auth/models/response/auth-request.response.ts | 2 -- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/desktop/src/auth/login/login-approval.component.html b/apps/desktop/src/auth/login/login-approval.component.html index 57f91f521a..8a07c37f80 100644 --- a/apps/desktop/src/auth/login/login-approval.component.html +++ b/apps/desktop/src/auth/login/login-approval.component.html @@ -11,7 +11,7 @@

{{ "fingerprintPhraseHeader" | i18n }}

- {{ authRequestResponse?.requestFingerprint }} + {{ fingerprintPhrase }}
diff --git a/apps/desktop/src/auth/login/login-approval.component.ts b/apps/desktop/src/auth/login/login-approval.component.ts index 3d21513370..f8124d2a50 100644 --- a/apps/desktop/src/auth/login/login-approval.component.ts +++ b/apps/desktop/src/auth/login/login-approval.component.ts @@ -6,11 +6,13 @@ import { ModalRef } from "@bitwarden/angular/components/modal/modal.ref"; import { ModalConfig } from "@bitwarden/angular/services/modal.service"; import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { AppIdService } from "@bitwarden/common/abstractions/appId.service"; +import { CryptoService } from "@bitwarden/common/abstractions/crypto.service"; import { I18nService } from "@bitwarden/common/abstractions/i18n.service"; import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service"; import { StateService } from "@bitwarden/common/abstractions/state.service"; import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service"; import { AuthRequestResponse } from "@bitwarden/common/auth/models/response/auth-request.response"; +import { Utils } from "@bitwarden/common/misc/utils"; const RequestTimeOut = 60000 * 15; //15 Minutes const RequestTimeUpdate = 60000 * 5; //5 Minutes @@ -25,6 +27,7 @@ export class LoginApprovalComponent implements OnInit, OnDestroy { private destroy$ = new Subject(); email: string; + fingerprintPhrase: string; authRequestResponse: AuthRequestResponse; interval: NodeJS.Timer; requestTimeText: string; @@ -37,6 +40,7 @@ export class LoginApprovalComponent implements OnInit, OnDestroy { protected apiService: ApiService, protected authService: AuthService, protected appIdService: AppIdService, + protected cryptoService: CryptoService, private modalRef: ModalRef, config: ModalConfig ) { @@ -61,8 +65,11 @@ export class LoginApprovalComponent implements OnInit, OnDestroy { async ngOnInit() { if (this.notificationId != null) { this.authRequestResponse = await this.apiService.getAuthRequest(this.notificationId); - + const publicKey = Utils.fromB64ToArray(this.authRequestResponse.publicKey); this.email = await this.stateService.getEmail(); + this.fingerprintPhrase = ( + await this.cryptoService.getFingerprint(this.email, publicKey.buffer) + ).join("-"); this.updateTimeText(); this.interval = setInterval(() => { diff --git a/libs/common/src/auth/models/response/auth-request.response.ts b/libs/common/src/auth/models/response/auth-request.response.ts index 9571669405..9d38edbeeb 100644 --- a/libs/common/src/auth/models/response/auth-request.response.ts +++ b/libs/common/src/auth/models/response/auth-request.response.ts @@ -12,7 +12,6 @@ export class AuthRequestResponse extends BaseResponse { masterPasswordHash: string; creationDate: string; requestApproved?: boolean; - requestFingerprint?: string; responseDate?: string; isAnswered: boolean; isExpired: boolean; @@ -27,7 +26,6 @@ export class AuthRequestResponse extends BaseResponse { this.masterPasswordHash = this.getResponseProperty("MasterPasswordHash"); this.creationDate = this.getResponseProperty("CreationDate"); this.requestApproved = this.getResponseProperty("RequestApproved"); - this.requestFingerprint = this.getResponseProperty("RequestFingerprint"); this.responseDate = this.getResponseProperty("ResponseDate"); const requestDate = new Date(this.creationDate);