evgenyneu / keychain-swift

Helper functions for saving text in Keychain securely for iOS, OS X, tvOS and watchOS.
MIT License
2.85k stars 345 forks source link

Support kSecClassInternetPassword class? #159

Open jordanhbuiltbyhq opened 2 years ago

jordanhbuiltbyhq commented 2 years ago

Apple seems to recommend when saving a password to use kSecClassInternetPassword where you specify a username account, a server, and a password (documentation). There is a note that one should use kSecClassGenericPassword instead when you don’t need extra attributes for remote access. Now everything in this keychain library uses kSecClassGenericPassword it's not possible to use kSecClassInternetPassword.

As an aside, it's mildly interesting, I suspect basically everyone is "misusing" the keychain API because I believe the "account" is not intended to be a key to look up like "MyServicePassword", it should seemingly be the user's account like their actual username. This makes it a bit tricky to look up later and migrate when the username changes. Wishing the keychain API were nicer fr. But perhaps this library could implement support for the recommended solution and even encourage correct usage? :)