Created method for handilng email-address-based fingerprint.

This commit is contained in:
Todd Martin 2024-04-01 17:50:28 -04:00
parent bdb1aa0a04
commit 79b912591d
No known key found for this signature in database
GPG Key ID: 663E7AF5C839BC8F
4 changed files with 24 additions and 9 deletions

View File

@ -75,9 +75,10 @@ export class LoginApprovalComponent implements OnInit, OnDestroy {
this.authRequestResponse = await this.apiService.getAuthRequest(this.notificationId); this.authRequestResponse = await this.apiService.getAuthRequest(this.notificationId);
const publicKey = Utils.fromB64ToArray(this.authRequestResponse.publicKey); const publicKey = Utils.fromB64ToArray(this.authRequestResponse.publicKey);
this.email = await this.stateService.getEmail(); this.email = await this.stateService.getEmail();
this.fingerprintPhrase = ( this.fingerprintPhrase = await this.authRequestService.getFingerprintPhrase(
await this.cryptoService.getFingerprint(this.email, publicKey) this.email,
).join("-"); publicKey,
);
this.updateTimeText(); this.updateTimeText();
this.interval = setInterval(() => { this.interval = setInterval(() => {

View File

@ -197,9 +197,10 @@ export class LoginViaAuthRequestComponent
const derivedPublicKeyArrayBuffer = await this.cryptoFunctionService.rsaExtractPublicKey( const derivedPublicKeyArrayBuffer = await this.cryptoFunctionService.rsaExtractPublicKey(
adminAuthReqStorable.privateKey, adminAuthReqStorable.privateKey,
); );
this.fingerprintPhrase = ( this.fingerprintPhrase = await this.authRequestService.getFingerprintPhrase(
await this.cryptoService.getFingerprint(this.email, derivedPublicKeyArrayBuffer) this.email,
).join("-"); derivedPublicKeyArrayBuffer,
);
// Request denied // Request denied
if (adminAuthReqResponse.isAnswered && !adminAuthReqResponse.requestApproved) { if (adminAuthReqResponse.isAnswered && !adminAuthReqResponse.requestApproved) {
@ -241,9 +242,10 @@ export class LoginViaAuthRequestComponent
const publicKey = Utils.fromBufferToB64(this.authRequestKeyPair.publicKey); const publicKey = Utils.fromBufferToB64(this.authRequestKeyPair.publicKey);
const accessCode = await this.passwordGenerationService.generatePassword({ length: 25 }); const accessCode = await this.passwordGenerationService.generatePassword({ length: 25 });
this.fingerprintPhrase = ( this.fingerprintPhrase = await this.authRequestService.getFingerprintPhrase(
await this.cryptoService.getFingerprint(this.email, this.authRequestKeyPair.publicKey) this.email,
).join("-"); this.authRequestKeyPair.publicKey,
);
this.authRequest = new CreateAuthRequest( this.authRequest = new CreateAuthRequest(
this.email, this.email,

View File

@ -66,4 +66,12 @@ export abstract class AuthRequestServiceAbstraction {
* @remark We should only be receiving approved push notifications to prevent enumeration. * @remark We should only be receiving approved push notifications to prevent enumeration.
*/ */
abstract sendAuthRequestPushNotification: (notification: AuthRequestPushNotification) => void; abstract sendAuthRequestPushNotification: (notification: AuthRequestPushNotification) => void;
/**
* Creates a dash-delimited fingerprint for use in confirming the `AuthRequest` between the requesting and approving device.
* @param email The email address of the user.
* @param publicKey The public key for the user.
* @returns
*/
abstract getFingerprintPhrase(email: string, publicKey: Uint8Array): Promise<string>;
} }

View File

@ -138,4 +138,8 @@ export class AuthRequestService implements AuthRequestServiceAbstraction {
this.authRequestPushNotificationSubject.next(notification.id); this.authRequestPushNotificationSubject.next(notification.id);
} }
} }
async getFingerprintPhrase(email: string, publicKey: Uint8Array): Promise<string> {
return (await this.cryptoService.getFingerprint(email.toLowerCase(), publicKey)).join("-");
}
} }