mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Rename userId to credentialId
This commit is contained in:
parent
1126055015
commit
a3717c7acd
@ -61,7 +61,8 @@ PublicKeyCredential BrowserPasskeys::buildRegisterPublicKeyCredential(const QJso
|
|||||||
const TestingVariables& testingVariables)
|
const TestingVariables& testingVariables)
|
||||||
{
|
{
|
||||||
QJsonObject publicKeyCredential;
|
QJsonObject publicKeyCredential;
|
||||||
const auto id = testingVariables.credentialId.isEmpty() ? browserMessageBuilder()->getRandomBytesAsBase64(ID_BYTES)
|
const auto credentialId = testingVariables.credentialId.isEmpty()
|
||||||
|
? browserMessageBuilder()->getRandomBytesAsBase64(ID_BYTES)
|
||||||
: testingVariables.credentialId;
|
: testingVariables.credentialId;
|
||||||
|
|
||||||
// Extensions
|
// Extensions
|
||||||
@ -72,22 +73,23 @@ PublicKeyCredential BrowserPasskeys::buildRegisterPublicKeyCredential(const QJso
|
|||||||
// Response
|
// Response
|
||||||
QJsonObject responseObject;
|
QJsonObject responseObject;
|
||||||
const auto clientData = buildClientDataJson(publicKeyCredentialOptions, origin, false);
|
const auto clientData = buildClientDataJson(publicKeyCredentialOptions, origin, false);
|
||||||
const auto attestationObject = buildAttestationObject(publicKeyCredentialOptions, extensions, id, testingVariables);
|
const auto attestationObject =
|
||||||
|
buildAttestationObject(publicKeyCredentialOptions, extensions, credentialId, testingVariables);
|
||||||
responseObject["clientDataJSON"] = browserMessageBuilder()->getBase64FromJson(clientData);
|
responseObject["clientDataJSON"] = browserMessageBuilder()->getBase64FromJson(clientData);
|
||||||
responseObject["attestationObject"] = browserMessageBuilder()->getBase64FromArray(attestationObject.cborEncoded);
|
responseObject["attestationObject"] = browserMessageBuilder()->getBase64FromArray(attestationObject.cborEncoded);
|
||||||
|
|
||||||
// PublicKeyCredential
|
// PublicKeyCredential
|
||||||
publicKeyCredential["authenticatorAttachment"] = QString("platform");
|
publicKeyCredential["authenticatorAttachment"] = QString("platform");
|
||||||
publicKeyCredential["id"] = id;
|
publicKeyCredential["id"] = credentialId;
|
||||||
publicKeyCredential["response"] = responseObject;
|
publicKeyCredential["response"] = responseObject;
|
||||||
publicKeyCredential["type"] = PUBLIC_KEY;
|
publicKeyCredential["type"] = PUBLIC_KEY;
|
||||||
|
|
||||||
return {id, publicKeyCredential, attestationObject.pem};
|
return {credentialId, publicKeyCredential, attestationObject.pem};
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject BrowserPasskeys::buildGetPublicKeyCredential(const QJsonObject& publicKeyCredentialRequestOptions,
|
QJsonObject BrowserPasskeys::buildGetPublicKeyCredential(const QJsonObject& publicKeyCredentialRequestOptions,
|
||||||
const QString& origin,
|
const QString& origin,
|
||||||
const QString& userId,
|
const QString& credentialId,
|
||||||
const QString& userHandle,
|
const QString& userHandle,
|
||||||
const QString& privateKeyPem)
|
const QString& privateKeyPem)
|
||||||
{
|
{
|
||||||
@ -104,7 +106,7 @@ QJsonObject BrowserPasskeys::buildGetPublicKeyCredential(const QJsonObject& publ
|
|||||||
|
|
||||||
QJsonObject publicKeyCredential;
|
QJsonObject publicKeyCredential;
|
||||||
publicKeyCredential["authenticatorAttachment"] = QString("platform");
|
publicKeyCredential["authenticatorAttachment"] = QString("platform");
|
||||||
publicKeyCredential["id"] = userId;
|
publicKeyCredential["id"] = credentialId;
|
||||||
publicKeyCredential["response"] = responseObject;
|
publicKeyCredential["response"] = responseObject;
|
||||||
publicKeyCredential["type"] = PUBLIC_KEY;
|
publicKeyCredential["type"] = PUBLIC_KEY;
|
||||||
|
|
||||||
@ -156,7 +158,7 @@ QJsonObject BrowserPasskeys::buildClientDataJson(const QJsonObject& publicKey, c
|
|||||||
// https://w3c.github.io/webauthn/#attestation-object
|
// https://w3c.github.io/webauthn/#attestation-object
|
||||||
PrivateKey BrowserPasskeys::buildAttestationObject(const QJsonObject& publicKey,
|
PrivateKey BrowserPasskeys::buildAttestationObject(const QJsonObject& publicKey,
|
||||||
const QString& extensions,
|
const QString& extensions,
|
||||||
const QString& id,
|
const QString& credentialId,
|
||||||
const TestingVariables& testingVariables)
|
const TestingVariables& testingVariables)
|
||||||
{
|
{
|
||||||
QByteArray result;
|
QByteArray result;
|
||||||
@ -188,7 +190,7 @@ PrivateKey BrowserPasskeys::buildAttestationObject(const QJsonObject& publicKey,
|
|||||||
|
|
||||||
// Credential Id
|
// Credential Id
|
||||||
result.append(QByteArray::fromBase64(
|
result.append(QByteArray::fromBase64(
|
||||||
testingVariables.credentialId.isEmpty() ? id.toUtf8() : testingVariables.credentialId.toUtf8(),
|
testingVariables.credentialId.isEmpty() ? credentialId.toUtf8() : testingVariables.credentialId.toUtf8(),
|
||||||
QByteArray::Base64UrlEncoding));
|
QByteArray::Base64UrlEncoding));
|
||||||
|
|
||||||
// Credential private key
|
// Credential private key
|
||||||
|
@ -54,7 +54,7 @@ enum AuthenticatorFlags
|
|||||||
|
|
||||||
struct PublicKeyCredential
|
struct PublicKeyCredential
|
||||||
{
|
{
|
||||||
QString id;
|
QString credentialId;
|
||||||
QJsonObject response;
|
QJsonObject response;
|
||||||
QByteArray key;
|
QByteArray key;
|
||||||
};
|
};
|
||||||
@ -87,7 +87,7 @@ public:
|
|||||||
const TestingVariables& predefinedVariables = {});
|
const TestingVariables& predefinedVariables = {});
|
||||||
QJsonObject buildGetPublicKeyCredential(const QJsonObject& publicKeyCredentialRequestOptions,
|
QJsonObject buildGetPublicKeyCredential(const QJsonObject& publicKeyCredentialRequestOptions,
|
||||||
const QString& origin,
|
const QString& origin,
|
||||||
const QString& userId,
|
const QString& credentialId,
|
||||||
const QString& userHandle,
|
const QString& userHandle,
|
||||||
const QString& privateKeyPem);
|
const QString& privateKeyPem);
|
||||||
bool isUserVerificationValid(const QString& userVerification) const;
|
bool isUserVerificationValid(const QString& userVerification) const;
|
||||||
@ -112,7 +112,7 @@ private:
|
|||||||
QJsonObject buildClientDataJson(const QJsonObject& publicKey, const QString& origin, bool get);
|
QJsonObject buildClientDataJson(const QJsonObject& publicKey, const QString& origin, bool get);
|
||||||
PrivateKey buildAttestationObject(const QJsonObject& publicKey,
|
PrivateKey buildAttestationObject(const QJsonObject& publicKey,
|
||||||
const QString& extensions,
|
const QString& extensions,
|
||||||
const QString& id,
|
const QString& credentialId,
|
||||||
const TestingVariables& predefinedVariables = {});
|
const TestingVariables& predefinedVariables = {});
|
||||||
QByteArray buildGetAttestationObject(const QJsonObject& publicKey);
|
QByteArray buildGetAttestationObject(const QJsonObject& publicKey);
|
||||||
PrivateKey buildCredentialPrivateKey(int alg,
|
PrivateKey buildCredentialPrivateKey(int alg,
|
||||||
|
@ -666,12 +666,18 @@ QJsonObject BrowserService::showPasskeysRegisterPrompt(const QJsonObject& public
|
|||||||
rpId,
|
rpId,
|
||||||
rpName,
|
rpName,
|
||||||
username,
|
username,
|
||||||
publicKeyCredentials.id,
|
publicKeyCredentials.credentialId,
|
||||||
userHandle,
|
userHandle,
|
||||||
publicKeyCredentials.key);
|
publicKeyCredentials.key);
|
||||||
} else {
|
} else {
|
||||||
addPasskeyToGroup(
|
addPasskeyToGroup(nullptr,
|
||||||
nullptr, origin, rpId, rpName, username, publicKeyCredentials.id, userHandle, publicKeyCredentials.key);
|
origin,
|
||||||
|
rpId,
|
||||||
|
rpName,
|
||||||
|
username,
|
||||||
|
publicKeyCredentials.credentialId,
|
||||||
|
userHandle,
|
||||||
|
publicKeyCredentials.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
hideWindow();
|
hideWindow();
|
||||||
@ -730,7 +736,7 @@ void BrowserService::addPasskeyToGroup(Group* group,
|
|||||||
const QString& rpId,
|
const QString& rpId,
|
||||||
const QString& rpName,
|
const QString& rpName,
|
||||||
const QString& username,
|
const QString& username,
|
||||||
const QString& userId,
|
const QString& credentialId,
|
||||||
const QString& userHandle,
|
const QString& userHandle,
|
||||||
const QString& privateKey)
|
const QString& privateKey)
|
||||||
{
|
{
|
||||||
@ -751,7 +757,7 @@ void BrowserService::addPasskeyToGroup(Group* group,
|
|||||||
entry->setUrl(url);
|
entry->setUrl(url);
|
||||||
entry->setIcon(KEEPASSXCBROWSER_PASSKEY_ICON);
|
entry->setIcon(KEEPASSXCBROWSER_PASSKEY_ICON);
|
||||||
|
|
||||||
addPasskeyToEntry(entry, rpId, rpName, username, userId, userHandle, privateKey);
|
addPasskeyToEntry(entry, rpId, rpName, username, credentialId, userHandle, privateKey);
|
||||||
|
|
||||||
// Remove blank entry history
|
// Remove blank entry history
|
||||||
entry->removeHistoryItems(entry->historyItems());
|
entry->removeHistoryItems(entry->historyItems());
|
||||||
@ -761,7 +767,7 @@ void BrowserService::addPasskeyToEntry(Entry* entry,
|
|||||||
const QString& rpId,
|
const QString& rpId,
|
||||||
const QString& rpName,
|
const QString& rpName,
|
||||||
const QString& username,
|
const QString& username,
|
||||||
const QString& userId,
|
const QString& credentialId,
|
||||||
const QString& userHandle,
|
const QString& userHandle,
|
||||||
const QString& privateKey)
|
const QString& privateKey)
|
||||||
{
|
{
|
||||||
@ -776,7 +782,7 @@ void BrowserService::addPasskeyToEntry(Entry* entry,
|
|||||||
entry->beginUpdate();
|
entry->beginUpdate();
|
||||||
|
|
||||||
entry->attributes()->set(BrowserPasskeys::KPEX_PASSKEY_USERNAME, username);
|
entry->attributes()->set(BrowserPasskeys::KPEX_PASSKEY_USERNAME, username);
|
||||||
entry->attributes()->set(BrowserPasskeys::KPEX_PASSKEY_GENERATED_USER_ID, userId, true);
|
entry->attributes()->set(BrowserPasskeys::KPEX_PASSKEY_GENERATED_USER_ID, credentialId, true);
|
||||||
entry->attributes()->set(BrowserPasskeys::KPEX_PASSKEY_PRIVATE_KEY_PEM, privateKey, true);
|
entry->attributes()->set(BrowserPasskeys::KPEX_PASSKEY_PRIVATE_KEY_PEM, privateKey, true);
|
||||||
entry->attributes()->set(BrowserPasskeys::KPEX_PASSKEY_RELYING_PARTY, rpId);
|
entry->attributes()->set(BrowserPasskeys::KPEX_PASSKEY_RELYING_PARTY, rpId);
|
||||||
entry->attributes()->set(BrowserPasskeys::KPEX_PASSKEY_USER_HANDLE, userHandle, true);
|
entry->attributes()->set(BrowserPasskeys::KPEX_PASSKEY_USER_HANDLE, userHandle, true);
|
||||||
@ -1324,9 +1330,9 @@ QJsonObject
|
|||||||
BrowserService::getPublicKeyCredentialFromEntry(const Entry* entry, const QJsonObject& publicKey, const QString& origin)
|
BrowserService::getPublicKeyCredentialFromEntry(const Entry* entry, const QJsonObject& publicKey, const QString& origin)
|
||||||
{
|
{
|
||||||
const auto privateKeyPem = entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_PRIVATE_KEY_PEM);
|
const auto privateKeyPem = entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_PRIVATE_KEY_PEM);
|
||||||
const auto userId = entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_GENERATED_USER_ID);
|
const auto credentialId = entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_GENERATED_USER_ID);
|
||||||
const auto userHandle = entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_USER_HANDLE);
|
const auto userHandle = entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_USER_HANDLE);
|
||||||
return browserPasskeys()->buildGetPublicKeyCredential(publicKey, origin, userId, userHandle, privateKeyPem);
|
return browserPasskeys()->buildGetPublicKeyCredential(publicKey, origin, credentialId, userHandle, privateKeyPem);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if the same user ID already exists for the current site
|
// Checks if the same user ID already exists for the current site
|
||||||
|
@ -84,7 +84,6 @@ public:
|
|||||||
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;
|
||||||
bool isUrlIdentical(const QString& first, const QString& second) const;
|
|
||||||
QSharedPointer<Database> selectedDatabase();
|
QSharedPointer<Database> selectedDatabase();
|
||||||
#ifdef WITH_XC_BROWSER_PASSKEYS
|
#ifdef WITH_XC_BROWSER_PASSKEYS
|
||||||
QJsonObject
|
QJsonObject
|
||||||
@ -97,14 +96,14 @@ public:
|
|||||||
const QString& rpId,
|
const QString& rpId,
|
||||||
const QString& rpName,
|
const QString& rpName,
|
||||||
const QString& username,
|
const QString& username,
|
||||||
const QString& userId,
|
const QString& credentialId,
|
||||||
const QString& userHandle,
|
const QString& userHandle,
|
||||||
const QString& privateKey);
|
const QString& privateKey);
|
||||||
void addPasskeyToEntry(Entry* entry,
|
void addPasskeyToEntry(Entry* entry,
|
||||||
const QString& rpId,
|
const QString& rpId,
|
||||||
const QString& rpName,
|
const QString& rpName,
|
||||||
const QString& username,
|
const QString& username,
|
||||||
const QString& userId,
|
const QString& credentialId,
|
||||||
const QString& userHandle,
|
const QString& userHandle,
|
||||||
const QString& privateKey);
|
const QString& privateKey);
|
||||||
#endif
|
#endif
|
||||||
|
@ -60,7 +60,7 @@ void PasskeyExporter::showExportDialog(const QList<Entry*>& items)
|
|||||||
* "relyingParty: <relying party>,
|
* "relyingParty: <relying party>,
|
||||||
* "url": <URL>,
|
* "url": <URL>,
|
||||||
* "userHandle": <user handle>,
|
* "userHandle": <user handle>,
|
||||||
* "userId": <generated user id>,
|
* "credentialId": <generated credential id>,
|
||||||
* "username:" <username>
|
* "username:" <username>
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
@ -91,7 +91,7 @@ void PasskeyExporter::exportSelectedEntry(const Entry* entry, const QString& fol
|
|||||||
passkeyObject["relyingParty"] = entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_RELYING_PARTY);
|
passkeyObject["relyingParty"] = entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_RELYING_PARTY);
|
||||||
passkeyObject["url"] = entry->url();
|
passkeyObject["url"] = entry->url();
|
||||||
passkeyObject["username"] = entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_USERNAME);
|
passkeyObject["username"] = entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_USERNAME);
|
||||||
passkeyObject["userId"] = entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_GENERATED_USER_ID);
|
passkeyObject["credentialId"] = entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_GENERATED_USER_ID);
|
||||||
passkeyObject["userHandle"] = entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_USER_HANDLE);
|
passkeyObject["userHandle"] = entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_USER_HANDLE);
|
||||||
passkeyObject["privateKey"] = entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_PRIVATE_KEY_PEM);
|
passkeyObject["privateKey"] = entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_PRIVATE_KEY_PEM);
|
||||||
|
|
||||||
|
@ -64,11 +64,11 @@ void PasskeyImporter::importSelectedFile(QFile& file, QSharedPointer<Database>&
|
|||||||
const auto relyingParty = passkeyObject["relyingParty"].toString();
|
const auto relyingParty = passkeyObject["relyingParty"].toString();
|
||||||
const auto url = passkeyObject["url"].toString();
|
const auto url = passkeyObject["url"].toString();
|
||||||
const auto username = passkeyObject["username"].toString();
|
const auto username = passkeyObject["username"].toString();
|
||||||
const auto password = passkeyObject["userId"].toString();
|
const auto credentialId = passkeyObject["credentialId"].toString();
|
||||||
const auto userHandle = passkeyObject["userHandle"].toString();
|
const auto userHandle = passkeyObject["userHandle"].toString();
|
||||||
const auto privateKey = passkeyObject["privateKey"].toString();
|
const auto privateKey = passkeyObject["privateKey"].toString();
|
||||||
|
|
||||||
if (relyingParty.isEmpty() || username.isEmpty() || password.isEmpty() || userHandle.isEmpty()
|
if (relyingParty.isEmpty() || username.isEmpty() || credentialId.isEmpty() || userHandle.isEmpty()
|
||||||
|| privateKey.isEmpty()) {
|
|| privateKey.isEmpty()) {
|
||||||
MessageBox::information(nullptr,
|
MessageBox::information(nullptr,
|
||||||
tr("Cannot import Passkey"),
|
tr("Cannot import Passkey"),
|
||||||
@ -80,7 +80,7 @@ void PasskeyImporter::importSelectedFile(QFile& file, QSharedPointer<Database>&
|
|||||||
tr("Cannot import Passkey"),
|
tr("Cannot import Passkey"),
|
||||||
tr("Cannot import Passkey file \"%1\". Private key is missing or malformed.").arg(file.fileName()));
|
tr("Cannot import Passkey file \"%1\". Private key is missing or malformed.").arg(file.fileName()));
|
||||||
} else {
|
} else {
|
||||||
showImportDialog(database, url, relyingParty, username, password, userHandle, privateKey);
|
showImportDialog(database, url, relyingParty, username, credentialId, userHandle, privateKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ void PasskeyImporter::showImportDialog(QSharedPointer<Database>& database,
|
|||||||
const QString& url,
|
const QString& url,
|
||||||
const QString& relyingParty,
|
const QString& relyingParty,
|
||||||
const QString& username,
|
const QString& username,
|
||||||
const QString& userId,
|
const QString& credentialId,
|
||||||
const QString& userHandle,
|
const QString& userHandle,
|
||||||
const QString& privateKey)
|
const QString& privateKey)
|
||||||
{
|
{
|
||||||
@ -120,7 +120,7 @@ void PasskeyImporter::showImportDialog(QSharedPointer<Database>& database,
|
|||||||
}
|
}
|
||||||
|
|
||||||
browserService()->addPasskeyToGroup(
|
browserService()->addPasskeyToGroup(
|
||||||
group, url, relyingParty, relyingParty, username, userId, userHandle, privateKey);
|
group, url, relyingParty, relyingParty, username, credentialId, userHandle, privateKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
Group* PasskeyImporter::getDefaultGroup(QSharedPointer<Database>& database)
|
Group* PasskeyImporter::getDefaultGroup(QSharedPointer<Database>& database)
|
||||||
|
@ -39,7 +39,7 @@ private:
|
|||||||
const QString& url,
|
const QString& url,
|
||||||
const QString& relyingParty,
|
const QString& relyingParty,
|
||||||
const QString& username,
|
const QString& username,
|
||||||
const QString& userId,
|
const QString& credentialId,
|
||||||
const QString& userHandle,
|
const QString& userHandle,
|
||||||
const QString& privateKey);
|
const QString& privateKey);
|
||||||
Group* getDefaultGroup(QSharedPointer<Database>& database);
|
Group* getDefaultGroup(QSharedPointer<Database>& database);
|
||||||
|
Loading…
Reference in New Issue
Block a user