Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add biometrics #42

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Add biometrics #42

wants to merge 18 commits into from

Conversation

initFabian
Copy link
Collaborator

@initFabian initFabian commented Jan 26, 2020

Purpose:

Add biometrics functionality.

New Cely Credentials API

Please refer to documentation docs for usage. I know I pulled the trigger a little early around the documentation site, buuuttttt I wanted to focus on the experience around documentation and have that drive the code for this release. Please give your honest opinion and API design and potential shortcomings.

Cely Documentation

This is going to be something new and entirely different so don't feel responsible for this part of the code. It uses mkdocs to generate the site. But if you are able to check out the docs and give your thoughts that would be amazing! I understand all this was made in a cave and should be viewed as a First Draft.

What did I do?

  • Introduces new CelyCredentials API
  • Added new file demo file CelyDemo/BiometricsLoginViewController.swift that in the Cely Demo Target that uses new CelyCredentials API
  • set CelyDemo/Appdelegate.swift to point to BiometricsLoginViewController.swift for testing
  • Add a button to CelyDemo/SettingsViewController.swift that logs credentials to the console
  • improve encapsulation (private) around methods/variables throughout Cely
  • Replace StorageResult with Swift Result
  • replace CelyStorageProtocol.removeAllData() with clearStorage()
  • Add class CelyKeychain
    • responsible for CRUD operations for KeychainObject (Keychain Items)
  • Add class CelySecureStorage
    • responsible for creating KeychainObject and storing them with CelyKeychain
    • implements CelyStorageProtocol (.clearStorage() gets called from CelyStorage when user is logging out)
  • Add class KeychainObject
    • syntactic sugar around KeychainItem. (I'm not entirely in love with how this came out around toGetMap/toLookupMap since they aren't really descriptive on what they're used for.)

Notes

When I created this PR, it was to finally get the code in front of someone else. In terms of what this PR sought out to do (add the biometrics functionality), it does just that. but as far as how we get there, that's where I have thoughts. Things such as should we allow the developer to use kSecClassGenericPassword instead of kSecClassInternetPassword or use kSecAttrAccessibleWhenUnlocked instead of kSecAttrAccessibleWhenUnlockedThisDeviceOnly. Definitely read Cely's documentation over Understanding Keychain to form an opinion on what Cely should/shouldn't do.

In all, I would say this PR is 97% done. Really the only thing I don't like is around KeychainObject, but that class is only used internally and not exposed to the user/developer. so I'm not sure if we want to give that class the green light for now and just improve it at a later time.

Lastly, this PR did a lot. I really wish it didn't, but I wanted to do one big push for v3 to get the ball rolling.

How to Test:

  1. Have device with biometrics (FaceID/TouchID)
  2. Pull down branch
  3. Change Scheme to Cely Demo
  4. Error will happen around team/bundleID. change values to allow App to run
  • if you can help with find a long term solution on this, that would be awesome!
  1. Log into app with the credentials username:asdf and password:asdf
  2. VERIFY: App logs you in
  3. go to settings page and click Get Credentials
  4. VERIFY: biometrics are run on device
  5. VERIFY: credentials are logged to the console.

.gitignore Outdated
docs/

Cely.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking out!

@@ -77,3 +58,8 @@ public extension UIWindow {
}
}
}

public enum AccessibilityOptions {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name is confusing, because these options don't seem to have anything to do with Accessibility in the sense of providing access to people with disabilities. Would something along the lines of AccessControlOptions be more in line?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion!

I believe this is a much better name.

func set(query: KeychainObject) throws {
// try adding first
let newQuery = query.toSetMap(withValue: true)
let status: OSStatus = SecItemAdd(newQuery as CFDictionary, nil)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}
}

func set(_ value: Any?, forKey key: String, securely _: Bool = true, persisted _: Bool = true) throws {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we even providing securely and persisted options if neither of those values are used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because CelySecureStorage implements CelyStorageProtocol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants