Skip to content
This repository was archived by the owner on Dec 15, 2020. It is now read-only.

Commit 4085c78

Browse files
committed
remove TouchID support without SEP
1 parent bcc7f1c commit 4085c78

3 files changed

Lines changed: 3 additions & 88 deletions

File tree

‎SoftU2FTool/CLI.swift‎

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ fileprivate let deleteAllFlag = "--delete-all"
1313
fileprivate let showSEPFlag = "--show-sep"
1414
fileprivate let enableSEPFlag = "--enable-sep"
1515
fileprivate let disableSEPFlag = "--disable-sep"
16-
fileprivate let showTouchidFlag = "--show-touchid"
17-
fileprivate let enableTouchidFlag = "--enable-touchid"
18-
fileprivate let disableTouchidFlag = "--disable-touchid"
1916

2017
class CLI {
2118
private let args: [String]
@@ -31,15 +28,6 @@ class CLI {
3128
} else if args.contains(deleteAllFlag) {
3229
deleteAll()
3330
return true
34-
} else if args.contains(showTouchidFlag) {
35-
showTouchid()
36-
return true
37-
} else if args.contains(enableTouchidFlag) {
38-
enableTouchid()
39-
return true
40-
} else if args.contains(disableTouchidFlag) {
41-
disableTouchid()
42-
return true
4331
} else if args.contains(showSEPFlag) {
4432
showSEP()
4533
return true
@@ -93,27 +81,6 @@ class CLI {
9381
print("Deleted ", initialCount, " registrations")
9482
}
9583

96-
private func showTouchid() {
97-
if Settings.touchidDisabled {
98-
print("TouchID is disabled")
99-
} else {
100-
print("TouchID is enabled")
101-
}
102-
}
103-
104-
private func enableTouchid() {
105-
if Settings.enableTouchid() {
106-
print("TouchID is now enabled")
107-
} else {
108-
print("Error enabling TouchID. Does your system support it?")
109-
}
110-
}
111-
112-
private func disableTouchid() {
113-
Settings.disableTouchid()
114-
print("TouchID is now disabled")
115-
}
116-
11784
private func showSEP() {
11885
if Settings.sepEnabled {
11986
print("SEP storage is enabled for new keys")

‎SoftU2FTool/Settings.swift‎

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,22 @@ import Foundation
99
import LocalAuthentication
1010

1111
class Settings {
12-
private static let touchidDisabledKey = "touchidDisabled"
1312
private static let sepEnabledKey = "sepEnabled"
1413

15-
static var touchidDisabled: Bool {
16-
return !touchidAvailable || UserDefaults.standard.bool(forKey: touchidDisabledKey)
17-
}
18-
1914
static var sepEnabled: Bool {
20-
return touchidAvailable && UserDefaults.standard.bool(forKey: sepEnabledKey)
15+
return sepAvailable && UserDefaults.standard.bool(forKey: sepEnabledKey)
2116
}
2217

23-
private static var touchidAvailable: Bool {
18+
private static var sepAvailable: Bool {
2419
if #available(OSX 10.12.2, *) {
2520
return LAContext().canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil)
2621
} else {
2722
return false
2823
}
2924
}
3025

31-
static func enableTouchid() -> Bool {
32-
if touchidAvailable {
33-
UserDefaults.standard.set(false, forKey: touchidDisabledKey)
34-
return true
35-
} else {
36-
return false
37-
}
38-
}
39-
40-
static func disableTouchid() {
41-
UserDefaults.standard.set(true, forKey: touchidDisabledKey)
42-
}
43-
4426
static func enableSEP() -> Bool {
45-
if touchidAvailable {
27+
if sepAvailable {
4628
UserDefaults.standard.set(true, forKey: sepEnabledKey)
4729
return true
4830
} else {

‎SoftU2FTool/UserPresence.swift‎

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -79,40 +79,6 @@ class UserPresence: NSObject {
7979

8080
// Send a notification popup to the user.
8181
func test(_ type: Notification) {
82-
if #available(OSX 10.12.2, *) {
83-
if !Settings.touchidDisabled {
84-
let ctx = LAContext()
85-
86-
if ctx.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) {
87-
ctx.localizedCancelTitle = "Reject"
88-
ctx.localizedFallbackTitle = "Skip TouchID"
89-
90-
var prompt: String
91-
switch type {
92-
case let .Register(facet):
93-
prompt = "register with " + (facet ?? "site")
94-
case let .Authenticate(facet):
95-
prompt = "authenticate with " + (facet ?? "site")
96-
}
97-
98-
ctx.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: prompt) { (success, err) in
99-
guard let lerr = err as? LAError else {
100-
self.complete(success)
101-
return
102-
}
103-
104-
switch lerr.code {
105-
case .userFallback, .touchIDNotAvailable, .touchIDNotEnrolled:
106-
self.sendNotification(type)
107-
default:
108-
self.complete(false)
109-
}
110-
}
111-
return
112-
}
113-
}
114-
}
115-
11682
sendNotification(type)
11783
}
11884

0 commit comments

Comments
 (0)