Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Implement Freedesktop.org Secret Storage spec server side API #2726

Merged
merged 2 commits into from
May 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ option(WITH_XC_YUBIKEY "Include YubiKey support." OFF)
option(WITH_XC_SSHAGENT "Include SSH agent support." OFF)
option(WITH_XC_KEESHARE "Sharing integration with KeeShare (requires quazip5 for secure containers)" OFF)
option(WITH_XC_UPDATECHECK "Include automatic update checks; disable for controlled distributions" ON)
if(UNIX AND NOT APPLE)
option(WITH_XC_FDOSECRETS "Implement freedesktop.org Secret Storage Spec server side API." OFF)
endif()
if(APPLE)
option(WITH_XC_TOUCHID "Include TouchID support for macOS." OFF)
endif()
Expand All @@ -65,6 +68,9 @@ if(WITH_XC_ALL)
if(APPLE)
set(WITH_XC_TOUCHID ON)
endif()
if(UNIX AND NOT APPLE)
set(WITH_XC_FDOSECRETS ON)
endif()
endif()

if(WITH_XC_SSHAGENT OR WITH_XC_KEESHARE)
Expand Down
4 changes: 4 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,7 @@ License: LGPL-2.1
Files: share/macosx/dmg-background.tiff
Copyright: 2008-2014, Andrey Tarantsov
License: MIT

Files: share/icons/application/scalable/apps/freedesktop.svg
Copyright: GPL-2+
Comment: from Freedesktop.org website
1 change: 1 addition & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ These steps place the compiled KeePassXC binary inside the `./build/src/` direct
-DWITH_XC_NETWORKING=[ON|OFF] Enable/Disable Networking support (e.g., favicon downloading) (default: OFF)
-DWITH_XC_SSHAGENT=[ON|OFF] Enable/Disable SSHAgent support (default: OFF)
-DWITH_XC_TOUCHID=[ON|OFF] (macOS Only) Enable/Disable Touch ID unlock (default:OFF)
-DWITH_XC_FDOSECRETS=[ON|OFF] (Linux Only) Enable/Disable Freedesktop.org Secrets Service support (default:OFF)
-DWITH_XC_KEESHARE=[ON|OFF] Enable/Disable KeeShare group synchronization extension (default: OFF)
-DWITH_XC_KEESHARE_SECURE=[ON|OFF] Enable/Disable KeeShare signed containers, requires libquazip5 (default: OFF)
-DWITH_XC_ALL=[ON|OFF] Enable/Disable compiling all plugins above (default: OFF)
Expand Down
92 changes: 92 additions & 0 deletions share/icons/application/scalable/apps/freedesktop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ add_feature_info(SSHAgent WITH_XC_SSHAGENT "SSH agent integration compatible wit
add_feature_info(KeeShare WITH_XC_KEESHARE "Sharing integration with KeeShare (requires quazip5 for secure containers)")
add_feature_info(YubiKey WITH_XC_YUBIKEY "YubiKey HMAC-SHA1 challenge-response")
add_feature_info(UpdateCheck WITH_XC_UPDATECHECK "Automatic update checking")
if(UNIX AND NOT APPLE)
add_feature_info(FdoSecrets WITH_XC_FDOSECRETS "Implement freedesktop.org Secret Storage Spec server side API.")
endif()
if(APPLE)
add_feature_info(TouchID WITH_XC_TOUCHID "TouchID integration")
endif()
Expand Down Expand Up @@ -226,6 +229,11 @@ if(WITH_XC_SSHAGENT)
set(sshagent_LIB sshagent)
endif()

add_subdirectory(fdosecrets)
if(WITH_XC_FDOSECRETS)
set(fdosecrets_LIB fdosecrets)
endif()

set(autotype_SOURCES
core/Tools.cpp
autotype/AutoType.cpp
Expand Down Expand Up @@ -270,6 +278,7 @@ target_link_libraries(keepassx_core
autotype
${keepassxcbrowser_LIB}
${qrcode_LIB}
${fdosecrets_LIB}
Qt5::Core
Qt5::Concurrent
Qt5::Network
Expand Down
1 change: 1 addition & 0 deletions src/config-keepassx.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#cmakedefine WITH_XC_KEESHARE_SECURE
#cmakedefine WITH_XC_UPDATECHECK
#cmakedefine WITH_XC_TOUCHID
#cmakedefine WITH_XC_FDOSECRETS

#cmakedefine KEEPASSXC_BUILD_TYPE "@KEEPASSXC_BUILD_TYPE@"
#cmakedefine KEEPASSXC_BUILD_TYPE_RELEASE
Expand Down
22 changes: 18 additions & 4 deletions src/core/EntrySearcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,20 @@ bool EntrySearcher::searchEntryImpl(Entry* entry)
case Field::Notes:
found = term->regex.match(entry->notes()).hasMatch();
break;
case Field::Attribute:
case Field::AttributeKey:
found = !attributes.filter(term->regex).empty();
break;
case Field::Attachment:
found = !attachments.filter(term->regex).empty();
break;
case Field::AttributeValue:
// skip protected attributes
if (entry->attributes()->isProtected(term->word)) {
continue;
}
found = entry->attributes()->contains(term->word)
&& term->regex.match(entry->attributes()->value(term->word)).hasMatch();
break;
default:
// Terms without a specific field try to match title, username, url, and notes
found = term->regex.match(entry->resolvePlaceholder(entry->title())).hasMatch()
Expand Down Expand Up @@ -207,12 +215,18 @@ void EntrySearcher::parseSearchTerms(const QString& searchString)
} else if (field.compare("notes", cs) == 0) {
term->field = Field::Notes;
} else if (field.startsWith("attr", cs)) {
term->field = Field::Attribute;
term->field = Field::AttributeKey;
} else if (field.startsWith("attach", cs)) {
term->field = Field::Attachment;
} else {
term->field = Field::Undefined;
} else if (field.startsWith("_", cs)) {
term->field = Field::AttributeValue;
// searching a custom attribute
// in this case term->word is the attribute key (removing the leading "_")
// and term->regex is used to match attribute value
term->word = field.mid(1);
}
} else {
term->field = Field::Undefined;
}

m_searchTerms.append(term);
Expand Down
5 changes: 3 additions & 2 deletions src/core/EntrySearcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ class EntrySearcher
Password,
Url,
Notes,
Attribute,
Attachment
AttributeKey,
Attachment,
AttributeValue
};

struct SearchTerm
Expand Down
17 changes: 17 additions & 0 deletions src/core/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,23 @@ Entry* Group::addEntryWithPath(const QString& entryPath)
return entry;
}

void Group::applyGroupIconTo(Entry* entry)
{
if (!config()->get("UseGroupIconOnEntryCreation").toBool()) {
return;
}

if (iconNumber() == Group::DefaultIconNumber && iconUuid().isNull()) {
return;
}

if (iconUuid().isNull()) {
entry->setIcon(iconNumber());
} else {
entry->setIcon(iconUuid());
}
}

bool Group::GroupData::operator==(const Group::GroupData& other) const
{
return equals(other, CompareItemDefault);
Expand Down
2 changes: 2 additions & 0 deletions src/core/Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ class Group : public QObject
void addEntry(Entry* entry);
void removeEntry(Entry* entry);

void applyGroupIconTo(Entry* entry);

signals:
void groupDataChanged(Group* group);
void groupAboutToAdd(Group* group, int index);
Expand Down
2 changes: 2 additions & 0 deletions src/crypto/SymmetricCipher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ int SymmetricCipher::algorithmIvSize(Algorithm algo)
switch (algo) {
case ChaCha20:
return 12;
case Aes128:
return 16;
case Aes256:
return 16;
case Twofish:
Expand Down
36 changes: 36 additions & 0 deletions src/fdosecrets/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
if(WITH_XC_FDOSECRETS)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})

add_library(fdosecrets STATIC
# app settings page
FdoSecretsPlugin.cpp
widgets/SettingsWidgetFdoSecrets.cpp

# per database settings page
DatabaseSettingsPageFdoSecrets.cpp
widgets/DatabaseSettingsWidgetFdoSecrets.cpp

# setting storage
FdoSecretsSettings.cpp

# gcrypt MPI wrapper
GcryptMPI.cpp

# dbus objects
objects/DBusObject.cpp
objects/Service.cpp
objects/Session.cpp
objects/SessionCipher.cpp
objects/Collection.cpp
objects/Item.cpp
objects/Prompt.cpp
objects/adaptors/ServiceAdaptor.cpp
objects/adaptors/SessionAdaptor.cpp
objects/adaptors/CollectionAdaptor.cpp
objects/adaptors/ItemAdaptor.cpp
objects/adaptors/PromptAdaptor.cpp
objects/DBusReturn.cpp
objects/DBusTypes.cpp
)
target_link_libraries(fdosecrets Qt5::Core Qt5::Widgets Qt5::DBus ${GCRYPT_LIBRARIES})
endif()
49 changes: 49 additions & 0 deletions src/fdosecrets/DatabaseSettingsPageFdoSecrets.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2019 Aetf <aetf@unlimitedcodeworks.xyz>
*
* 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
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "DatabaseSettingsPageFdoSecrets.h"

#include "fdosecrets/widgets/DatabaseSettingsWidgetFdoSecrets.h"

#include "core/FilePath.h"

QString DatabaseSettingsPageFdoSecrets::name()
{
return QObject::tr("Secret Service Integration");
}

QIcon DatabaseSettingsPageFdoSecrets::icon()
{
return filePath()->icon(QStringLiteral("apps"), QStringLiteral("freedesktop"));
}

QWidget* DatabaseSettingsPageFdoSecrets::createWidget()
{
return new DatabaseSettingsWidgetFdoSecrets;
}

void DatabaseSettingsPageFdoSecrets::loadSettings(QWidget* widget, QSharedPointer<Database> db)
{
auto settingsWidget = qobject_cast<DatabaseSettingsWidgetFdoSecrets*>(widget);
settingsWidget->loadSettings(db);
}

void DatabaseSettingsPageFdoSecrets::saveSettings(QWidget* widget)
{
auto settingsWidget = qobject_cast<DatabaseSettingsWidgetFdoSecrets*>(widget);
settingsWidget->saveSettings();
}
36 changes: 36 additions & 0 deletions src/fdosecrets/DatabaseSettingsPageFdoSecrets.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (C) 2019 Aetf <aetf@unlimitedcodeworks.xyz>
*
* 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
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef KEEPASSXC_DATABASESETTINGSPAGEFDOSECRETS_H
#define KEEPASSXC_DATABASESETTINGSPAGEFDOSECRETS_H

#include "gui/dbsettings/DatabaseSettingsDialog.h"

class DatabaseSettingsPageFdoSecrets : public IDatabaseSettingsPage
{
Q_DISABLE_COPY(DatabaseSettingsPageFdoSecrets)
public:
DatabaseSettingsPageFdoSecrets() = default;

QString name() override;
QIcon icon() override;
QWidget* createWidget() override;
void loadSettings(QWidget* widget, QSharedPointer<Database> db) override;
void saveSettings(QWidget* widget) override;
};

#endif // KEEPASSXC_DATABASESETTINGSPAGEFDOSECRETS_H
Loading