From 50c2e085a00696b06e58de72ea5e17fe26c210a3 Mon Sep 17 00:00:00 2001 From: dankito Date: Fri, 2 Oct 2020 04:34:46 +0200 Subject: [PATCH] Implemented setting also keychain item's SecAccessControl and LAContext (but setting LAContext doesn't work yet, setting it results in an error) --- .../Security/KeychainPasswordItem.swift | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ui/BankingiOSApp/BankingiOSApp/Security/KeychainPasswordItem.swift b/ui/BankingiOSApp/BankingiOSApp/Security/KeychainPasswordItem.swift index 1f283f95..696a80fd 100644 --- a/ui/BankingiOSApp/BankingiOSApp/Security/KeychainPasswordItem.swift +++ b/ui/BankingiOSApp/BankingiOSApp/Security/KeychainPasswordItem.swift @@ -53,6 +53,8 @@ */ import Foundation +import LocalAuthentication + struct KeychainPasswordItem { // MARK: Types @@ -71,13 +73,20 @@ struct KeychainPasswordItem { private(set) var account: String? let accessGroup: String? + + let secAccessControl: SecAccessControl? + + let authenticationContext: LAContext? + // MARK: Intialization - init(service: String, account: String?, accessGroup: String? = nil) { + init(service: String, account: String?, accessGroup: String? = nil, secAccessControl: SecAccessControl? = nil, authenticationContext: LAContext? = nil) { self.service = service self.account = account self.accessGroup = accessGroup + self.secAccessControl = secAccessControl + self.authenticationContext = authenticationContext } @@ -185,12 +194,12 @@ struct KeychainPasswordItem { query[kSecAttrAccessGroup as String] = accessGroup as AnyObject? } - if let accessControl = accessControl { + if let accessControl = secAccessControl { query[kSecAttrAccessControl as String] = accessControl as AnyObject? } if let authenticationContext = authenticationContext { - query[kSecUseAuthenticationContext as String] = authenticationContext as AnyObject? + query[kSecUseAuthenticationContext as String] = authenticationContext } return query