Hi, I am learning Swift and managed to make the login example work in a different app in Swift 3. So it is a great tutorial if a novice like me can make it work!
Like d07Jansen, I tried to extend what I learnt to save another item in the key chain, but got confused by the use of the “v_Data” key. I assume it is pre-defined but I can’t find it documented anywhere. Does it relate to kSecValueData?
Is it easy to explain how to add more than one item to the key chain or is that a whole other tutorial?
Seems to work well and written in swift - which makes it easier for me to figure what’s happening since I don’t know Objective C. Wrote engineering / CAD systems in Fortran / assembler in the 1980s so a whole generation of modern programming languages passed me by!
One question: Why are you enforcing that the user already created an account before allowing them to use 1Password? The value of a password manager is to not have to remember or write down your credentials. You first generate the password and save it to the password manager. Then you register for the site using the credentials you created.
The current approach seems to be a simplifying assumption so you don’t have to handle the additional case of a new user registering with 1Password.
I’m not “enforcing” anything. The tutorial was written with three goals. 1 Show users how to create an app that uses the Keychain to save credentials. 2. Show how to set up Touch ID. 3. Show how to use 1Password. All the while providing a fallback if users don’t have TouchID or 1Password.
At the time the tutorial was first written, the iPhone 5 had just come out. Around that time not many people had access to Touch ID, especially on iPad. We wanted to make sure that we could provide a fallback for users who couldn’t use the framework. There are still lots of iPad 2’s, 3’s and iPad Mini’s out there
Additionally when I started writing the tutorial, the 1Password SDK had just come out, I wasn’t aware that it didn’t work directly with Touch ID, in fact if I recall correctly, it didn’t. It does support Touch ID now to open the Extension as well.
So the tutorial was written to provide enough information for someone to build upon. It is in no way intended to be the ideal workflow. There are also plenty of Swift based Keychain Wrappers out there now. There weren’t many when the tutorial was first written.
Glad you enjoyed the tutorial and I’m also pleased that you can see the flaws. That means you’ll probably take the idea to the next level.
How do I test the credentials which saved in IOS keychain?
As a tester, I want to test the credentials which saved in IOS keychain. scenarios which App can not contact the keychain, Crashed credentials (how to crash?), does the correct credentials use in all the times, Does the credentials remove when the app close and uninstall… etc. How do I do that as a tester?
If you’re asking about writing a unit test you would need to mock the data. So inside your test function you would create a record to store in the keychain and then follow it up with a XCTAssertEqual(_ [or True] to see if the value gets stored as expected or not.
Since Keychain is synchronized over iCloud. So, that means if a User logs in with his/her iCloud account in 2 devices, both the devices will have the same Keychain. Am I Right?
We’ve just finished updating the tutorial for Swift 3.0 using a Swift Wrapper. It should be out soon. I’ll take a look at your problem and get back to you.
Hmm. Interesting question. I’ll have to try that. I think as long as the App identifier is the same it should work. You may need to tweak the Keychain capability to make that work.