1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-31 22:51:28 +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"; type: "ConfirmNewNonDiscoverableCredentialResponse";
cipherId: string; cipherId: string;
} }
| {
type: "InformExcludedCredentialRequest";
existingCipherIds: string[];
}
| { | {
type: "AbortRequest"; type: "AbortRequest";
} }
@ -222,12 +226,15 @@ export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSessi
return response.cipherId; return response.cipherId;
} }
informExcludedCredential( async informExcludedCredential(existingCipherIds: string[]): Promise<void> {
existingCipherIds: string[], const data: BrowserFido2Message = {
newCredential: NewCredentialParams, type: "InformExcludedCredentialRequest",
abortController?: AbortController sessionId: this.sessionId,
): Promise<void> { existingCipherIds,
return null; };
await this.send(data);
await this.receive("AbortResponse");
} }
private async send(msg: BrowserFido2Message): Promise<void> { private async send(msg: BrowserFido2Message): Promise<void> {

View File

@ -37,6 +37,18 @@
</div> </div>
<button type="button" class="btn btn-outline-secondary" (click)="confirmNew()">Create</button> <button type="button" class="btn btn-outline-secondary" (click)="confirmNew()">Create</button>
</ng-container> </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)"> <button type="button" class="btn btn-outline-secondary" (click)="abort(true)">
Use browser built-in Use browser built-in
</button> </button>

View File

@ -85,6 +85,13 @@ export class Fido2Component implements OnInit, OnDestroy {
this.ciphers = (await this.cipherService.getAllDecrypted()).filter( this.ciphers = (await this.cipherService.getAllDecrypted()).filter(
(cipher) => cipher.type === CipherType.Login && !cipher.isDeleted (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$) takeUntil(this.destroy$)

View File

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

View File

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