1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-20 21:01:29 +01:00

[EC-598] feat: add rudimentary support for excluded credentials

This commit is contained in:
Andreas Coroiu 2023-04-05 16:43:13 +02:00
parent 183af55491
commit 034f16f29e
No known key found for this signature in database
GPG Key ID: E70B5FFC81DFEC1A
5 changed files with 34 additions and 12 deletions

View File

@ -75,6 +75,10 @@ export type BrowserFido2Message = { sessionId: string } & (
type: "ConfirmNewNonDiscoverableCredentialResponse";
cipherId: string;
}
| {
type: "InformExcludedCredentialRequest";
existingCipherIds: string[];
}
| {
type: "AbortRequest";
}
@ -222,12 +226,15 @@ export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSessi
return response.cipherId;
}
informExcludedCredential(
existingCipherIds: string[],
newCredential: NewCredentialParams,
abortController?: AbortController
): Promise<void> {
return null;
async informExcludedCredential(existingCipherIds: string[]): Promise<void> {
const data: BrowserFido2Message = {
type: "InformExcludedCredentialRequest",
sessionId: this.sessionId,
existingCipherIds,
};
await this.send(data);
await this.receive("AbortResponse");
}
private async send(msg: BrowserFido2Message): Promise<void> {

View File

@ -37,6 +37,18 @@
</div>
<button type="button" class="btn btn-outline-secondary" (click)="confirmNew()">Create</button>
</ng-container>
<ng-container *ngIf="data.type == 'InformExcludedCredentialRequest'">
A passkey already exists in Bitwarden for this account
<div class="box list">
<div class="box-content">
<app-cipher-row
*ngFor="let cipher of ciphers"
[cipher]="cipher"
(onSelected)="pick(cipher)"
></app-cipher-row>
</div>
</div>
</ng-container>
<button type="button" class="btn btn-outline-secondary" (click)="abort(true)">
Use browser built-in
</button>

View File

@ -85,6 +85,13 @@ export class Fido2Component implements OnInit, OnDestroy {
this.ciphers = (await this.cipherService.getAllDecrypted()).filter(
(cipher) => cipher.type === CipherType.Login && !cipher.isDeleted
);
} else if (data?.type === "InformExcludedCredentialRequest") {
this.ciphers = await Promise.all(
data.existingCipherIds.map(async (cipherId) => {
const cipher = await this.cipherService.get(cipherId);
return cipher.decrypt();
})
);
}
}),
takeUntil(this.destroy$)

View File

@ -39,7 +39,6 @@ export abstract class Fido2UserInterfaceSession {
) => Promise<string | undefined>;
informExcludedCredential: (
existingCipherIds: string[],
newCredential: NewCredentialParams,
abortController?: AbortController
) => Promise<void>;
}

View File

@ -65,11 +65,8 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr
const isExcluded = await this.vaultContainsCredentials(params.excludeCredentialDescriptorList);
if (isExcluded) {
await userInterfaceSession.informExcludedCredential(
[Utils.guidToStandardFormat(params.excludeCredentialDescriptorList[0].id)],
{
credentialName: params.rpEntity.name,
userName: params.userEntity.displayName,
},
// [Utils.guidToStandardFormat(params.excludeCredentialDescriptorList[0].id)],
[],
abortController
);