mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-05 05:27:39 +03:00
Passkeys: Add support for importing Passkey to entry (#9987)
--------- Co-authored-by: Jonathan White <support@dmapps.us>
This commit is contained in:
parent
013db199cb
commit
13c88e1013
27 changed files with 459 additions and 176 deletions
|
@ -64,8 +64,6 @@ const QString BrowserService::OPTION_HIDE_ENTRY = QStringLiteral("BrowserHideEnt
|
|||
const QString BrowserService::OPTION_ONLY_HTTP_AUTH = QStringLiteral("BrowserOnlyHttpAuth");
|
||||
const QString BrowserService::OPTION_NOT_HTTP_AUTH = QStringLiteral("BrowserNotHttpAuth");
|
||||
const QString BrowserService::OPTION_OMIT_WWW = QStringLiteral("BrowserOmitWww");
|
||||
// Multiple URL's
|
||||
const QString BrowserService::ADDITIONAL_URL = QStringLiteral("KP2A_URL");
|
||||
|
||||
Q_GLOBAL_STATIC(BrowserService, s_browserService);
|
||||
|
||||
|
@ -775,6 +773,20 @@ void BrowserService::addPasskeyToEntry(Entry* entry,
|
|||
return;
|
||||
}
|
||||
|
||||
// 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?")
|
||||
.arg(entry->title(), entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_USERNAME)),
|
||||
MessageBox::Overwrite | MessageBox::Cancel,
|
||||
MessageBox::Cancel)
|
||||
!= MessageBox::Overwrite) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
entry->beginUpdate();
|
||||
|
||||
entry->attributes()->set(BrowserPasskeys::KPEX_PASSKEY_USERNAME, username);
|
||||
|
@ -1084,7 +1096,13 @@ void BrowserService::denyEntry(Entry* entry, const QString& siteHost, const QStr
|
|||
QJsonObject BrowserService::prepareEntry(const Entry* entry)
|
||||
{
|
||||
QJsonObject res;
|
||||
#ifdef WITH_XC_BROWSER_PASSKEYS
|
||||
// Use Passkey's username instead if found
|
||||
res["login"] = entry->hasPasskey() ? entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_USERNAME)
|
||||
: entry->resolveMultiplePlaceholders(entry->username());
|
||||
#else
|
||||
res["login"] = entry->resolveMultiplePlaceholders(entry->username());
|
||||
#endif
|
||||
res["password"] = entry->resolveMultiplePlaceholders(entry->password());
|
||||
res["name"] = entry->resolveMultiplePlaceholders(entry->title());
|
||||
res["uuid"] = entry->resolveMultiplePlaceholders(entry->uuidToHex());
|
||||
|
@ -1291,8 +1309,7 @@ QList<Entry*> BrowserService::getPasskeyEntries(const QString& rpId, const Strin
|
|||
{
|
||||
QList<Entry*> entries;
|
||||
for (const auto& entry : searchEntries(rpId, "", keyList, true)) {
|
||||
if (entry->attributes()->hasKey(BrowserPasskeys::KPEX_PASSKEY_PRIVATE_KEY_PEM)
|
||||
&& entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_RELYING_PARTY) == rpId) {
|
||||
if (entry->hasPasskey() && entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_RELYING_PARTY) == rpId) {
|
||||
entries << entry;
|
||||
}
|
||||
}
|
||||
|
@ -1419,14 +1436,34 @@ bool BrowserService::handleURL(const QString& entryUrl,
|
|||
return false;
|
||||
}
|
||||
|
||||
QSharedPointer<Database> BrowserService::getDatabase()
|
||||
QSharedPointer<Database> BrowserService::getDatabase(const QUuid& rootGroupUuid)
|
||||
{
|
||||
if (!rootGroupUuid.isNull()) {
|
||||
const auto openDatabases = getOpenDatabases();
|
||||
for (const auto& db : openDatabases) {
|
||||
if (db->rootGroup()->uuid() == rootGroupUuid) {
|
||||
return db;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_currentDatabaseWidget) {
|
||||
return m_currentDatabaseWidget->database();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
QList<QSharedPointer<Database>> BrowserService::getOpenDatabases()
|
||||
{
|
||||
QList<QSharedPointer<Database>> databaseList;
|
||||
for (auto dbWidget : getMainWindow()->getOpenDatabases()) {
|
||||
if (!dbWidget->isLocked()) {
|
||||
databaseList << dbWidget->database();
|
||||
}
|
||||
}
|
||||
return databaseList;
|
||||
}
|
||||
|
||||
QSharedPointer<Database> BrowserService::selectedDatabase()
|
||||
{
|
||||
QList<DatabaseWidget*> databaseWidgets;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue