1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-19 18:26:34 +01:00

Revert "Remove GnomeKeyringPasswords plugin"

This reverts commit b9fb89a31c.

This plugin was removed due to the underlying library being deprecated
and removed from some distributions. However:

* the gnome-keyring library is still available in Fedora Rawhide,
* the plugin is optional, and the availability of the library is
  automatically detected, so having the plugin available will not hurt
  users who do not have access to the underlying library, as Falkon will
  just be built without the optional plugin then,
* distribution packagers can put the plugin into an optional subpackage
  (which I have always done in Fedora to begin with),
* a replacement plugin using libsecret (the upstream replacement for
  libgnome-keyring) is still not available, and
* perhaps most importantly: not having the plugin available leaves users
  with no easy way to access their existing saved passwords (due to no
  libsecret plugin being available), which is IMHO not acceptable.
This commit is contained in:
Kevin Kofler 2022-01-11 09:59:11 +01:00 committed by Adriaan de Groot
parent 1781ea1fae
commit b6131a2de9
9 changed files with 531 additions and 0 deletions

View File

@ -98,6 +98,15 @@ if (EXISTS "${CMAKE_SOURCE_DIR}/po")
find_package(KF5I18n REQUIRED)
endif()
# Optional: GnomeKeyring
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
option(BUILD_KEYRING "Gnome keyring password plugin" ON)
if (BUILD_KEYRING)
pkg_check_modules(GNOME_KEYRING IMPORTED_TARGET gnome-keyring-1 )
endif()
endif()
# Optional: KWallet, KIO, KCrash, KCoreAddons
set(KF5_MIN_VERSION "5.54.0")
find_package(KF5Wallet ${KF5_MIN_VERSION} CONFIG)

View File

@ -9,6 +9,10 @@ add_subdirectory(StatusBarIcons)
add_subdirectory(TabManager)
add_subdirectory(VerticalTabs)
if (GNOME_KEYRING_FOUND)
add_subdirectory(GnomeKeyringPasswords)
endif()
if (ENABLE_KDE_FRAMEWORKS_INTEGRATION_PLUGIN)
add_subdirectory(KDEFrameworksIntegration)
endif()

View File

@ -0,0 +1,13 @@
add_definitions(${GNOME_KEYRING_CFLAGS} ${GNOME_KEYRING_CFLAGS_OTHER})
set( GnomeKeyringPasswords_SRCS
gnomekeyringplugin.cpp
gnomekeyringpasswordbackend.cpp
)
ecm_create_qm_loader( GnomeKeyringPasswords_SRCS falkon_gnomekeyringpasswords_qt )
add_library(GnomeKeyringPasswords MODULE ${GnomeKeyringPasswords_SRCS} ${RSCS})
install(TARGETS GnomeKeyringPasswords DESTINATION ${FALKON_INSTALL_PLUGINDIR})
target_link_libraries(GnomeKeyringPasswords PkgConfig::GNOME_KEYRING FalkonPrivate)

View File

@ -0,0 +1,2 @@
#! /bin/sh
$EXTRACT_TR_STRINGS `find . -name '*.cpp' -o -name '*.h' -o -name '*.ui'` -o $podir/falkon_gnomekeyringpasswords_qt.pot

View File

