mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-25 07:19:42 -05:00
Passkeys: Register to an existing entry
This commit is contained in:
parent
bd449f3226
commit
92b30ae7ec
@ -870,23 +870,6 @@ Please select the correct database for saving credentials.</source>
|
||||
<numerusform></numerusform>
|
||||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Do you want to register Passkey for:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Existing Passkey found.
|
||||
Do you want to register a new Passkey for:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Select the existing Passkey and press Update to replace it.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Authenticate Passkey credentials for:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Relying Party: %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@ -899,6 +882,27 @@ Do you want to register a new Passkey for:</source>
|
||||
<source>KeePassXC - Passkey credentials</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Add to existing entry</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Existing passkey found.
|
||||
Do you want to register a new passkey for:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Select the existing passkey and press Update to replace it.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Authenticate passkey credentials for:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Do you want to register a passkey for:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BrowserService</name>
|
||||
@ -939,11 +943,6 @@ Do you want to delete the entry?
|
||||
<source>%1 (Passkey)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Entry already has a Passkey.
|
||||
Do you want to overwrite the Passkey in %1 - %2?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>KeePassXC - Create a new group</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@ -956,10 +955,6 @@ Do you want to overwrite the Passkey in %1 - %2?</source>
|
||||
<source>KeePassXC - Overwrite existing key?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>KeePassXC - Update Passkey</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>KeePassXC - Update Entry</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@ -976,6 +971,27 @@ Do you want to overwrite the Passkey in %1 - %2?</source>
|
||||
<source>Passkey</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>KeePassXC - Passkey credentials</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Register a new passkey to this entry:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>KeePassXC - Update passkey</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Entry already has a passkey.
|
||||
Do you want to overwrite the passkey in %1 - %2?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Register</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BrowserSettingsWidget</name>
|
||||
@ -1223,11 +1239,11 @@ Do you want to overwrite the Passkey in %1 - %2?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Allows using insecure http://localhost with Passkeys for testing purposes.</source>
|
||||
<source>Allows using insecure http://localhost with passkeys for testing purposes.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Allow using localhost with Passkeys</source>
|
||||
<source>Allow using localhost with passkeys</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
@ -6214,10 +6230,6 @@ We recommend you use the AppImage available on our downloads page.</source>
|
||||
<source>KeePassXC - Passkey Export</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Export the following Passkey entries.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Filenames will be generated with title and .passkey file extension.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@ -6238,6 +6250,10 @@ We recommend you use the AppImage available on our downloads page.</source>
|
||||
<source>Export to folder</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Export the following passkey entries.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PasskeyExporter</name>
|
||||
@ -6294,28 +6310,28 @@ Do you want to overwrite it?
|
||||
<source>Cancel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Import the following Passkey:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Entry</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Import the following Passkey to this entry:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Create new entry</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Default Passkeys group (Imported Passkeys)</source>
|
||||
<source>Relying Party: %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Relying Party: %1</source>
|
||||
<source>Import the following passkey:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Import the following passkey to this entry:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Default passkeys group (Imported Passkeys)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
@ -6329,10 +6345,6 @@ Do you want to overwrite it?
|
||||
<source>All files</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open Passkey file</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cannot open file</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@ -6342,23 +6354,27 @@ Do you want to overwrite it?
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cannot import Passkey</source>
|
||||
<source>Open passkey file</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cannot import Passkey file "%1". Data is missing.</source>
|
||||
<source>Cannot import passkey</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cannot import Passkey file "%1". Private key is missing or malformed.</source>
|
||||
<source>Cannot import passkey file "%1". Data is missing.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cannot import Passkey file "%1".
|
||||
<source>Cannot import passkey file "%1".
|
||||
The following data is missing:
|
||||
%2</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cannot import passkey file "%1". Private key is missing or malformed.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PasswordEditWidget</name>
|
||||
@ -8584,10 +8600,6 @@ This option is deprecated, use --set-key-file instead.</source>
|
||||
<source>Wait for timer to expire</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unknown Passkeys error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Challenge is shorter than required minimum length</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@ -8682,6 +8694,10 @@ This option is deprecated, use --set-key-file instead.</source>
|
||||
<source>Unsupported KDF type, cannot decrypt json file</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unknown passkeys error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>QtIOCompressor</name>
|
||||
@ -9008,14 +9024,6 @@ This option is deprecated, use --set-key-file instead.</source>
|
||||
<source>List of entry URLs</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Please wait, list of entries with Passkeys is being updated…</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>No entries with Passkeys.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Title</source>
|
||||
<translation type="unfinished"></translation>
|
||||
@ -9063,6 +9071,14 @@ This option is deprecated, use --set-key-file instead.</source>
|
||||
<source>The passkey file will be vulnerable to theft and unauthorized use, if left unsecured. Are you sure you want to continue?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Please wait, list of entries with passkeys is being updated…</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>No entries with passkeys.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ReportsWidgetStatistics</name>
|
||||
|
@ -151,7 +151,7 @@ QString BrowserMessageBuilder::getErrorMessage(const int errorCode) const
|
||||
case ERROR_PASSKEYS_WAIT_FOR_LIFETIMER:
|
||||
return QObject::tr("Wait for timer to expire");
|
||||
case ERROR_PASSKEYS_UNKNOWN_ERROR:
|
||||
return QObject::tr("Unknown Passkeys error");
|
||||
return QObject::tr("Unknown passkeys error");
|
||||
case ERROR_PASSKEYS_INVALID_CHALLENGE:
|
||||
return QObject::tr("Challenge is shorter than required minimum length");
|
||||
case ERROR_PASSKEYS_INVALID_USER_ID:
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
|
||||
* Copyright (C) 2024 KeePassXC Team <team@keepassxc.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -32,7 +32,6 @@ BrowserPasskeysConfirmationDialog::BrowserPasskeysConfirmationDialog(QWidget* pa
|
||||
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
|
||||
|
||||
m_ui->setupUi(this);
|
||||
m_ui->updateButton->setVisible(false);
|
||||
m_ui->verticalLayout->setAlignment(Qt::AlignTop);
|
||||
|
||||
connect(m_ui->credentialsTable, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(accept()));
|
||||
@ -53,21 +52,22 @@ void BrowserPasskeysConfirmationDialog::registerCredential(const QString& userna
|
||||
const QList<Entry*>& existingEntries,
|
||||
int timeout)
|
||||
{
|
||||
m_ui->firstLabel->setText(tr("Do you want to register Passkey for:"));
|
||||
m_ui->firstLabel->setText(tr("Do you want to register a passkey for:"));
|
||||
m_ui->relyingPartyLabel->setText(tr("Relying Party: %1").arg(relyingParty));
|
||||
m_ui->usernameLabel->setText(tr("Username: %1").arg(username));
|
||||
m_ui->updateButton->setVisible(true);
|
||||
m_ui->secondLabel->setText("");
|
||||
|
||||
if (!existingEntries.isEmpty()) {
|
||||
m_ui->firstLabel->setText(tr("Existing Passkey found.\nDo you want to register a new Passkey for:"));
|
||||
m_ui->secondLabel->setText(tr("Select the existing Passkey and press Update to replace it."));
|
||||
|
||||
m_ui->updateButton->setVisible(true);
|
||||
m_ui->firstLabel->setText(tr("Existing passkey found.\nDo you want to register a new passkey for:"));
|
||||
m_ui->secondLabel->setText(tr("Select the existing passkey and press Update to replace it."));
|
||||
m_ui->updateButton->setText(tr("Update"));
|
||||
m_ui->confirmButton->setText(tr("Register new"));
|
||||
updateEntriesToTable(existingEntries);
|
||||
} else {
|
||||
m_ui->verticalLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||
m_ui->confirmButton->setText(tr("Register"));
|
||||
m_ui->updateButton->setText(tr("Add to existing entry"));
|
||||
m_ui->credentialsTable->setVisible(false);
|
||||
}
|
||||
|
||||
@ -78,9 +78,10 @@ void BrowserPasskeysConfirmationDialog::authenticateCredential(const QList<Entry
|
||||
const QString& relyingParty,
|
||||
int timeout)
|
||||
{
|
||||
m_ui->firstLabel->setText(tr("Authenticate Passkey credentials for:"));
|
||||
m_ui->firstLabel->setText(tr("Authenticate passkey credentials for:"));
|
||||
m_ui->relyingPartyLabel->setText(tr("Relying Party: %1").arg(relyingParty));
|
||||
m_ui->usernameLabel->setVisible(false);
|
||||
m_ui->updateButton->setVisible(false);
|
||||
m_ui->secondLabel->setText("");
|
||||
updateEntriesToTable(entries);
|
||||
startCounter(timeout);
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "BrowserPasskeysClient.h"
|
||||
#include "BrowserPasskeysConfirmationDialog.h"
|
||||
#include "PasskeyUtils.h"
|
||||
#include "gui/passkeys/PasskeyImporter.h"
|
||||
#endif
|
||||
#ifdef Q_OS_MACOS
|
||||
#include "gui/osutils/macutils/MacUtils.h"
|
||||
@ -658,13 +659,33 @@ QJsonObject BrowserService::showPasskeysRegisterPrompt(const QJsonObject& public
|
||||
|
||||
const auto rpName = publicKeyOptions["rp"]["name"].toString();
|
||||
if (confirmDialog.isPasskeyUpdated()) {
|
||||
addPasskeyToEntry(confirmDialog.getSelectedEntry(),
|
||||
rpId,
|
||||
rpName,
|
||||
username,
|
||||
publicKeyCredentials.credentialId,
|
||||
userId,
|
||||
publicKeyCredentials.key);
|
||||
// If no entry is selected, show the import dialog for manual entry selection
|
||||
auto selectedEntry = confirmDialog.getSelectedEntry();
|
||||
if (!selectedEntry) {
|
||||
PasskeyImporter passkeyImporter(m_currentDatabaseWidget);
|
||||
const auto result = passkeyImporter.showImportDialog(db,
|
||||
nullptr,
|
||||
origin,
|
||||
rpId,
|
||||
username,
|
||||
publicKeyCredentials.credentialId,
|
||||
userId,
|
||||
publicKeyCredentials.key,
|
||||
tr("KeePassXC - Passkey credentials"),
|
||||
tr("Register a new passkey to this entry:"),
|
||||
tr("Register"));
|
||||
if (!result) {
|
||||
return getPasskeyError(ERROR_PASSKEYS_REQUEST_CANCELED);
|
||||
}
|
||||
} else {
|
||||
addPasskeyToEntry(selectedEntry,
|
||||
rpId,
|
||||
rpName,
|
||||
username,
|
||||
publicKeyCredentials.credentialId,
|
||||
userId,
|
||||
publicKeyCredentials.key);
|
||||
}
|
||||
} else {
|
||||
addPasskeyToGroup(db,
|
||||
nullptr,
|
||||
@ -790,8 +811,8 @@ void BrowserService::addPasskeyToEntry(Entry* entry,
|
||||
// Ask confirmation if entry already contains a Passkey
|
||||
if (entry->hasPasskey()) {
|
||||
if (MessageBox::question(m_currentDatabaseWidget,
|
||||
tr("KeePassXC - Update Passkey"),
|
||||
tr("Entry already has a Passkey.\nDo you want to overwrite the Passkey in %1 - %2?")
|
||||
tr("KeePassXC - Update passkey"),
|
||||
tr("Entry already has a passkey.\nDo you want to overwrite the passkey in %1 - %2?")
|
||||
.arg(entry->title(), passkeyUtils()->getUsernameFromEntry(entry)),
|
||||
MessageBox::Overwrite | MessageBox::Cancel,
|
||||
MessageBox::Cancel)
|
||||
|
@ -313,10 +313,10 @@
|
||||
<item>
|
||||
<widget class="QCheckBox" name="allowLocalhostWithPasskeys">
|
||||
<property name="toolTip">
|
||||
<string>Allows using insecure http://localhost with Passkeys for testing purposes.</string>
|
||||
<string>Allows using insecure http://localhost with passkeys for testing purposes.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Allow using localhost with Passkeys</string>
|
||||
<string>Allow using localhost with passkeys</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
|
||||
* Copyright (C) 2024 KeePassXC Team <team@keepassxc.org>
|
||||
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -1415,7 +1415,7 @@ void DatabaseWidget::switchToPasskeys()
|
||||
|
||||
void DatabaseWidget::showImportPasskeyDialog(bool isEntry)
|
||||
{
|
||||
PasskeyImporter passkeyImporter;
|
||||
PasskeyImporter passkeyImporter(this);
|
||||
|
||||
if (isEntry) {
|
||||
auto currentEntry = currentSelectedEntry();
|
||||
|
@ -23,7 +23,7 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Export the following Passkey entries.</string>
|
||||
<string>Export the following passkey entries.</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
|
@ -27,13 +27,18 @@
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
PasskeyExporter::PasskeyExporter(QWidget* parent)
|
||||
: m_parent(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void PasskeyExporter::showExportDialog(const QList<Entry*>& items)
|
||||
{
|
||||
if (items.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PasskeyExportDialog passkeyExportDialog;
|
||||
PasskeyExportDialog passkeyExportDialog(m_parent);
|
||||
passkeyExportDialog.setEntries(items);
|
||||
auto ret = passkeyExportDialog.exec();
|
||||
|
||||
@ -69,7 +74,7 @@ void PasskeyExporter::exportSelectedEntry(const Entry* entry, const QString& fol
|
||||
{
|
||||
const auto fullPath = QString("%1/%2.passkey").arg(folder, Tools::cleanFilename(entry->title()));
|
||||
if (QFile::exists(fullPath)) {
|
||||
auto dialogResult = MessageBox::warning(nullptr,
|
||||
auto dialogResult = MessageBox::warning(m_parent,
|
||||
tr("KeePassXC: Passkey Export"),
|
||||
tr("File \"%1.passkey\" already exists.\n"
|
||||
"Do you want to overwrite it?\n")
|
||||
@ -84,7 +89,7 @@ void PasskeyExporter::exportSelectedEntry(const Entry* entry, const QString& fol
|
||||
QFile passkeyFile(fullPath);
|
||||
if (!passkeyFile.open(QIODevice::WriteOnly)) {
|
||||
MessageBox::information(
|
||||
nullptr, tr("Cannot open file"), tr("Cannot open file \"%1\" for writing.").arg(fullPath));
|
||||
m_parent, tr("Cannot open file"), tr("Cannot open file \"%1\" for writing.").arg(fullPath));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
|
||||
* Copyright (C) 2024 KeePassXC Team <team@keepassxc.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,6 +20,8 @@
|
||||
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
#include <QWidget>
|
||||
|
||||
class Entry;
|
||||
|
||||
@ -28,12 +30,15 @@ class PasskeyExporter : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PasskeyExporter() = default;
|
||||
explicit PasskeyExporter(QWidget* parent = nullptr);
|
||||
|
||||
void showExportDialog(const QList<Entry*>& items);
|
||||
|
||||
private:
|
||||
void exportSelectedEntry(const Entry* entry, const QString& folder);
|
||||
|
||||
private:
|
||||
QPointer<QWidget> m_parent;
|
||||
};
|
||||
|
||||
#endif // KEEPASSXC_PASSKEYEXPORTER_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
|
||||
* Copyright (C) 2024 KeePassXC Team <team@keepassxc.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -48,14 +48,17 @@ PasskeyImportDialog::~PasskeyImportDialog()
|
||||
void PasskeyImportDialog::setInfo(const QString& relyingParty,
|
||||
const QString& username,
|
||||
const QSharedPointer<Database>& database,
|
||||
bool isEntry)
|
||||
bool isEntry,
|
||||
const QString& titleText,
|
||||
const QString& infoText,
|
||||
const QString& importButtonText)
|
||||
{
|
||||
m_ui->relyingPartyLabel->setText(tr("Relying Party: %1").arg(relyingParty));
|
||||
m_ui->usernameLabel->setText(tr("Username: %1").arg(username));
|
||||
|
||||
if (isEntry) {
|
||||
m_ui->verticalLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||
m_ui->infoLabel->setText(tr("Import the following Passkey to this entry:"));
|
||||
m_ui->infoLabel->setText(tr("Import the following passkey to this entry:"));
|
||||
m_ui->groupBox->setVisible(false);
|
||||
}
|
||||
|
||||
@ -70,6 +73,18 @@ void PasskeyImportDialog::setInfo(const QString& relyingParty,
|
||||
}
|
||||
}
|
||||
m_ui->selectDatabaseCombobBox->setEnabled(openDatabaseCount > 1);
|
||||
|
||||
if (!titleText.isEmpty()) {
|
||||
setWindowTitle(titleText);
|
||||
}
|
||||
|
||||
if (!infoText.isEmpty()) {
|
||||
m_ui->infoLabel->setText(infoText);
|
||||
}
|
||||
|
||||
if (!importButtonText.isEmpty()) {
|
||||
m_ui->importButton->setText(importButtonText);
|
||||
}
|
||||
}
|
||||
|
||||
QSharedPointer<Database> PasskeyImportDialog::getSelectedDatabase() const
|
||||
@ -155,7 +170,7 @@ void PasskeyImportDialog::addGroups()
|
||||
}
|
||||
|
||||
m_ui->selectGroupComboBox->clear();
|
||||
m_ui->selectGroupComboBox->addItem(tr("Default Passkeys group (Imported Passkeys)"), {});
|
||||
m_ui->selectGroupComboBox->addItem(tr("Default passkeys group (Imported Passkeys)"), {});
|
||||
|
||||
for (const auto& group : m_selectedDatabase->rootGroup()->groupsRecursive(true)) {
|
||||
if (!group || group->isRecycled() || group == m_selectedDatabase->metadata()->recycleBin()) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
|
||||
* Copyright (C) 2024 KeePassXC Team <team@keepassxc.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -39,7 +39,10 @@ public:
|
||||
void setInfo(const QString& relyingParty,
|
||||
const QString& username,
|
||||
const QSharedPointer<Database>& database,
|
||||
bool isEntry);
|
||||
bool isEntry,
|
||||
const QString& titleText = {},
|
||||
const QString& infoText = {},
|
||||
const QString& importButtonText = {});
|
||||
QSharedPointer<Database> getSelectedDatabase() const;
|
||||
QUuid getSelectedEntryUuid() const;
|
||||
QUuid getSelectedGroupUuid() const;
|
||||
|
@ -36,7 +36,7 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Import the following Passkey:</string>
|
||||
<string>Import the following passkey:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
|
||||
* Copyright (C) 2024 KeePassXC Team <team@keepassxc.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -30,11 +30,16 @@
|
||||
|
||||
static const QString IMPORTED_PASSKEYS_GROUP = QStringLiteral("Imported Passkeys");
|
||||
|
||||
PasskeyImporter::PasskeyImporter(QWidget* parent)
|
||||
: m_parent(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void PasskeyImporter::importPasskey(QSharedPointer<Database>& database, Entry* entry)
|
||||
{
|
||||
auto filter = QString("%1 (*.passkey);;%2 (*)").arg(tr("Passkey file"), tr("All files"));
|
||||
auto fileName =
|
||||
fileDialog()->getOpenFileName(nullptr, tr("Open Passkey file"), FileDialog::getLastDir("passkey"), filter);
|
||||
fileDialog()->getOpenFileName(nullptr, tr("Open passkey file"), FileDialog::getLastDir("passkey"), filter);
|
||||
if (fileName.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@ -56,9 +61,9 @@ void PasskeyImporter::importSelectedFile(QFile& file, QSharedPointer<Database>&
|
||||
const auto fileData = file.readAll();
|
||||
const auto passkeyObject = browserMessageBuilder()->getJsonObject(fileData);
|
||||
if (passkeyObject.isEmpty()) {
|
||||
MessageBox::information(nullptr,
|
||||
tr("Cannot import Passkey"),
|
||||
tr("Cannot import Passkey file \"%1\". Data is missing.").arg(file.fileName()));
|
||||
MessageBox::information(m_parent,
|
||||
tr("Cannot import passkey"),
|
||||
tr("Cannot import passkey file \"%1\". Data is missing.").arg(file.fileName()));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -70,43 +75,46 @@ void PasskeyImporter::importSelectedFile(QFile& file, QSharedPointer<Database>&
|
||||
<< "credentialId"
|
||||
<< "userHandle"
|
||||
<< "privateKey");
|
||||
|
||||
if (!missingKeys.isEmpty()) {
|
||||
MessageBox::information(nullptr,
|
||||
tr("Cannot import Passkey"),
|
||||
tr("Cannot import Passkey file \"%1\".\nThe following data is missing:\n%2")
|
||||
MessageBox::information(m_parent,
|
||||
tr("Cannot import passkey"),
|
||||
tr("Cannot import passkey file \"%1\".\nThe following data is missing:\n%2")
|
||||
.arg(file.fileName(), missingKeys.join(", ")));
|
||||
} else if (!privateKey.startsWith("-----BEGIN PRIVATE KEY-----")
|
||||
|| !privateKey.trimmed().endsWith("-----END PRIVATE KEY-----")) {
|
||||
MessageBox::information(
|
||||
nullptr,
|
||||
tr("Cannot import Passkey"),
|
||||
tr("Cannot import Passkey file \"%1\". Private key is missing or malformed.").arg(file.fileName()));
|
||||
m_parent,
|
||||
tr("Cannot import passkey"),
|
||||
tr("Cannot import passkey file \"%1\". Private key is missing or malformed.").arg(file.fileName()));
|
||||
} else {
|
||||
const auto relyingParty = passkeyObject["relyingParty"].toString();
|
||||
const auto url = passkeyObject["url"].toString();
|
||||
const auto username = passkeyObject["username"].toString();
|
||||
const auto credentialId = passkeyObject["credentialId"].toString();
|
||||
const auto userHandle = passkeyObject["userHandle"].toString();
|
||||
showImportDialog(database, url, relyingParty, username, credentialId, userHandle, privateKey, entry);
|
||||
showImportDialog(database, entry, url, relyingParty, username, credentialId, userHandle, privateKey);
|
||||
}
|
||||
}
|
||||
|
||||
void PasskeyImporter::showImportDialog(QSharedPointer<Database>& database,
|
||||
bool PasskeyImporter::showImportDialog(QSharedPointer<Database>& database,
|
||||
Entry* entry,
|
||||
const QString& url,
|
||||
const QString& relyingParty,
|
||||
const QString& username,
|
||||
const QString& credentialId,
|
||||
const QString& userHandle,
|
||||
const QString& privateKey,
|
||||
Entry* entry)
|
||||
const QString& titleText,
|
||||
const QString& infoText,
|
||||
const QString& importButtonText)
|
||||
{
|
||||
PasskeyImportDialog passkeyImportDialog;
|
||||
passkeyImportDialog.setInfo(relyingParty, username, database, entry != nullptr);
|
||||
PasskeyImportDialog passkeyImportDialog(m_parent);
|
||||
passkeyImportDialog.setInfo(
|
||||
relyingParty, username, database, entry != nullptr, titleText, infoText, importButtonText);
|
||||
|
||||
auto ret = passkeyImportDialog.exec();
|
||||
if (ret != QDialog::Accepted) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
auto db = passkeyImportDialog.getSelectedDatabase();
|
||||
@ -118,7 +126,7 @@ void PasskeyImporter::showImportDialog(QSharedPointer<Database>& database,
|
||||
if (entry) {
|
||||
browserService()->addPasskeyToEntry(
|
||||
entry, relyingParty, relyingParty, username, credentialId, userHandle, privateKey);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Import to entry selected instead of creating a new one
|
||||
@ -134,7 +142,7 @@ void PasskeyImporter::showImportDialog(QSharedPointer<Database>& database,
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Group settings. Use default group "Imported Passkeys" if user did not select a specific one.
|
||||
@ -153,6 +161,8 @@ void PasskeyImporter::showImportDialog(QSharedPointer<Database>& database,
|
||||
|
||||
browserService()->addPasskeyToGroup(
|
||||
db, group, url, relyingParty, relyingParty, username, credentialId, userHandle, privateKey);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Group* PasskeyImporter::getDefaultGroup(QSharedPointer<Database>& database) const
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
|
||||
* Copyright (C) 2024 KeePassXC Team <team@keepassxc.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -21,7 +21,9 @@
|
||||
#include "core/Database.h"
|
||||
#include <QFile>
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
#include <QUuid>
|
||||
#include <QWidget>
|
||||
|
||||
class Entry;
|
||||
|
||||
@ -30,21 +32,27 @@ class PasskeyImporter : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PasskeyImporter() = default;
|
||||
explicit PasskeyImporter(QWidget* parent = nullptr);
|
||||
|
||||
void importPasskey(QSharedPointer<Database>& database, Entry* entry = nullptr);
|
||||
|
||||
private:
|
||||
void importSelectedFile(QFile& file, QSharedPointer<Database>& database, Entry* entry);
|
||||
void showImportDialog(QSharedPointer<Database>& database,
|
||||
bool showImportDialog(QSharedPointer<Database>& database,
|
||||
Entry* entry,
|
||||
const QString& url,
|
||||
const QString& relyingParty,
|
||||
const QString& username,
|
||||
const QString& credentialId,
|
||||
const QString& userHandle,
|
||||
const QString& privateKey,
|
||||
Entry* entry);
|
||||
const QString& titleText = {},
|
||||
const QString& infoText = {},
|
||||
const QString& importButtonText = {});
|
||||
|
||||
private:
|
||||
void importSelectedFile(QFile& file, QSharedPointer<Database>& database, Entry* entry);
|
||||
Group* getDefaultGroup(QSharedPointer<Database>& database) const;
|
||||
|
||||
private:
|
||||
QPointer<QWidget> m_parent;
|
||||
};
|
||||
|
||||
#endif // KEEPASSXC_PASSKEYIMPORTER_H
|
||||
|
@ -152,7 +152,7 @@ void ReportsWidgetPasskeys::loadSettings(QSharedPointer<Database> db)
|
||||
m_rowToEntry.clear();
|
||||
|
||||
auto row = QList<QStandardItem*>();
|
||||
row << new QStandardItem(tr("Please wait, list of entries with Passkeys is being updated…"));
|
||||
row << new QStandardItem(tr("Please wait, list of entries with passkeys is being updated…"));
|
||||
m_referencesModel->appendRow(row);
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ void ReportsWidgetPasskeys::updateEntries()
|
||||
|
||||
// Set the table header
|
||||
if (m_referencesModel->rowCount() == 0) {
|
||||
m_referencesModel->setHorizontalHeaderLabels(QStringList() << tr("No entries with Passkeys."));
|
||||
m_referencesModel->setHorizontalHeaderLabels(QStringList() << tr("No entries with passkeys."));
|
||||
} else {
|
||||
m_referencesModel->setHorizontalHeaderLabels(QStringList() << tr("Title") << tr("Path") << tr("Username")
|
||||
<< tr("Relying Party") << tr("URLs"));
|
||||
@ -282,7 +282,7 @@ void ReportsWidgetPasskeys::selectionChanged()
|
||||
|
||||
void ReportsWidgetPasskeys::importPasskey()
|
||||
{
|
||||
PasskeyImporter passkeyImporter;
|
||||
PasskeyImporter passkeyImporter(this);
|
||||
passkeyImporter.importPasskey(m_db);
|
||||
|
||||
updateEntries();
|
||||
@ -300,6 +300,6 @@ void ReportsWidgetPasskeys::exportPasskey()
|
||||
return;
|
||||
}
|
||||
|
||||
PasskeyExporter passkeyExporter;
|
||||
PasskeyExporter passkeyExporter(this);
|
||||
passkeyExporter.showExportDialog(getSelectedEntries());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user