mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-29 12:55:21 +01:00
Force ssh key creation when creating new ssh item while filtering to ssh keys in desktop (#11985)
This commit is contained in:
parent
1360c2abba
commit
06b5c798dd
@ -111,9 +111,19 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit, On
|
|||||||
) {
|
) {
|
||||||
this.cipher = null;
|
this.cipher = null;
|
||||||
}
|
}
|
||||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
await super.load();
|
||||||
super.load();
|
|
||||||
|
if (!this.editMode || this.cloneMode) {
|
||||||
|
// Creating an ssh key directly while filtering to the ssh key category
|
||||||
|
// must force a key to be set. SSH keys must never be created with an empty private key field
|
||||||
|
if (
|
||||||
|
this.cipher.type === CipherType.SshKey &&
|
||||||
|
(this.cipher.sshKey.privateKey == null || this.cipher.sshKey.privateKey === "")
|
||||||
|
) {
|
||||||
|
await this.generateSshKey(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onWindowHidden() {
|
onWindowHidden() {
|
||||||
@ -145,17 +155,20 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit, On
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async generateSshKey() {
|
async generateSshKey(showNotification: boolean = true) {
|
||||||
const sshKey = await ipc.platform.sshAgent.generateKey("ed25519");
|
const sshKey = await ipc.platform.sshAgent.generateKey("ed25519");
|
||||||
this.cipher.sshKey.privateKey = sshKey.privateKey;
|
this.cipher.sshKey.privateKey = sshKey.privateKey;
|
||||||
this.cipher.sshKey.publicKey = sshKey.publicKey;
|
this.cipher.sshKey.publicKey = sshKey.publicKey;
|
||||||
this.cipher.sshKey.keyFingerprint = sshKey.keyFingerprint;
|
this.cipher.sshKey.keyFingerprint = sshKey.keyFingerprint;
|
||||||
|
|
||||||
|
if (showNotification) {
|
||||||
this.toastService.showToast({
|
this.toastService.showToast({
|
||||||
variant: "success",
|
variant: "success",
|
||||||
title: "",
|
title: "",
|
||||||
message: this.i18nService.t("sshKeyGenerated"),
|
message: this.i18nService.t("sshKeyGenerated"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async importSshKeyFromClipboard() {
|
async importSshKeyFromClipboard() {
|
||||||
const key = await this.platformUtilsService.readFromClipboard();
|
const key = await this.platformUtilsService.readFromClipboard();
|
||||||
|
@ -17,6 +17,10 @@ export class SshKeyView extends ItemView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get maskedPrivateKey(): string {
|
get maskedPrivateKey(): string {
|
||||||
|
if (!this.privateKey || this.privateKey.length === 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
let lines = this.privateKey.split("\n").filter((l) => l.trim() !== "");
|
let lines = this.privateKey.split("\n").filter((l) => l.trim() !== "");
|
||||||
lines = lines.map((l, i) => {
|
lines = lines.map((l, i) => {
|
||||||
if (i === 0 || i === lines.length - 1) {
|
if (i === 0 || i === lines.length - 1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user