mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-25 15:29:44 -05:00
Add support for group selection when creating a passkey
This commit is contained in:
parent
c1a66a8be9
commit
ea2e36c676
@ -579,8 +579,9 @@ QJsonObject BrowserAction::handlePasskeysRegister(const QJsonObject& json, const
|
|||||||
return getErrorReply(action, ERROR_PASSKEYS_INVALID_URL_PROVIDED);
|
return getErrorReply(action, ERROR_PASSKEYS_INVALID_URL_PROVIDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto groupName = browserRequest.getString("groupName");
|
||||||
const auto keyList = getConnectionKeys(browserRequest);
|
const auto keyList = getConnectionKeys(browserRequest);
|
||||||
const auto response = browserService()->showPasskeysRegisterPrompt(publicKey, origin, keyList);
|
const auto response = browserService()->showPasskeysRegisterPrompt(publicKey, origin, groupName, keyList);
|
||||||
|
|
||||||
const Parameters params{{"response", response}};
|
const Parameters params{{"response", response}};
|
||||||
return buildResponse(action, browserRequest.incrementedNonce, params);
|
return buildResponse(action, browserRequest.incrementedNonce, params);
|
||||||
|
@ -58,6 +58,7 @@ static const QString KEEPASSXCBROWSER_GROUP_NAME = QStringLiteral("KeePassXC-Bro
|
|||||||
static int KEEPASSXCBROWSER_DEFAULT_ICON = 1;
|
static int KEEPASSXCBROWSER_DEFAULT_ICON = 1;
|
||||||
#ifdef WITH_XC_BROWSER_PASSKEYS
|
#ifdef WITH_XC_BROWSER_PASSKEYS
|
||||||
static int KEEPASSXCBROWSER_PASSKEY_ICON = 13;
|
static int KEEPASSXCBROWSER_PASSKEY_ICON = 13;
|
||||||
|
static const QString PASSKEYS_DEFAULT_GROUP_NAME = QStringLiteral("KeePassXC-Browser Passkeys");
|
||||||
#endif
|
#endif
|
||||||
// These are for the settings and password conversion
|
// These are for the settings and password conversion
|
||||||
static const QString KEEPASSHTTP_NAME = QStringLiteral("KeePassHttp Settings");
|
static const QString KEEPASSHTTP_NAME = QStringLiteral("KeePassHttp Settings");
|
||||||
@ -258,8 +259,12 @@ QJsonArray BrowserService::getDatabaseEntries()
|
|||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject BrowserService::createNewGroup(const QString& groupName)
|
QJsonObject BrowserService::createNewGroup(const QString& groupName, bool isPasskeysGroup)
|
||||||
{
|
{
|
||||||
|
if (groupName.isEmpty()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
auto db = getDatabase();
|
auto db = getDatabase();
|
||||||
if (!db) {
|
if (!db) {
|
||||||
return {};
|
return {};
|
||||||
@ -309,10 +314,15 @@ QJsonObject BrowserService::createNewGroup(const QString& groupName)
|
|||||||
QString gName = getGroupName(i);
|
QString gName = getGroupName(i);
|
||||||
auto tempGroup = rootGroup->findGroupByPath(gName);
|
auto tempGroup = rootGroup->findGroupByPath(gName);
|
||||||
if (!tempGroup) {
|
if (!tempGroup) {
|
||||||
Group* newGroup = new Group();
|
auto newGroup = new Group();
|
||||||
newGroup->setName(groups[i]);
|
newGroup->setName(groups[i]);
|
||||||
newGroup->setUuid(QUuid::createUuid());
|
newGroup->setUuid(QUuid::createUuid());
|
||||||
newGroup->setParent(previousGroup);
|
newGroup->setParent(previousGroup);
|
||||||
|
#ifdef WITH_XC_BROWSER_PASSKEYS
|
||||||
|
if (isPasskeysGroup && i == groups.length() - 1) {
|
||||||
|
newGroup->setIcon(KEEPASSXCBROWSER_PASSKEY_ICON);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
name = newGroup->name();
|
name = newGroup->name();
|
||||||
uuid = Tools::uuidToHex(newGroup->uuid());
|
uuid = Tools::uuidToHex(newGroup->uuid());
|
||||||
previousGroup = newGroup;
|
previousGroup = newGroup;
|
||||||
@ -620,6 +630,7 @@ QString BrowserService::getKey(const QString& id)
|
|||||||
// Passkey registration
|
// Passkey registration
|
||||||
QJsonObject BrowserService::showPasskeysRegisterPrompt(const QJsonObject& publicKeyOptions,
|
QJsonObject BrowserService::showPasskeysRegisterPrompt(const QJsonObject& publicKeyOptions,
|
||||||
const QString& origin,
|
const QString& origin,
|
||||||
|
const QString& groupName,
|
||||||
const StringPairList& keyList)
|
const StringPairList& keyList)
|
||||||
{
|
{
|
||||||
auto db = selectedDatabase();
|
auto db = selectedDatabase();
|
||||||
@ -691,8 +702,13 @@ QJsonObject BrowserService::showPasskeysRegisterPrompt(const QJsonObject& public
|
|||||||
publicKeyCredentials.key);
|
publicKeyCredentials.key);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Handle new/existing group
|
||||||
|
const auto createResponse =
|
||||||
|
createNewGroup(groupName.isEmpty() ? PASSKEYS_DEFAULT_GROUP_NAME : groupName, true);
|
||||||
|
const auto group = db->rootGroup()->findGroupByUuid(Tools::hexToUuid(createResponse["uuid"].toString()));
|
||||||
|
|
||||||
addPasskeyToGroup(db,
|
addPasskeyToGroup(db,
|
||||||
nullptr,
|
group,
|
||||||
origin,
|
origin,
|
||||||
rpId,
|
rpId,
|
||||||
rpName,
|
rpName,
|
||||||
|
@ -80,7 +80,7 @@ public:
|
|||||||
|
|
||||||
QJsonObject getDatabaseGroups();
|
QJsonObject getDatabaseGroups();
|
||||||
QJsonArray getDatabaseEntries();
|
QJsonArray getDatabaseEntries();
|
||||||
QJsonObject createNewGroup(const QString& groupName);
|
QJsonObject createNewGroup(const QString& groupName, bool isPasskeysGroup = false);
|
||||||
QString getCurrentTotp(const QString& uuid);
|
QString getCurrentTotp(const QString& uuid);
|
||||||
void showPasswordGenerator(const KeyPairMessage& keyPairMessage);
|
void showPasswordGenerator(const KeyPairMessage& keyPairMessage);
|
||||||
bool isPasswordGeneratorRequested() const;
|
bool isPasswordGeneratorRequested() const;
|
||||||
@ -90,6 +90,7 @@ public:
|
|||||||
#ifdef WITH_XC_BROWSER_PASSKEYS
|
#ifdef WITH_XC_BROWSER_PASSKEYS
|
||||||
QJsonObject showPasskeysRegisterPrompt(const QJsonObject& publicKeyOptions,
|
QJsonObject showPasskeysRegisterPrompt(const QJsonObject& publicKeyOptions,
|
||||||
const QString& origin,
|
const QString& origin,
|
||||||
|
const QString& groupName,
|
||||||
const StringPairList& keyList);
|
const StringPairList& keyList);
|
||||||
QJsonObject showPasskeysAuthenticationPrompt(const QJsonObject& publicKeyOptions,
|
QJsonObject showPasskeysAuthenticationPrompt(const QJsonObject& publicKeyOptions,
|
||||||
const QString& origin,
|
const QString& origin,
|
||||||
|
Loading…
Reference in New Issue
Block a user