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

Prototype of using privacy screen and LocalAuthentication #219

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

beaucollins
Copy link
Collaborator

@beaucollins beaucollins commented Oct 27, 2017

Adds Component that:

  • Checks if device can use LocalAuthentication
  • Checks if a successful auth challenge has occurred

Given that LocalAuthentication is available on the device:

When the application becomes foreground after launching a privacy screen is presented. A successful
LocalAuthentication dismisses the privacy screen.

When the application enters the background state the privacy screen is presented. This prevents
tokens from being displayed during app switching.

None of the keychain items are using LocalAuthentication for encryption. This is purely UI related
so the security/encryption of the keychain items have not been changed by this feature.

Tokens are still readable/displayable by the app no matter what the state of the LocalAuthentication
challenge is.

- Adds Component that:
  - Checks if device can use LocalAuthentication
  - Checks if a successful auth challenge has occurred

Given that LocalAuthentication is available on the device:

When the application becomes foreground after launching a privacy screen is presented. A successful
LocalAuthentication dismisses the privacy screen.

When the application enters the background state the privacy screen is presented. This prevents
tokens from being displayed during app switching.

None of the keychain items are using LocalAuthentication for encryption. This is purely UI related
so the security/encryption of the keychain items have not been changed by this feature.

Tokens are still readable/displayable by the app no matter what the state of the LocalAuthentication
challenge is.

@objc private func authChallenge() {
let context = LAContext()
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: "LOLZ") { (reply, error) in
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 localizedReason seems completely correct to me.

@codecov
Copy link

codecov bot commented Sep 27, 2018

Codecov Report

Merging #219 into develop will increase coverage by 1.98%.
The diff coverage is 60.6%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #219      +/-   ##
===========================================
+ Coverage    38.48%   40.47%   +1.98%     
===========================================
  Files           40       40              
  Lines         1863     1895      +32     
===========================================
+ Hits           717      767      +50     
+ Misses        1146     1128      -18
Impacted Files Coverage Δ
Authenticator/Source/RootViewController.swift 35.53% <28.57%> (+14.48%) ⬆️
Authenticator/Source/AppController.swift 35.71% <50%> (+9.04%) ⬆️
Authenticator/Source/OTPAppDelegate.swift 50% <50%> (ø) ⬆️
Authenticator/Source/Root.swift 72.94% <77.77%> (+0.88%) ⬆️
Authenticator/Source/UITableView+Updates.swift 100% <0%> (+4%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9ed3357...5c9d8a9. Read the comment docs.

@beaucollins
Copy link
Collaborator Author

@mattrubin not sure if you'll be referencing this PR at all for the local auth feature but I merged it with develop so it's in a buildable state again.

@mattrubin
Copy link
Owner

Thanks, @beaucollins!

@mattrubin mattrubin mentioned this pull request Mar 9, 2019
@BrunoMiguens
Copy link

Do you need any help to update/finish this MR or any other?

@mattrubin
Copy link
Owner

Thanks for the offer, @BrunoMiguens!

I've built out this feature more on top of Beau's work - you can see the latest at #304. The description on that PR contains a list of improvements that need to be made before the feature is ready for release. The two that are most important - and are perhaps the best place for someone to lend a hand - are:

  • switch to using a separate UIWindow for the lock screen, rather than a modal view controller. I haven't found a good way to reliably present the modal lock screen on launch, so launching to the lock screen as a the key window is likely more reliable and secure. There's a FIXME comment to that effect in PR Local Authentication #304.
  • adding a toggle to the settings screen to enable/disable screen lock. This should only be available to the user if a device password is set, as checked by LocalAuthentication's canEvaluatePolicy. (checking out the previous user setting added in Settings screen for password digit grouping #290 might help provide a template for how to add and store a preference toggle.)

If either of those seems like something you'd like to work on, PRs are always welcome! I am away from my computer for the next week, but have set aside some time to work on Authenticator when I return, so while I can't review any code immediately, I will have time to look at it next week.


@objc private func authChallenge() {
let context = LAContext()
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: "LOLZ") { (reply, error) in

Choose a reason for hiding this comment

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

This currently only triggers the passcode-screen, although Face ID is available. Per docs it should try Face ID / Touch ID first. Did you notice this as well?

Copy link
Owner

Choose a reason for hiding this comment

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

Strange! On my phone, it triggers FaceID.
Each app that wants to use FaceID shows a permission prompt the first time it tries to authenticate with FaceID. If permission is denied, it falls back to using a password. If you check in the system Settings.app, does Authenticator have permission to use FaceID?

Choose a reason for hiding this comment

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

It does not prompt for this permission and is not visible in the settings but I can check again!

Having this pull request merged brings this project to a new level of privacy, so thanks everyone contributing to this! 🙂

@savyyy001

This comment has been minimized.

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

Successfully merging this pull request may close these issues.

6 participants