strongbox-password-safe / Strongbox

A KeePass/Password Safe Client for iOS and OS X
https://strongboxsafe.com
GNU Affero General Public License v3.0
1.33k stars 102 forks source link

Support QuickType Auto Fill #20

Closed mmcguill closed 5 years ago

mmcguill commented 5 years ago

https://developer.apple.com/videos/play/wwdc2018/721/

Ben-Voris commented 5 years ago

How is this different from https://github.com/mmcguill/Strongbox/issues/9?

mmcguill commented 5 years ago

Basically improves and streamlines the experience, no UI involvement basically, so option to auto login appears inline in the keyboard as part of 'Quick-Type' area, no touch-id/face-id/password required.

georgesnow commented 5 years ago

How is this different from #9?

Effectively the autofill extension can be provided a list of domains and usernames from the app. So when you land on webpage that matches. it provides a suggested username (credential) for that domain. when the user selects the suggested entry it asks the user to authenticate (touch id passcode) and the autofill extension handles the rest. it requests from the app the password for the requested credential and passes it back to fill in the password field in Safari. you can see the attached picture. how 1Password uses it. iCloud Keychain also provides this support if using autofill. autofillqtsugesst

I would recommend watching the second half the video, which explains it more fully.

georgesnow commented 5 years ago

I am not sure if this is part of this or it falls under the general auto fill extension for iOS. The ability to add new entry if one can’t be found. Example being there is no QuickType entry available or entry without QuickType. So If you end up in the search list view. There could be an add button to create a new entry for the site.

aglasson commented 5 years ago

This is a good idea and definitely a todo for the future if possible. The current auto fill integration is decent I think.

mmcguill commented 5 years ago

Yes, I'll consider this a feature request, and get it on the backlog

mmcguill commented 5 years ago

I am not sure if this is part of this or it falls under the general auto fill extension for iOS. The ability to add new entry if one can’t be found. Example being there is no QuickType entry available or entry without QuickType. So If you end up in the search list view. There could be an add button to create a new entry for the site.

georgesnow commented 5 years ago

Just curious have you given this feature any further thought?

mmcguill commented 5 years ago

Hi @georgesnow, definitely, super high on the list, think it would be a very nice feature indeed. Hopefully get to it in the next few weeks. Cheers, -Mark

mmcguill commented 5 years ago

This is available now with 1.25.0. Let me know if you have any issues.

georgesnow commented 5 years ago

awesome! I will keep an eye out for update. curious how does it operate with multiple KeePass databases? do you have to pick one db or is it all available dbs? I just ask cause I have 2 databases want to make sure I understand how it works before I report an issue thanks

mmcguill commented 5 years ago

Hi,

You can control whether a database takes part in QuickType, and also there is a master on/off switch in Settings to turn them all off.

There is a bit of an issue, which is sort of unavoidable (due to the design of the QuickType API) when working with multiple databases which is when you turn off on of your databases from QuickType, it is not possible to selectively remove the entries from the QuickType database. It is only possible to remove all entries or none.

I've err'd on the side of convenience here, and left those entries in place, but the whole QuickType database can be cleared by using the Master On/Off switch in settings if this becomes an issue. So you could flick the master switch off then on, re-open the database you wanted to participate in QuickType and it will populate the QuickType database with only those entries.

Hope that makes sense, -Mark

georgesnow commented 5 years ago

yes it does. i went down a rabbit hole reading about the Quicktype API. when i was using a different password manager and didn't do that. and i couldn't figure out how it was populating entries. it was annoying to say the least

georgesnow commented 5 years ago

Updated this evening and so it is working great with one database but not the other. And it’s strange cause I have same entry in both one database QuickType works and matches. The other it won’t. I tried creating new records, turning on and off cache, auto fill all the together. The one database always works and the other won’t. Both are stored in iCloud. So far I can only find 2 differences.

The one that works is shared via iCloud with another person and was created with MacPass.

The other says it was created with strongbox and is not shared.

JLWFuQrioea69ugsykvQcg commented 5 years ago

Hmm so how is this supposed to work? I have autofill enabled globally and on my database in Strongbox that was created in Keepass. I have yet to see QuickType provide me with an option to fill sourced from Strongbox. It works fine from iCloud Keychain because I get the suggestion which shows the source.

JLWFuQrioea69ugsykvQcg commented 5 years ago

I keep trying but it doesn’t seem to work. One instance of my database is stored on OneDrive, and a copy of that instance is also copied into Strongbox locally. I’ve enabled both but neither seem to work.

georgesnow commented 5 years ago

Might be red herring but did you happen to notice where it says the database was created by? Ie strongbox, keepass, Macpass basicly the clien

JLWFuQrioea69ugsykvQcg commented 5 years ago

My primary database shows “Keepass” as the generator. I also created a test database in Strongbox a few test entries and it shows “Strongbox”. Unfortunately neither one works for QuickType. What’s weird is that I also have 1Password (although I rarely use it) and that doesn’t seem to generate entries for QuickType either. The be made sure that whatever I’m testing is selected in the Autofill Passwords setting in iOS Settings.

JLWFuQrioea69ugsykvQcg commented 5 years ago

FWIW I tried it on my work phone and my wife’s phone and can’t get it to work. All iOS 12.2 but different hardware models. Can’t get 1Password QuickType to work either on my personal or work phone—all different iCloud accounts.

JLWFuQrioea69ugsykvQcg commented 5 years ago

Sorry for so many posts...

Well I was able to get 1Password to work finally on multiple devices by turning it off and on a few times. When I set 1Password to Autofill it shows “Updating Passwords...” and then it works. I’ve tried doing the same with Strongbox but no visual indicator which is probably specific to 1Password. I’ve even turned off all Autofill related functions within iOS settings and Strongbox and turned them back on and still no luck.

JLWFuQrioea69ugsykvQcg commented 5 years ago

One more interesting observation. If I create a new Keepass 2 Advanced database in Strongbox, I cannot get the QuickType to work. If I create a new Keepass 2 Classic database in Strongbox, IT WORKS PERFECTLY??? So maybe something in the difference between the two database structures is causing the issue.

limuc commented 5 years ago

I also couldn't get it to work. iCloud Keychain works perfectly. The database was created with KeePassXC.

mmcguill commented 5 years ago

Thanks for the feedback. Seems there maybe some teething troubles.

@shad0whawk, @limuc, can I ask you about the format of your URLs, are they fully qualified with a scheme, so "https://google.com" rather than just "google.com"?

The format of the DB shouldn't matter at all, and I've been able to create both a classic and an advanced as well as a Password Safe and get them working.

It might also help to make sure you toggle the Strongbox Master switch on/off before you try it out.

You must also open/unlock the database to populate the QuickType database.

Also I'm sure you're already doing this but make sure iOS settings are ON for Strongbox too:

image

limuc commented 5 years ago

Yes, the URLs are fully qualified. I also tried it with the exact URL (website.com/login) and the generic one (website.com).

I also toggled the button, unlocked the database and the iOS settings are also on.

mmcguill commented 5 years ago

That is strange indeed... I just want to list the conditions here for others just to make it easy to rule out simple things:

1) Using version 1.25.0 2) on iOS12+ with the iOS AutoFill settings for Strongbox ON 3) Both Strongbox QuickType (Master and Database) toggles ON 4) The entries have non empty Usernames 5) Fully qualified URLs 6) You have Unlocked the Database (required to fill the QuickType database

Could I also ask how many databases you have in Strongbox? I wonder if the issue is related to multiple databases.

limuc commented 5 years ago

I did everything you listed there and i have only one database. Maybe it has something to do with the application you created it, in my case KeePassXC.

mmcguill commented 5 years ago

Thanks @limuc, have you tried creating a new DB with Strongbox, does that work? Also, hate to recommend the old classic "restart your device", but could you try that too?

georgesnow commented 5 years ago

So I did some testing I found that one I created with Mac pass works and one that I created in the Strongbox iOS app use the express option works But won’t won’t actually auto fill when I select from the QuickType. I test with cacheing on abd off they both worked. However the older one that I created in Strongbox (I believe with the desktop app) doesn’t seem to work. Encryption and version match those that do work. I am going to try and take my older database and see if exporting and re- importing in Macpass fixes it.

georgesnow commented 5 years ago

Also I have multiple databases which doesn’t seem to affect which ones work

georgesnow commented 5 years ago

Also how does it handle when you have custom fields with multiple urls?

limuc commented 5 years ago

@mmcguill No problem, restarted the device, still didn't work. I also created a new database and it works flawless. So it's some problem with my database, don't know if it's possible to fix. The workaround from @georgesnow isn't possible for me because i don't have a mac.

georgesnow commented 5 years ago

strongboxautofill

this is the behavior i am getting with the newer databases. they provide the option to autofill but fail. however, the one database that worked still works no matter what. it is really strange

mmcguill commented 5 years ago

Hi @georgesnow I think this is because there are stale references to older (now removed) database in QuickType. If you toggle the Master Switch Off and then On, that will clear things, and then open your databases up to populate the QuickType cache... does that fix the issue you're seeing?

Definitely need better messaging here.

mmcguill commented 5 years ago

@mmcguill No problem, restarted the device, still didn't work. I also created a new database and it works flawless. So it's some problem with my database, don't know if it's possible to fix. The workaround from @georgesnow isn't possible for me because i don't have a mac.

@limuc I don't think it will have anything to do with MacPass or what client created the database... I believe that's a red herring. But I really wonder what is stopping your database from working. That is indeed very strange. How far in the process do you get? Do you see the suggestion in say Safari if you go to the appropriate website?

mmcguill commented 5 years ago

Also how does it handle when you have custom fields with multiple urls?

Strongbox should pick up URLs in the Notes and Custom Fields and add them to the Quick Type cache too... So should just work

georgesnow commented 5 years ago

i did some testing and looks like you are right mark. the client doesn't seem to matter.

ok- i was wondering if entries with multiple URLs was causing the issue.

this is just so weird cause i have database that works. I can even add entries from desktop client and iOS app and they show up as an option to use as QuickType like below and they autofill no problem. but any other database i try to use (or create) won't work properly.

Screen Shot 2019-04-04 at 8 38 02 AM

georgesnow commented 5 years ago

Hi @georgesnow I think this is because there are stale references to older (now removed) database in QuickType. If you toggle the Master Switch Off and then On, that will clear things, and then open your databases up to populate the QuickType cache... does that fix the issue you're seeing?

Definitely need better messaging here.

no, it didn't. i created the database within Strongbox(iOS) as test database. QuickType still does what i should above in the gif. so it presents the entry in QuickType but selecting it just shows that white screen briefly. however, i copied that entry into my working database. and it works flawlessly when select it. presents touch id and fills the form.

georgesnow commented 5 years ago

i also tried using Strongbox (macOS) created a new database and added a few entries. Then i went to my iOS device and QuickType again showed the entry, but i get the behavior above still.

sorry - for so many replies....

mmcguill commented 5 years ago

Thanks @georgesnow... that is very strange indeed... I will add some better messaging about what's happening here in the next release, and also I think I will be a bit more aggressive about clearing stale entries. I'll also add some UI indication of Population and Clearing of the QuickType DB.

limuc commented 5 years ago

@mmcguill No, i don't even see the suggestion. Tried it multiple times. But maybe it's just my database, i have this strange problem with the readout of my history (maybe a hint, that something with my database isn't working the way it should?) IMG_3842

JLWFuQrioea69ugsykvQcg commented 5 years ago

Hi Mark. I've been trying everything you suggested but can't get it to work on my existing database. I created a new test database in Keepass and it works fine. I then tried to sync my existing database entries with the working new one and it doesn't work with QuickType. Then I deleted everything in the test database that I synced except for the two test entries and now it works (which is useless since I deleted all my data out of it).

In your checklist of items 1-5, you mentioned nonempty usernames and websites. Are you saying every entry has to have these populated in order to work? My database contains plenty of entries where one or both are not populated but that's by design. I would think that it would skip these.

Also, I noticed that while testing a working database, if I change the username of an entry, it wasn't showing correctly in QuickType until I toggled Autofill on/off.

georgesnow commented 5 years ago

@shad0whawk turns out the empty username entries don't matter. The working database i confirmed there are 3-4 entries with URLs and passwords but no usernames. And other sites that have username, password and URL Strongbox populated QuickType suggestions

JLWFuQrioea69ugsykvQcg commented 5 years ago

So I've narrowed my testing down to a small number of entries. It appears that it fails if there is a custom field in any entry. That seems to be the most consistent reason for failure from my testing. If I remove all entries with custom fields it works immediately and after I toggle the master Autofill switch off/on. If I add a custom field to an entry, it still works until I toggle the master autofill switch off/on, but it fails after I toggle the master Autofill switch off/on until I remove the custom field.

georgesnow commented 5 years ago

is this any type of custom field? ie what about TOTP Seeds?

georgesnow commented 5 years ago

when you say "master" are referring the iOS system preferences or the master toggle within the app?

JLWFuQrioea69ugsykvQcg commented 5 years ago

Initially a couple of my testing entries had a custom field called "Email" so I deleted it. Then tried it and it worked. Then I created a new custom entry within Strongbox called "Test" and it failed, removed it and it worked. Tried again with "Custom" and same results. So it seems the name doesn't matter if that's truly the issue.

Master meaning within Strongbox on the app's home screen where the databases are listed.

limuc commented 5 years ago

Awesome find @shad0whawk ! Tested it and i had one entry with a custom field, deleted that and it works!

georgesnow commented 5 years ago

do any of you have TOTP setup and have it working?

JLWFuQrioea69ugsykvQcg commented 5 years ago

That was a pain in the @$$ getting there. Hopefully, if that's the cause, it can be programmatically fixed to overlook that attribute.

georgesnow commented 5 years ago

awesome find....uh yeah that was. i just went through over 300 entries....i am going to try adding my TOTP back in cause it works now for me too without any custom fields of any kind. including items in my trash