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

[WIP] Create new KeepassHTTP KeyAcceptDialog #850

Closed

Conversation

duk3luk3
Copy link

@duk3luk3 duk3luk3 commented Aug 6, 2017

WIP - Creates a new dialog widget for accepting keys - needed for #838

For #838, #530

This is a proof-of-concept for myself that I can make changes to KeePassXC and a first step towards making some big changes to the KeepassHTTP authorization key management in order to address #838 and #530 and my own usability / workflow itches as someone who generally works with multiple databases open at the same time.

Please give this change a quick look and tell me if this is a good direction to go in, as well as anything problematic in the code I've changed (as far as it isn't a temporary mock-up / stub)

Description

Planned changes:

Motivation and context

See #530, #838

How has this been tested?

  • Not yet, WIP changes

Screenshots (if appropriate):

keepassnewkey

Types of changes

  • ✅ Bug fix (non-breaking change which fixes an issue)
  • ✅ New feature (non-breaking change which adds functionality)
  • ✅ Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • ✅ I have read the CONTRIBUTING document. [REQUIRED]
  • ? My code follows the code style of this project. [REQUIRED]
  • X All new and existing tests passed. [REQUIRED]
  • X I have compiled and verified my code with -DWITH_ASAN=ON. [REQUIRED]
  • ? My change requires a change to the documentation and I have updated it accordingly.
  • X I have added tests to cover my changes.

@droidmonkey
Copy link
Member

droidmonkey commented Aug 6, 2017

This needs to jive with #608 as well. We are likely going to pull support for the HTTP protocol in a couple releases due to its insecurity.

I really like the dialog and modification though! It is sorely needed.

@duk3luk3
Copy link
Author

duk3luk3 commented Aug 7, 2017

What extensions are going to replace chromeIPass and passIFox?

@droidmonkey
Copy link
Member

The author of the new method actually created a new plugin as well.

@duk3luk3
Copy link
Author

duk3luk3 commented Aug 7, 2017

I see - I checked this out, I'll keep it in mind. thanks.

As far as a quick check tells me, the "semantic model" of remote connections will remain the same so I should be fine with just continuing work on this and adapting it for any changes based on keepassxc-browser should be easy once that is merged.

@duk3luk3
Copy link
Author

duk3luk3 commented Aug 8, 2017

I have a question: It seems that the DatabaseTabWidget manages all databases and gives the rest of the codebase access only to the currently open database (via DatabaseTabWidget::currentDatabaseWidget). Is this just a historical artifact due to multi-database support not being part of the original KeePassX, or is that an intentional part of the design of KeePassX(C)?

EDIT: In Service::searchEntries access to all databases is gained by grabbing the databases out of the tab widgets; isn't that pretty ugly?

@duk3luk3
Copy link
Author

duk3luk3 commented Aug 9, 2017

I've now added a proper feature: All databases are listed in the dialog and keys are inserted into all selected databases.

It would be very nice to get a proper review of my changes at this point (of course keeping in mind that it's still WIP).

@TheZ3ro
Copy link
Contributor

TheZ3ro commented Sep 19, 2017

Should we postpone this to 2.3.0 ?

@droidmonkey
Copy link
Member

I think so, it should be synced with the new browser integration. I'll look at this tonight.

@droidmonkey
Copy link
Member

droidmonkey commented Sep 20, 2017

I've tested this and it works well, however if you do not enter a name in the top box it fails to find the database. Recommend adding an error if no name is supplied or use the name of the database by default. There is also commented out code and XXX comments that need to be removed or addressed.

Copy link
Member

@droidmonkey droidmonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the changes in my previous comment.

@droidmonkey droidmonkey modified the milestones: v2.2.1, v2.3.0 Sep 20, 2017
@duk3luk3
Copy link
Author

Thank you for testing this, will check your feedback!

I will add some inline comments to the things I marked with XXX, because this is where I'm unsure how exactly C++ and Qt work.

}
}

return resultList;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it okay to stack-allocate (? - I am not sure if that is what happens, and whether Qt transforms that into something else) resultList here and then return it to the caller, where the caller will simply let it go out of scope?

I.e. will the object be destroyed once it runs out of scope in the caller, and is this the proper way to do it or should this be done differently?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answered on second question


//XXX
//bool Service::attributeExists(QList<Entry*> entries, const QString &attribute)
bool Service::attributeExists(QList<Entry*> entries, const QString attribute)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is const QString attribute or const QString &attribute correct here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is correct. The data you allocate as part of the list gets shared with the calling scope's new QList object.

@duk3luk3
Copy link
Author

I rebased for now. To resolve to "TODOs", I still need an answer to my question upthread.

@droidmonkey
Copy link
Member

I will be updating this behavior in my database pointer refactoring. Proceed with the ugly code for now.

@duk3luk3
Copy link
Author

if you do not enter a name in the top box it fails to find the database. Recommend adding an error if no name is supplied or use the name of the database by default

I've fixed this by not allowing to submit the dialog if the key name is empty. Are you happy with that solution?

@duk3luk3
Copy link
Author

I added some more cleanup and additional verification to the key accept dialog.

The only thing left to do for now is adding translation support.

@duk3luk3 duk3luk3 changed the title [WIP, RFC] Create new KeepassHTTP KeyAcceptDialog [WIP] Create new KeepassHTTP KeyAcceptDialog Sep 25, 2017
@duk3luk3
Copy link
Author

duk3luk3 commented Sep 25, 2017

Translation wrappers added.

@droidmonkey please review, then I will rebase and squash.

@TheZ3ro TheZ3ro requested a review from a team November 6, 2017 19:24
@TheZ3ro
Copy link
Contributor

TheZ3ro commented Nov 30, 2017

@keepassxreboot/core-developers can someone review this?

Copy link
Contributor

@weslly weslly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coding style.

#include <QDialogButtonBox>
#include <QPushButton>

KeyAcceptDialog::KeyAcceptDialog(QWidget *parent) :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QWidget* parent

Pointers on left side.

Q_OBJECT

public:
explicit KeyAcceptDialog(QWidget *parent = nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QWidget* parent


private slots:
void keyEditChanged(const QString &text);
void modelItemChanged(QStandardItem *item);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QStandardItem* item

if (DatabaseWidget* dbWidget = m_dbTabWidget->currentDatabaseWidget())
QList<Entry*> entries;

for (int i = 0; i < m_dbTabWidget->count(); i++)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This for block should be wrapped with braces.

Copy link
Author

@duk3luk3 duk3luk3 Dec 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is inconsistent with the style of the rest of the file. Should I really partially fix the style of the file(s)? A separate code style commit would probably be better.

The same applies for NULL vs. nullptr.

Copy link
Contributor

@weslly weslly Dec 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is inconsistent with the style of the rest of the file

Older code, mostly before the fork, don't necessarily follow the current coding style, but all new PR's should stick to the project coding style guide.

Should I really partially fix the style of the file(s)?

It's not required to fix the style where you didn't modify/add code, but we would appreciate if you do. :)

A separate code style commit would probably be better.

Concur.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run this command to fix all the file codestyle to project standard
clang-format -i -style=file src/http/Service.cpp in the project root.

Yes, fix the codestyle in a new commit please

QList<Entry*> entries;

