Persisting User Data
There are numerous ways to save data on a mac and iOS device. Saving to a file in a format such as JSON is possibly one of the most obvious and straight forward ways but my research this week has been towards the best way to save user sensitive data. The data I wish to persist is the users name and email address. This is the information that will be associated with a Stamp, much like a git identify is associated with a commit and thus users can see who made a stamp, allowing for functionality such as searching and filtering per user.
As I began to sketch out the information I might want to associate with a Stamp I took a git identity as inspiration. I wanted to keep the information as lightweight as possible and also in the back of my mind I also wanted to make sure I had a plan for users being able to verify whether a Stamp was actually made the associated creator. Git solves this problem by signing commits with a GPG Public Key. I do not intend to implement this now but if there comes a time when Stamps are being made and maliciously associated with an incorrect user then I have a plan in place.
Apple suggest persisting user sensitive data in KeyChain and provide an API called Keychain Services to interact with it. I found Keychain Services to be quite a difficult API to work. To store some data in the keychain, you need to package several attributes about the data along with the secret information. You store all of them together into a keychain item. To make my life easier I decided to use an open source wrapper around the API called Keychain Access.
- Apple Keychain Services. [online]. Available at: https://developer.apple.com/documentation/security/keychain_services [accessed 16 August 2020].
- Git Signing Your Work. [online]. Available at: https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work [accessed 16 August 2020].
- Keychain Access. [online]. Available at: https://github.com/kishikawakatsumi/KeychainAccess [accessed 16 August 2020].