mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-05-02 14:46:07 -04:00
Passkeys: Register to an existing entry
This commit is contained in:
parent
bd449f3226
commit
92b30ae7ec
15 changed files with 212 additions and 128 deletions
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue