oblador / react-native-keychain

:key: Keychain Access for React Native
MIT License
3.21k stars 519 forks source link

Feature Idea: Add ability to search by username #112

Open fbartho opened 6 years ago

fbartho commented 6 years ago

An app I'm working on stores a few bits of data as Generic Passwords under distinct usernames as persistent state (in native code) and I'm looking to migrate this app to react-native.

If we use react-native-keychain as implemented today, getGenericPassword doesn't take an option for kSecAttrAccount, so it returns 1 (random?) value from this list of 4 keys. It'd be great if we could submit the key we're looking to search for.

I'd be happy to contribute a PR for iOS, -- but I have no idea of the scope of this for Android. Would this PR be a welcome feature addition?

ghost commented 6 years ago

We just encountered this issue after adding https://github.com/urbanairship/react-native-module (see https://github.com/urbanairship/react-native-module/issues/114#issuecomment-385534343), would be very helpful to have this available.

fbartho commented 6 years ago

@jacobcabantomski-ct -- My project is also going to need to use UrbanAirship so your referenced issue is going to be a blocker soon, so we're going to need this feature sooner than later. Do you want to collaborate on a PR for this?

I'd be happy to review your code if you have time this week, or I'd be happy to get it started in a week or so. -- Maybe @oblador might be able to fast-track it if we get it done well?

ghost commented 6 years ago

@fbartho I'm currently awaiting feedback on whether we can invalidate current user logins and use getInternetCredentials to store our information in a more controllable way. If not, I'd be happy to collab on a PR. I have some rusty Android/Java skills I can contribute.

fbartho commented 6 years ago

@jacobcabantomski-ct I'm pretty comfortable on the iOS side, myself, so with our powers combined…

From looking at what we'd need to do, I think the hardest part is the public API changes.

As I see it the easy options are: A. we either ask for "all active generic passwords" and return an array of them which the user can filter down to 1 B. we update the options passed to getGenericPassword to have a username key that it can filter at the native level.

Depending on our implementation choice, it would actually mostly be javascript code. 1 small tweak to create a new api (getGenericPasswords) that returns an array, + add a shim in the JS to support the old API & return the first entry in this array if it exists.

fbartho commented 6 years ago

Any opinions @oblador ? Which API would you prefer we add?

veermangat commented 5 years ago

I have the same issue, would be nice if we could pass the account to retrieve specific entries and not just the first one.

I am stuck, because I am trying to upgrade from a previous version of the app. And with this library I can only fetch the first value. If the user has had multiple accounts, there is no way to fetch the latest one currently.

vomchik commented 4 years ago

+1

krzysztofnowak commented 9 months ago

+1

travis-mark commented 4 months ago

I just ran into this issue when reading keychain entries set by existing iOS code that used multiple accounts under the same service. PR: https://github.com/oblador/react-native-keychain/pull/643