1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-18 10:23:52 +00:00

Add get other user's keys endpoint

This commit is contained in:
Bernd Schoolmann
2025-05-19 11:29:25 +02:00
parent 54a69aac32
commit 99454812e5
7 changed files with 63 additions and 12 deletions

View File

@@ -21,7 +21,8 @@
<div class="tw-flex tw-flex-col tw-space-y-3">
<h2>User Public Key</h2>
<input type="text" bitInput formControlName="fetchPKIUserId" placeholder="UserId" />
Result: {{ otherUserPublicKey }}
Result Public Key: {{ otherUserPublicKey }} Verifying Key:
{{ otherUserVerifyingKey }} PublicKeyOwnershipClaim: {{ otherUserPublicKeyOwnershipClaim }}
<button type="button" bitButton buttonType="primary" block (click)="getUserPublicKey()">
<span> Get Public Key </span>
</button>

View File

@@ -2,9 +2,8 @@ import { Component, OnInit } from "@angular/core";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { firstValueFrom } from "rxjs";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { MasterPasswordServiceAbstraction } from "@bitwarden/common/key-management/master-password/abstractions/master-password.service.abstraction";
import { KeyApiService } from "@bitwarden/common/key-management/keys/services/abstractions/key-api-service.abstraction";
import { EncryptionType } from "@bitwarden/common/platform/enums";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { KeyService } from "@bitwarden/key-management";
@@ -26,8 +25,6 @@ export class DebugMenu implements OnInit {
privateKey: string;
privateKeyType: string;
masterKey: string;
userId: string;
testClaimPublicKeyOwnershipResult: string;
@@ -45,13 +42,14 @@ export class DebugMenu implements OnInit {
testClaimPublicKeyOwnershipClaim: this.formBuilder.control("", [Validators.required]),
});
otherUserPublicKey: string | null = null;
otherUserVerifyingKey: string | null = null;
otherUserPublicKeyOwnershipClaim: string | null = null;
constructor(
private keyService: KeyService,
private masterPasswordService: MasterPasswordServiceAbstraction,
private accountService: AccountService,
private formBuilder: FormBuilder,
private apiService: ApiService,
private keyApiService: KeyApiService,
) {}
async ngOnInit() {
@@ -86,9 +84,12 @@ export class DebugMenu implements OnInit {
}
getUserPublicKey = async () => {
this.otherUserPublicKey = (
await this.apiService.getUserPublicKey(this.formGroup.get("fetchPKIUserId").value)
).publicKey;
const keys = await this.keyApiService.getUserPublicKeys(
this.formGroup.get("fetchPKIUserId").value,
);
this.otherUserPublicKey = keys.PublicKey;
this.otherUserVerifyingKey = keys.VerifyingKey.toString();
this.otherUserPublicKeyOwnershipClaim = keys.SignedPublicKeyOwnershipClaim.toString();
};
verifyPublicKeyOwnershipClaim = async () => {

View File

@@ -696,11 +696,11 @@ const routes: Routes = [
path: "reports",
loadChildren: () => ReportsModule,
},
{
buildDevOnlyRoute({
path: "debug",
loadComponent: () =>
import("./key-management/debug/debug.component").then((mod) => mod.DebugMenu),
},
}),
{ path: "setup/families-for-enterprise", component: FamiliesForEnterpriseSetupComponent },
],
},
@@ -731,3 +731,12 @@ export function buildFlaggedRoute(flagName: keyof Flags, route: Route): Route {
redirectTo: "/",
};
}
function buildDevOnlyRoute(route: Route): Route {
return process.env.NODE_ENV === "development"
? route
: {
path: route.path,
redirectTo: "/",
};
}