From e6bcb76c2ddec8052cc8bb8d697c7f4e75a55be8 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Fri, 15 Nov 2024 11:04:36 +0100 Subject: [PATCH] Ensure keychain items are accessible after the device was unlocked (#99) By setting `kSecAttrAccessibleAfterFirstUnlock` when writing keychain items, these should be readable even after the device is locked due to lock screen etc. --- .../Sources/Keychain/Internal/Queries/AddKeyQuery.swift | 1 + .../Sources/Keychain/Internal/Queries/AddPasswordQuery.swift | 1 + .../Sources/Keychain/Internal/Queries/UpdatePasswordQuery.swift | 1 + xcconfigs/General.xcconfig | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Packages/Keychain/Sources/Keychain/Internal/Queries/AddKeyQuery.swift b/Packages/Keychain/Sources/Keychain/Internal/Queries/AddKeyQuery.swift index c956c9b..3978a92 100644 --- a/Packages/Keychain/Sources/Keychain/Internal/Queries/AddKeyQuery.swift +++ b/Packages/Keychain/Sources/Keychain/Internal/Queries/AddKeyQuery.swift @@ -13,6 +13,7 @@ struct AddKeyQuery: KeychainQuery { if let accessGroup { query[kSecAttrAccessGroup as String] = accessGroup } + query[kSecAttrAccessible as String] = kSecAttrAccessibleAfterFirstUnlock return query as CFDictionary } } diff --git a/Packages/Keychain/Sources/Keychain/Internal/Queries/AddPasswordQuery.swift b/Packages/Keychain/Sources/Keychain/Internal/Queries/AddPasswordQuery.swift index d9c9978..1e1e844 100644 --- a/Packages/Keychain/Sources/Keychain/Internal/Queries/AddPasswordQuery.swift +++ b/Packages/Keychain/Sources/Keychain/Internal/Queries/AddPasswordQuery.swift @@ -15,6 +15,7 @@ struct AddPasswordQuery: KeychainQuery { if let accessGroup { query[kSecAttrAccessGroup as String] = accessGroup } + query[kSecAttrAccessible as String] = kSecAttrAccessibleAfterFirstUnlock return query as CFDictionary } } diff --git a/Packages/Keychain/Sources/Keychain/Internal/Queries/UpdatePasswordQuery.swift b/Packages/Keychain/Sources/Keychain/Internal/Queries/UpdatePasswordQuery.swift index 869d397..410cf3e 100644 --- a/Packages/Keychain/Sources/Keychain/Internal/Queries/UpdatePasswordQuery.swift +++ b/Packages/Keychain/Sources/Keychain/Internal/Queries/UpdatePasswordQuery.swift @@ -6,6 +6,7 @@ struct UpdatePasswordQuery: KeychainQuery { var rawQuery: CFDictionary { var query: [String: Any] = [:] query[kSecValueData as String] = password + query[kSecAttrAccessible as String] = kSecAttrAccessibleAfterFirstUnlock return query as CFDictionary } } diff --git a/xcconfigs/General.xcconfig b/xcconfigs/General.xcconfig index 0cdbe6d..faa41e8 100644 --- a/xcconfigs/General.xcconfig +++ b/xcconfigs/General.xcconfig @@ -1,6 +1,6 @@ GENERATE_INFOPLIST_FILE = YES CURRENT_PROJECT_VERSION = 1 -MARKETING_VERSION = 0.10.1 +MARKETING_VERSION = 0.10.2 DEVELOPMENT_TEAM = 566MC7D8D4 CODE_SIGN_STYLE = Automatic CODE_SIGN_ENTITLEMENTS = Tartelet/Supporting files/Tartelet.entitlements