agilebits / onepassword-app-extension

1Password Extension for iOS Apps
2.58k stars 311 forks source link

WKWebview + local html file brings up an empty 1Password with no option to search #350

Closed gabek closed 7 years ago

gabek commented 7 years ago

I'm using the 1Password extension with a WKWebview. This web view is loading a local HTML page that is bootstrapping a Javascript app. Therefore 1Password accurately sees it as "about:blank".

However, I'd expect to be able to search my available 1Password logins from this screen, and instead it only gives me the option to create a new one. I've tried with both showOnlyLogins as false and true.

Thanks for any help!

portable network graphics image-bfc7759d07b8-1

gks commented 7 years ago

Hi @gabek!

Sorry it took so long for me to respond to this. In your particular scenario you have two options for working through the trouble you're having.

The first, which you've found out is that the fillItemIntoWebView method obtains its URL from the web view itself. There's no search feature here or show all logins option here for security reasons. The option to search is offered in findLoginForURLString only if no matching logins are found for the supplied URL. We explicitly disable searching in fillItemIntoWebView due to phishing concerns.

That means the only way really around this while using fillItemIntoWebView is going to be to have the rendered page hosted on a server under the URL you wish for fillItemIntoWebView to search rather than to have it locally contained within the application.

I'm not sure if this is a feasible option but it is the first option and therefore providing it.

The second option would be to use findLoginForURLString which allows you to supply the URL, but does not supply filling into the web view. You'd effectively have to use findLoginForURLString to get the dictionary with the username and password back, then from your Objective-C or Swift code inject the username and password into their correct fields in the web view. This is more work, but it would allow you to do what you're expecting since fillItemIntoWebView is not going to let you supply the URL and it's not going to allow the user to search or show other login items due to phishing concerns.

I wish I had some examples of this but I'm afraid I do not. But I hope it makes sense and one of those two options will suffice for you.

Let me know if you have any questions however.

gabek commented 7 years ago

Less than one day turnaround for a response, you guys are on top of it, thanks for getting back to me @gks!

Those restrictions all make total sense, thanks for looking into it. Our web integration was just a stopgap anyway, so this isn't the end of the world. Hope all is well in AgileBits land!

gks commented 7 years ago

Thanks @gabek!

Would've liked to have had a response to you yesterday, eventually I'll get there :)

Yea, if that's just a stopgap then you should be on your way in due time! Thank you for adding 1Password support to your app as well, it's greatly appreciated not just by us but by all of our potential mutual users. Keep up the great work and if I can do anything to assist in the future just let me know.