@ -0,0 +1,304 @@
/* ============================================================
* GnomeKeyringPasswords - gnome-keyring support plugin for Falkon
* Copyright (C) 2013-2014 David Rosca <nowrep@gmail.com>
*
* 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 3 of the License, or
* (at your option) any later version.
*
* 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 "gnomekeyringpasswordbackend.h"
#include "gnomekeyringplugin.h"
#include <QDateTime>
extern "C" {
#include "gnome-keyring.h"
}
static PasswordEntry createEntry(GnomeKeyringFound* item)
{
PasswordEntry entry;
entry.id = item->item_id;
entry.password = QString::fromUtf8(item->secret);
for (unsigned i = 0; i < item->attributes->len; ++i) {
GnomeKeyringAttribute attr = g_array_index(item->attributes, GnomeKeyringAttribute, i);
if (strcmp(attr.name, "host") == 0) {
entry.host = QString::fromUtf8(attr.value.string);
}
else if (strcmp(attr.name, "username") == 0) {
entry.username = QString::fromUtf8(attr.value.string);
}
else if (strcmp(attr.name, "data") == 0) {
entry.data = attr.value.string;
}
else if (strcmp(attr.name, "updated") == 0) {
entry.updated = attr.value.integer;
}
}
entry.data.replace(QByteArray("___PASSWORD-VALUE___"), PasswordManager::urlEncodePassword(entry.password));
return entry;
}
static GnomeKeyringAttributeList* createAttributes(const PasswordEntry &entry)
{
GnomeKeyringAttributeList* attributes = gnome_keyring_attribute_list_new();
gnome_keyring_attribute_list_append_string(attributes, "application", "Falkon");
QByteArray value = entry.username.toUtf8();
gnome_keyring_attribute_list_append_string(attributes, "username", value.constData());
value = entry.data;
value.replace(PasswordManager::urlEncodePassword(entry.password), "___PASSWORD-VALUE___");
gnome_keyring_attribute_list_append_string(attributes, "data", value.constData());
value = entry.host.toUtf8();
gnome_keyring_attribute_list_append_string(attributes, "host", value.constData());
gnome_keyring_attribute_list_append_uint32(attributes, "updated", entry.updated);
return attributes;
}
static void storeEntry(PasswordEntry &entry)
{
guint32 itemId;
GnomeKeyringAttributeList* attributes = createAttributes(entry);
QByteArray pass = entry.password.toUtf8();
QByteArray host = entry.host.toUtf8();
GnomeKeyringResult result = gnome_keyring_item_create_sync(GNOME_KEYRING_DEFAULT,
GNOME_KEYRING_ITEM_GENERIC_SECRET,
host.constData(),
attributes,
pass.constData(),
TRUE, // Update if exists
&itemId);
gnome_keyring_attribute_list_free(attributes);
if (result != GNOME_KEYRING_RESULT_OK) {
qWarning() << "GnomeKeyringPasswordBackend::addEntry Cannot add entry to keyring!";
}
entry.id = itemId;
}
GnomeKeyringPasswordBackend::GnomeKeyringPasswordBackend()
: PasswordBackend()
, m_loaded(false)
{
}
QString GnomeKeyringPasswordBackend::name() const
{
return GnomeKeyringPlugin::tr("Gnome Keyring");
}
QVector<PasswordEntry> GnomeKeyringPasswordBackend::getEntries(const QUrl &url)
{
initialize();
const QString host = PasswordManager::createHost(url);
QVector<PasswordEntry> list;
foreach (const PasswordEntry &entry, m_allEntries) {
if (entry.host == host) {
list.append(entry);
}
}
// Sort to prefer last updated entries
std::sort(list.begin(), list.end());
return list;
}
QVector<PasswordEntry> GnomeKeyringPasswordBackend::getAllEntries()
{
initialize();
return m_allEntries;
}
void GnomeKeyringPasswordBackend::addEntry(const PasswordEntry &entry)
{
initialize();
PasswordEntry stored = entry;
stored.updated = QDateTime::currentDateTime().toTime_t();
storeEntry(stored);
m_allEntries.append(stored);
}
bool GnomeKeyringPasswordBackend::updateEntry(const PasswordEntry &entry)
{
initialize();
// Update item attributes
GnomeKeyringAttributeList* attributes = createAttributes(entry);
GnomeKeyringResult result = gnome_keyring_item_set_attributes_sync(GNOME_KEYRING_DEFAULT,
entry.id.toUInt(),
attributes);
gnome_keyring_attribute_list_free(attributes);
if (result != GNOME_KEYRING_RESULT_OK) {
qWarning() << "GnomeKeyringPasswordBackend::updateEntry Cannot updated entry attributes in keyring!";
return false;
}
// Update secret
GnomeKeyringItemInfo* info;
result = gnome_keyring_item_get_info_full_sync(GNOME_KEYRING_DEFAULT, entry.id.toUInt(),
GNOME_KEYRING_ITEM_INFO_SECRET, &info);
if (result != GNOME_KEYRING_RESULT_OK) {
qWarning() << "GnomeKeyringPasswordBackend::updateEntry Cannot get entry info from keyring!";
return false;
}
QByteArray pass = entry.password.toUtf8();
gnome_keyring_item_info_set_secret(info, pass.constData());
result = gnome_keyring_item_set_info_sync(GNOME_KEYRING_DEFAULT, entry.id.toUInt(), info);
gnome_keyring_item_info_free(info);
if (result != GNOME_KEYRING_RESULT_OK) {
qWarning() << "GnomeKeyringPasswordBackend::updateEntry Cannot set entry info in keyring!";
return false;
}
int index = m_allEntries.indexOf(entry);
if (index > -1) {
m_allEntries[index] = entry;
}
return true;
}
void GnomeKeyringPasswordBackend::updateLastUsed(PasswordEntry &entry)
{
initialize();
entry.updated = QDateTime::currentDateTime().toTime_t();
GnomeKeyringAttributeList* attributes = createAttributes(entry);
GnomeKeyringResult result = gnome_keyring_item_set_attributes_sync(GNOME_KEYRING_DEFAULT,
entry.id.toUInt(),
attributes);
gnome_keyring_attribute_list_free(attributes);
if (result != GNOME_KEYRING_RESULT_OK) {
qWarning() << "GnomeKeyringPasswordBackend::updateLastUsed Cannot updated entry in keyring!";
return;
}
int index = m_allEntries.indexOf(entry);
if (index > -1) {
m_allEntries[index] = entry;
}
}
void GnomeKeyringPasswordBackend::removeEntry(const PasswordEntry &entry)
{
initialize();
GnomeKeyringResult result = gnome_keyring_item_delete_sync(GNOME_KEYRING_DEFAULT, entry.id.toUInt());
if (result != GNOME_KEYRING_RESULT_OK) {
qWarning() << "GnomeKeyringPasswordBackend::removeEntry Cannot remove entry from keyring!";
return;
}
int index = m_allEntries.indexOf(entry);
if (index > -1) {
m_allEntries.remove(index);
}
}
void GnomeKeyringPasswordBackend::removeAll()
{
initialize();
foreach (const PasswordEntry &entry, m_allEntries) {
removeEntry(entry);
}
m_allEntries.clear();
}
void GnomeKeyringPasswordBackend::initialize()
{
if (m_loaded) {
return;
}
GList* found;
GnomeKeyringResult result = gnome_keyring_find_itemsv_sync(GNOME_KEYRING_ITEM_GENERIC_SECRET, &found,
"application", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING, "Falkon",
NULL);
if (result != GNOME_KEYRING_RESULT_OK && result != GNOME_KEYRING_RESULT_NO_MATCH) {
qWarning() << "GnomeKeyringPasswordBackend::initialize Cannot read items from keyring!";
return;
}
bool migrate = false;
if (result == GNOME_KEYRING_RESULT_NO_MATCH) {
result = gnome_keyring_find_itemsv_sync(GNOME_KEYRING_ITEM_GENERIC_SECRET, &found,
"application", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING, "QupZilla",
NULL);
if (result != GNOME_KEYRING_RESULT_OK && result != GNOME_KEYRING_RESULT_NO_MATCH) {
qWarning() << "GnomeKeyringPasswordBackend::initialize Cannot read items from keyring!";
return;
}
if (result == GNOME_KEYRING_RESULT_OK) {
migrate = true;
}
}
GList* tmp = found;
while (tmp) {
GnomeKeyringFound* item = (GnomeKeyringFound*) tmp->data;
m_allEntries.append(createEntry(item));
tmp = tmp->next;
}
gnome_keyring_found_list_free(found);
if (migrate) {
for (PasswordEntry &entry : m_allEntries) {
storeEntry(entry);
}
}
m_loaded = true;
}

View File

@ -0,0 +1,50 @@
/* ============================================================
* GnomeKeyringPasswords - gnome-keyring support plugin for Falkon
* Copyright (C) 2013-2014 David Rosca <nowrep@gmail.com>
*
* 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 3 of the License, or
* (at your option) any later version.
*
* 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 GNOMEKEYRINGPASSWORDBACKEND_H
#define GNOMEKEYRINGPASSWORDBACKEND_H
#include <QVector>
#include "passwordbackends/passwordbackend.h"
#include "passwordmanager.h"
class FALKON_EXPORT GnomeKeyringPasswordBackend : public PasswordBackend
{
public:
explicit GnomeKeyringPasswordBackend();
QString name() const;
QVector<PasswordEntry> getEntries(const QUrl &url);
QVector<PasswordEntry> getAllEntries();
void addEntry(const PasswordEntry &entry);
bool updateEntry(const PasswordEntry &entry);
void updateLastUsed(PasswordEntry &entry);
void removeEntry(const PasswordEntry &entry);
void removeAll();
private:
void initialize();
bool m_loaded;
QVector<PasswordEntry> m_allEntries;
};
#endif // GNOMEKEYRINGPASSWORDBACKEND_H

View File

@ -0,0 +1,54 @@
{
"Comment": "Provides support for storing passwords in gnome-keyring",
"Comment[ca@valencia]": "Proporciona suport per emmagatzemar les contrasenyes a l'anell de claus de Gnome",
"Comment[ca]": "Proporciona suport per emmagatzemar les contrasenyes a l'anell de claus de Gnome",
"Comment[cs]": "Poskytuje podporu pro ukládání hesel pomocí gnome-keyring",
"Comment[da]": "Giver understøttelse af lagring af adgangskoder i gnome-nøglring",
"Comment[de]": "Unterstützung für die Speicherung von Passwörtern in gnome-keyring",
"Comment[en_GB]": "Provides support for storing passwords in gnome-keyring",
"Comment[es]": "Implementa el almacenamiento de contraseñas en el anillo de claves de Gnome",
"Comment[fi]": "Tarjoaa tuen salasanojen tallentamiseksi Gnomen avainrenkaaseen",
"Comment[fr]": "Prise en charge de l'enregistrement de mots de passe au sein de gnome-keyring",
"Comment[gl]": "Permite almacenar contrasinais en gnome-keyring",
"Comment[id]": "Menyediakan dukungan untuk menyimpan sandi dalam gnome-keyring",
"Comment[it]": "Fornisce un supporto all'immagazzinamento delle password nel portachiavi di Gnome",
"Comment[nl]": "Biedt ondersteuning voor opslaan van GNOME-sleutelbos wachtwoorden",
"Comment[nn]": "Gjev støtte for lagring av passord i Gnome-nøkkelringen",
"Comment[pl]": "Zapewnia obsługę przechowywania haseł w pęku kluczy gnome",
"Comment[pt]": "Oferece o suporte para gravar as senhas no 'gnome-keyring'",
"Comment[pt_BR]": "Fornece suporte para armazenar senhas no gnome-keyring",
"Comment[sk]": "Poskytuje podporu pre ukladanie hesiel do Gnome kľúčenky",
"Comment[sv]": "Tillhandahåller stöd för att lagra lösenord i Gnome-nyckelring",
"Comment[uk]": "Забезпечує підтримку зберігання паролів у gnome-keyring",
"Comment[x-test]": "xxProvides support for storing passwords in gnome-keyringxx",
"Comment[zh_CN]": "提供在 gnome-keyring 中保存密码的支持",
"Icon": "base64:iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAAOdEVYdFRpdGxlAEZpcmV3YWxsEoGurgAAABd0RVh0QXV0aG9yAExhcG8gQ2FsYW1hbmRyZWnfkRoqAAAHa0lEQVRYw7VXeWybZx0OpR1buy2rOKpS2NFNjCOUP4Y2EFCh/bFyrxts0iqGGOdAQoOCUNkGirZ6SRM3TdK16VYm2NS0ieMkTepctmPHTnx/vu3YTnzfdnzFsf3ZjuOH9/NcqZp6pKaN9Cifvu9939/z/o7n93PTgQMHmq4Hq1V8t0aj6qAolUFDqdYJoiqVYkImk+2/0d7N4Lof1Wr1V4hB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l2E9xP8BDBgwSfI9hFsLO+btumCBw/0ZFzupagppS1vs9MvczzyVM96wcPHnz8IwS2129+mcDn68YfINhD8JlNE7iMY51v5bp7jleI4Gz09HZVyM3pY+w23Zus1nZyyN11d2+9gjgTgjvr3y6HoPmKENxxvRD8DzzDc11yXKSCAAAAAElFTkSuQmCC",
"Name": "Gnome Keyring Passwords",
"Name[ca@valencia]": "Contrasenyes a l'anell de claus de Gnome",
"Name[ca]": "Contrasenyes a l'anell de claus de Gnome",
"Name[cs]": "Hesla z klíčenky Gnome",
"Name[da]": "Adgangskoder til Gnome-nøglering",
"Name[de]": "Passwörter für Gnome Keyring",
"Name[en_GB]": "Gnome Keyring Passwords",
"Name[es]": "Anillo de contraseñas de Gnome",
"Name[fi]": "Gnomen avainrenkaan salasankaat",
"Name[fr]": "Trousseau de clés de GNOME",
"Name[gl]": "Contrasinais do chaveiro de Gnome",
"Name[id]": "Gnome Keyring Passwords",
"Name[it]": "Portachiavi per le chiavi di Gnome",
"Name[nl]": "GNOME-sleutelbos wachtwoorden",
"Name[nn]": "Passord for Gnome-nøkkelring",
"Name[pl]": "Hasła pęku kluczy Gnome",
"Name[pt]": "Senhas no Porta-Chaves do Gnome",
"Name[pt_BR]": "Senhas do chaveiro do GNOME",
"Name[sk]": "Heslá Gnome kľúčenky",
"Name[sv]": "Gnome-nyckelring lösenord",
"Name[uk]": "Паролі сховища ключів Gnome",
"Name[x-test]": "xxGnome Keyring Passwordsxx",
"Name[zh_CN]": "Gnome 钥匙链密码",
"Name[zh_TW]": "GNOME 鑰匙圈密碼",
"X-Falkon-Author": "David Rosca",
"X-Falkon-Email": "nowrep@gmail.com",
"X-Falkon-Settings": "false",
"X-Falkon-Version": "0.1.0"
}

View File

@ -0,0 +1,52 @@
/* ============================================================
* GnomeKeyringPasswords - gnome-keyring support plugin for Falkon
* Copyright (C) 2013-2014 David Rosca <nowrep@gmail.com>
*
* 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 3 of the License, or
* (at your option) any later version.
*
* 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 "gnomekeyringplugin.h"
#include "gnomekeyringpasswordbackend.h"
#include "pluginproxy.h"
#include "browserwindow.h"
#include "../config.h"
#include "mainapplication.h"
#include "autofill.h"
#include "passwordmanager.h"
GnomeKeyringPlugin::GnomeKeyringPlugin()
: QObject()
, m_backend(0)
{
}
void GnomeKeyringPlugin::init(InitState state, const QString &settingsPath)
{
Q_UNUSED(state);
Q_UNUSED(settingsPath);
m_backend = new GnomeKeyringPasswordBackend;
mApp->autoFill()->passwordManager()->registerBackend(QSL("GnomeKeyring"), m_backend);
}
void GnomeKeyringPlugin::unload()
{
mApp->autoFill()->passwordManager()->unregisterBackend(m_backend);
delete m_backend;
}
bool GnomeKeyringPlugin::testPlugin()
{
// Require the version that the plugin was built with
return (Qz::VERSION == QLatin1String(FALKON_VERSION));
}

View File

@ -0,0 +1,43 @@
/* ============================================================
* GnomeKeyringPasswords - gnome-keyring support plugin for Falkon
* Copyright (C) 2013-2014 David Rosca <nowrep@gmail.com>
*
* 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 3 of the License, or
* (at your option) any later version.
*
* 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 GNOMEKEYRINGPLUGIN_H
#define GNOMEKEYRINGPLUGIN_H
#include "plugininterface.h"
class GnomeKeyringPasswordBackend;
class GnomeKeyringPlugin : public QObject, public PluginInterface
{
Q_OBJECT
Q_INTERFACES(PluginInterface)
Q_PLUGIN_METADATA(IID "Falkon.Browser.plugin.GnomeKeyringPasswords" FILE "gnomekeyringpasswords.json")
public:
explicit GnomeKeyringPlugin();
void init(InitState state, const QString &settingsPath);
void unload();
bool testPlugin();
private:
GnomeKeyringPasswordBackend* m_backend;
};
#endif // GNOMEKEYRINGPLUGIN_H