for (int i = 0; i < m_dbTabWidget->count(); i++)
if (DatabaseWidget* dbWidget = qobject_cast<DatabaseWidget*>(m_dbTabWidget->widget(i)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@@ -44,7 +46,7 @@ class Server : public QObject
public:
explicit Server(QObject *parent = 0);

virtual bool isDatabaseOpened() const = 0;
virtual bool isDatabaseOpened(DatabaseWidget* dbWidget = NULL) const = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use nullptr instead of NULL.

if (create)
entry->setGroup(db->rootGroup());
else
entry = NULL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullptr instead of NULL.

@@ -522,7 +589,7 @@ QString Service::generatePassword()

void Service::removeSharedEncryptionKeys()
{
if (!isDatabaseOpened()) {
if (!isDatabaseOpened(NULL)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullptr

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@duk3luk3 This one wasn't addressed

@@ -561,7 +628,7 @@ void Service::removeSharedEncryptionKeys()

void Service::removeStoredPermissions()
{
if (!isDatabaseOpened()) {
if (!isDatabaseOpened(NULL)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullptr

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@duk3luk3 This one wasn't addressed

ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
ui->buttonBox->button(QDialogButtonBox::Ok)->setToolTip(tr("Make sure the key name is not empty!"));
}
else if (!hasChecked) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove newline between } and else if

@droidmonkey
Copy link
Member

@duk3luk3 will you be submitting revisions for Weslley's comments?

@duk3luk3
Copy link
Author

duk3luk3 commented Dec 5, 2017

Hi,

sure! Will do as soon as I am able.

@duk3luk3
Copy link
Author

@droidmonkey @weslly Please let me know if there are any other issues, and then I'll rebase the PR.

@@ -522,7 +589,7 @@ QString Service::generatePassword()

void Service::removeSharedEncryptionKeys()
{
if (!isDatabaseOpened()) {
if (!isDatabaseOpened(NULL)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@duk3luk3 This one wasn't addressed

@@ -561,7 +628,7 @@ void Service::removeSharedEncryptionKeys()

void Service::removeStoredPermissions()
{
if (!isDatabaseOpened()) {
if (!isDatabaseOpened(NULL)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@duk3luk3 This one wasn't addressed

@duk3luk3
Copy link
Author

@weslly Ah, I assumed clang-format would catch those. I amended the formatting commit.

@TheZ3ro
Copy link
Contributor

TheZ3ro commented Dec 12, 2017

@duk3luk3 can you rebase on top of develop? There are some conflict with src/http/Service.cpp

* !WIP!
* Creates a new dialog widget for accepting keys - needed for keepassxreboot#838

For keepassxreboot#838, keepassxreboot#530
Basic implementation of allowing user to select which DBs to insert
KeepassHTTP Authentication Keys into.

For keepassxreboot#535
Disables the "OK" button when the key name edit is empty.
This avoids saving a KeepassHTTP key with empty key name, which causes
problems later.
TODO: Squash
To improve multi-db handling, we can move the checking for open
(unlocked) databases to the key accept dialog.

This means that even if the selected db is not open, the key can be
stored in another db as selected by the user.

This commit also adds a check for selected db's to the key accept dialog
so the dialog cannot be submitted if no db's to store the key are
selected.
Wrap strings presented to user in tr() for localization
Run clang-format and replace NULLs in all files touched by the PR
@duk3luk3
Copy link
Author

Rebased, test failures appear to come from develop: https://travis-ci.org/keepassxreboot/keepassxc/builds/315131994

I will do some more cleanup as soon as I am able.

@TheZ3ro
Copy link
Contributor

TheZ3ro commented Jan 4, 2018

@duk3luk3 can you please rebase again? we changed our CI

@droidmonkey can you please review your requested changes?
Thanks

@duk3luk3
Copy link
Author

duk3luk3 commented Jan 4, 2018

I will have to do some more work now that #608 has been merged. Will do it asap.

@TheZ3ro
Copy link
Contributor

TheZ3ro commented Jan 4, 2018

No problem @duk3luk3. Ping me when you are done :)

@droidmonkey
Copy link
Member

This PR has been overcome by the KeePassXC-Browser. HTTP is deprecated and will be removed in 2.4.0.

@droidmonkey droidmonkey removed this from the Future milestone Feb 24, 2018
@duk3luk3
Copy link
Author

duk3luk3 commented Mar 5, 2018

The changes in this PR should be 100% applicable to KeePassXC-Browser.

I just need to port them - I will do that as soon as I find time.

@droidmonkey
Copy link
Member

I agree with that, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KeePassHTTP Encryption Key not recognized when multiple databases are open
5 participants