1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-02-18 01:41:27 +01:00

[PM-4882] Passkeys: funnel rp name or id to the cipher name on save (#7969)

* funnel rp name or id to the cipher name on save

* remove comment

* add rp name and id to addCipher function

---------

Co-authored-by: Merissa Weinstein <merissaweinstein@merissas-mbp-2.lan>
This commit is contained in:
Merissa Weinstein 2024-03-06 11:30:12 -06:00 committed by GitHub
parent 51f482dde9
commit 5dcc035245
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 16 additions and 7 deletions

View File

@ -67,6 +67,7 @@ export type BrowserFido2Message = { sessionId: string } & (
userName: string; userName: string;
userVerification: boolean; userVerification: boolean;
fallbackSupported: boolean; fallbackSupported: boolean;
rpId: string;
} }
| { | {
type: "ConfirmNewCredentialResponse"; type: "ConfirmNewCredentialResponse";
@ -242,6 +243,7 @@ export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSessi
credentialName, credentialName,
userName, userName,
userVerification, userVerification,
rpId,
}: NewCredentialParams): Promise<{ cipherId: string; userVerified: boolean }> { }: NewCredentialParams): Promise<{ cipherId: string; userVerified: boolean }> {
const data: BrowserFido2Message = { const data: BrowserFido2Message = {
type: "ConfirmNewCredentialRequest", type: "ConfirmNewCredentialRequest",
@ -250,6 +252,7 @@ export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSessi
userName, userName,
userVerification, userVerification,
fallbackSupported: this.fallbackSupported, fallbackSupported: this.fallbackSupported,
rpId,
}; };
await this.send(data); await this.send(data);

View File

@ -16,7 +16,6 @@ import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { SettingsService } from "@bitwarden/common/abstractions/settings.service"; import { SettingsService } from "@bitwarden/common/abstractions/settings.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { SecureNoteType, CipherType } from "@bitwarden/common/vault/enums"; import { SecureNoteType, CipherType } from "@bitwarden/common/vault/enums";
import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type"; import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type";
@ -245,7 +244,8 @@ export class Fido2Component implements OnInit, OnDestroy {
protected async saveNewLogin() { protected async saveNewLogin() {
const data = this.message$.value; const data = this.message$.value;
if (data?.type === "ConfirmNewCredentialRequest") { if (data?.type === "ConfirmNewCredentialRequest") {
await this.createNewCipher(); const name = data.credentialName || data.rpId;
await this.createNewCipher(name);
// We are bypassing user verification pending implementation of PIN and biometric support. // We are bypassing user verification pending implementation of PIN and biometric support.
this.send({ this.send({
@ -296,7 +296,7 @@ export class Fido2Component implements OnInit, OnDestroy {
// eslint-disable-next-line @typescript-eslint/no-floating-promises // eslint-disable-next-line @typescript-eslint/no-floating-promises
this.router.navigate(["/add-cipher"], { this.router.navigate(["/add-cipher"], {
queryParams: { queryParams: {
name: Utils.getHostname(this.url), name: data.credentialName || data.rpId,
uri: this.url, uri: this.url,
uilocation: "popout", uilocation: "popout",
senderTabId: this.senderTabId, senderTabId: this.senderTabId,
@ -344,9 +344,9 @@ export class Fido2Component implements OnInit, OnDestroy {
this.destroy$.complete(); this.destroy$.complete();
} }
private buildCipher() { private buildCipher(name: string) {
this.cipher = new CipherView(); this.cipher = new CipherView();
this.cipher.name = Utils.getHostname(this.url); this.cipher.name = name;
this.cipher.type = CipherType.Login; this.cipher.type = CipherType.Login;
this.cipher.login = new LoginView(); this.cipher.login = new LoginView();
this.cipher.login.uris = [new LoginUriView()]; this.cipher.login.uris = [new LoginUriView()];
@ -358,8 +358,8 @@ export class Fido2Component implements OnInit, OnDestroy {
this.cipher.reprompt = CipherRepromptType.None; this.cipher.reprompt = CipherRepromptType.None;
} }
private async createNewCipher() { private async createNewCipher(name: string) {
this.buildCipher(); this.buildCipher(name);
const cipher = await this.cipherService.encrypt(this.cipher); const cipher = await this.cipherService.encrypt(this.cipher);
try { try {
await this.cipherService.createWithServer(cipher); await this.cipherService.createWithServer(cipher);

View File

@ -16,6 +16,10 @@ export interface NewCredentialParams {
* Whether or not the user must be verified before completing the operation. * Whether or not the user must be verified before completing the operation.
*/ */
userVerification: boolean; userVerification: boolean;
/**
* The relying party ID is usually the URL
*/
rpId: string;
} }
/** /**

View File

@ -216,6 +216,7 @@ describe("FidoAuthenticatorService", () => {
credentialName: params.rpEntity.name, credentialName: params.rpEntity.name,
userName: params.userEntity.displayName, userName: params.userEntity.displayName,
userVerification, userVerification,
rpId: params.rpEntity.id,
} as NewCredentialParams); } as NewCredentialParams);
}); });
} }

View File

@ -113,6 +113,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr
credentialName: params.rpEntity.name, credentialName: params.rpEntity.name,
userName: params.userEntity.displayName, userName: params.userEntity.displayName,
userVerification: params.requireUserVerification, userVerification: params.requireUserVerification,
rpId: params.rpEntity.id,
}); });
const cipherId = response.cipherId; const cipherId = response.cipherId;
userVerified = response.userVerified; userVerified = response.userVerified;