mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Add support for skipping Auto-Submit with Browser Integration
This commit is contained in:
parent
e5295b4eb0
commit
a93b22f89a
@ -50,6 +50,9 @@ static int KEEPASSXCBROWSER_DEFAULT_ICON = 1;
|
||||
const char BrowserService::LEGACY_ASSOCIATE_KEY_PREFIX[] = "Public Key: ";
|
||||
static const char KEEPASSHTTP_NAME[] = "KeePassHttp Settings";
|
||||
static const char KEEPASSHTTP_GROUP_NAME[] = "KeePassHttp Passwords";
|
||||
// Extra entry related options saved in custom data
|
||||
const char BrowserService::OPTION_SKIP_AUTO_SUBMIT[] = "BrowserSkipAutoSubmit";
|
||||
const char BrowserService::OPTION_HIDE_ENTRY[] = "BrowserHideEntry";
|
||||
|
||||
BrowserService::BrowserService(DatabaseTabWidget* parent)
|
||||
: m_dbTabWidget(parent)
|
||||
@ -375,6 +378,11 @@ QJsonArray BrowserService::findMatchingEntries(const QString& id,
|
||||
QList<Entry*> pwEntriesToConfirm;
|
||||
QList<Entry*> pwEntries;
|
||||
for (Entry* entry : searchEntries(url, keyList)) {
|
||||
if (entry->customData()->contains(BrowserService::OPTION_HIDE_ENTRY) &&
|
||||
entry->customData()->value(BrowserService::OPTION_HIDE_ENTRY) == "true") {
|
||||
continue;
|
||||
}
|
||||
|
||||
// HTTP Basic Auth always needs a confirmation
|
||||
if (!ignoreHttpAuth && httpAuth) {
|
||||
pwEntriesToConfirm.append(entry);
|
||||
@ -839,6 +847,10 @@ QJsonObject BrowserService::prepareEntry(const Entry* entry)
|
||||
res["expired"] = "true";
|
||||
}
|
||||
|
||||
if (entry->customData()->contains(BrowserService::OPTION_SKIP_AUTO_SUBMIT)) {
|
||||
res["skipAutoSubmit"] = entry->customData()->value(BrowserService::OPTION_SKIP_AUTO_SUBMIT);
|
||||
}
|
||||
|
||||
if (browserSettings()->supportKphFields()) {
|
||||
const EntryAttributes* attr = entry->attributes();
|
||||
QJsonArray stringFields;
|
||||
|
@ -72,6 +72,8 @@ public:
|
||||
static const char KEEPASSXCBROWSER_OLD_NAME[];
|
||||
static const char ASSOCIATE_KEY_PREFIX[];
|
||||
static const char LEGACY_ASSOCIATE_KEY_PREFIX[];
|
||||
static const char OPTION_SKIP_AUTO_SUBMIT[];
|
||||
static const char OPTION_HIDE_ENTRY[];
|
||||
|
||||
public slots:
|
||||
QJsonArray findMatchingEntries(const QString& id,
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "EditEntryWidget.h"
|
||||
#include "ui_EditEntryWidgetAdvanced.h"
|
||||
#include "ui_EditEntryWidgetAutoType.h"
|
||||
#include "ui_EditEntryWidgetBrowser.h"
|
||||
#include "ui_EditEntryWidgetHistory.h"
|
||||
#include "ui_EditEntryWidgetMain.h"
|
||||
#include "ui_EditEntryWidgetSSHAgent.h"
|
||||
@ -49,6 +50,9 @@
|
||||
#include "sshagent/KeeAgentSettings.h"
|
||||
#include "sshagent/SSHAgent.h"
|
||||
#endif
|
||||
#ifdef WITH_XC_BROWSER
|
||||
#include "browser/BrowserService.h"
|
||||
#endif
|
||||
#include "gui/Clipboard.h"
|
||||
#include "gui/EditWidgetIcons.h"
|
||||
#include "gui/EditWidgetProperties.h"
|
||||
@ -68,6 +72,7 @@ EditEntryWidget::EditEntryWidget(QWidget* parent)
|
||||
, m_autoTypeUi(new Ui::EditEntryWidgetAutoType())
|
||||
, m_sshAgentUi(new Ui::EditEntryWidgetSSHAgent())
|
||||
, m_historyUi(new Ui::EditEntryWidgetHistory())
|
||||
, m_browserUi(new Ui::EditEntryWidgetBrowser())
|
||||
, m_customData(new CustomData())
|
||||
, m_mainWidget(new QWidget())
|
||||
, m_advancedWidget(new QWidget())
|
||||
@ -75,6 +80,9 @@ EditEntryWidget::EditEntryWidget(QWidget* parent)
|
||||
, m_autoTypeWidget(new QWidget())
|
||||
#ifdef WITH_XC_SSHAGENT
|
||||
, m_sshAgentWidget(new QWidget())
|
||||
#endif
|
||||
#ifdef WITH_XC_BROWSER
|
||||
, m_browserWidget(new QWidget())
|
||||
#endif
|
||||
, m_editWidgetProperties(new EditWidgetProperties())
|
||||
, m_historyWidget(new QWidget())
|
||||
@ -103,6 +111,10 @@ EditEntryWidget::EditEntryWidget(QWidget* parent)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_XC_BROWSER
|
||||
setupBrowser();
|
||||
#endif
|
||||
|
||||
setupProperties();
|
||||
setupHistory();
|
||||
setupEntryUpdate();
|
||||
@ -246,6 +258,27 @@ void EditEntryWidget::setupAutoType()
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
#ifdef WITH_XC_BROWSER
|
||||
void EditEntryWidget::setupBrowser()
|
||||
{
|
||||
m_browserUi->setupUi(m_browserWidget);
|
||||
|
||||
if (config()->get("Browser/Enabled", false).toBool()) {
|
||||
addPage(tr("Browser Integration"), FilePath::instance()->icon("apps", "internet-web-browser"), m_browserWidget);
|
||||
connect(m_browserUi->skipAutoSubmitCheckbox, SIGNAL(toggled(bool)), SLOT(updateBrowser()));
|
||||
connect(m_browserUi->hideEntryCheckbox, SIGNAL(toggled(bool)), SLOT(updateBrowser()));
|
||||
}
|
||||
}
|
||||
|
||||
void EditEntryWidget::updateBrowser()
|
||||
{
|
||||
auto skip = m_browserUi->skipAutoSubmitCheckbox->isChecked();
|
||||
auto hide = m_browserUi->hideEntryCheckbox->isChecked();
|
||||
m_customData->set(BrowserService::OPTION_SKIP_AUTO_SUBMIT, (skip ? QString("true") : QString("false")));
|
||||
m_customData->set(BrowserService::OPTION_HIDE_ENTRY, (hide ? QString("true") : QString("false")));
|
||||
}
|
||||
#endif
|
||||
|
||||
void EditEntryWidget::setupProperties()
|
||||
{
|
||||
addPage(tr("Properties"), FilePath::instance()->icon("actions", "document-properties"), m_editWidgetProperties);
|
||||
@ -330,6 +363,13 @@ void EditEntryWidget::setupEntryUpdate()
|
||||
connect(m_sshAgentUi->lifetimeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setModified()));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_XC_BROWSER
|
||||
if (config()->get("Browser/Enabled", false).toBool()) {
|
||||
connect(m_browserUi->skipAutoSubmitCheckbox, SIGNAL(toggled(bool)), this, SLOT(setModified()));
|
||||
connect(m_browserUi->hideEntryCheckbox, SIGNAL(toggled(bool)), this, SLOT(setModified()));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void EditEntryWidget::emitHistoryEntryActivated(const QModelIndex& index)
|
||||
@ -820,6 +860,20 @@ void EditEntryWidget::setForms(Entry* entry, bool restore)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_XC_BROWSER
|
||||
if (m_customData->contains(BrowserService::OPTION_SKIP_AUTO_SUBMIT)) {
|
||||
m_browserUi->skipAutoSubmitCheckbox->setChecked(m_customData->value(BrowserService::OPTION_SKIP_AUTO_SUBMIT) == "true");
|
||||
} else {
|
||||
m_browserUi->skipAutoSubmitCheckbox->setChecked(false);
|
||||
}
|
||||
|
||||
if (m_customData->contains(BrowserService::OPTION_HIDE_ENTRY)) {
|
||||
m_browserUi->hideEntryCheckbox->setChecked(m_customData->value(BrowserService::OPTION_HIDE_ENTRY) == "true");
|
||||
} else {
|
||||
m_browserUi->hideEntryCheckbox->setChecked(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
m_editWidgetProperties->setFields(entry->timeInfo(), entry->uuid());
|
||||
|
||||
if (!m_history && !restore) {
|
||||
|
@ -51,6 +51,7 @@ namespace Ui
|
||||
{
|
||||
class EditEntryWidgetAdvanced;
|
||||
class EditEntryWidgetAutoType;
|
||||
class EditEntryWidgetBrowser;
|
||||
class EditEntryWidgetSSHAgent;
|
||||
class EditEntryWidgetMain;
|
||||
class EditEntryWidgetHistory;
|
||||
@ -118,12 +119,18 @@ private slots:
|
||||
void decryptPrivateKey();
|
||||
void copyPublicKey();
|
||||
#endif
|
||||
#ifdef WITH_XC_BROWSER
|
||||
void updateBrowser();
|
||||
#endif
|
||||
|
||||
private:
|
||||
void setupMain();
|
||||
void setupAdvanced();
|
||||
void setupIcon();
|
||||
void setupAutoType();
|
||||
#ifdef WITH_XC_BROWSER
|
||||
void setupBrowser();
|
||||
#endif
|
||||
#ifdef WITH_XC_SSHAGENT
|
||||
void setupSSHAgent();
|
||||
#endif
|
||||
@ -157,6 +164,7 @@ private:
|
||||
const QScopedPointer<Ui::EditEntryWidgetAutoType> m_autoTypeUi;
|
||||
const QScopedPointer<Ui::EditEntryWidgetSSHAgent> m_sshAgentUi;
|
||||
const QScopedPointer<Ui::EditEntryWidgetHistory> m_historyUi;
|
||||
const QScopedPointer<Ui::EditEntryWidgetBrowser> m_browserUi;
|
||||
const QScopedPointer<CustomData> m_customData;
|
||||
|
||||
QWidget* const m_mainWidget;
|
||||
@ -165,6 +173,9 @@ private:
|
||||
QWidget* const m_autoTypeWidget;
|
||||
#ifdef WITH_XC_SSHAGENT
|
||||
QWidget* const m_sshAgentWidget;
|
||||
#endif
|
||||
#ifdef WITH_XC_BROWSER
|
||||
QWidget* const m_browserWidget;
|
||||
#endif
|
||||
EditWidgetProperties* const m_editWidgetProperties;
|
||||
QWidget* const m_historyWidget;
|
||||
|
80
src/gui/entry/EditEntryWidgetBrowser.ui
Normal file
80
src/gui/entry/EditEntryWidgetBrowser.ui
Normal file
@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>EditEntryWidgetBrowser</class>
|
||||
<widget class="QWidget" name="EditEntryWidgetBrowser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>348</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_1">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>These settings affect to the entry's behaviour with the browser extension.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>General</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="skipAutoSubmitCheckbox">
|
||||
<property name="text">
|
||||
<string>Skip Auto-Submit for this entry</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="hideEntryCheckbox">
|
||||
<property name="text">
|
||||
<string>Hide this entry from the browser extension</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>skipAutoSubmitCheckbox</tabstop>
|
||||
<tabstop>hideEntryCheckbox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue
Block a user