Skip to content

Commit

Permalink
Merge branch 'fork'
Browse files Browse the repository at this point in the history
  • Loading branch information
rivera-ernesto committed Aug 14, 2024
2 parents e0c7eeb + 49d5cbd commit 0d5aedd
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion Lib/KeychainAccess/Keychain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -881,12 +881,18 @@ public final class Keychain {

// MARK:

public class func allKeys(_ itemClass: ItemClass) -> [(String, String)] {
public class func allKeys(_ itemClass: ItemClass, accessGroupsCompatible: Bool = true) -> [(String, String)] {
var query = [String: Any]()
query[Class] = itemClass.rawValue
query[AttributeSynchronizable] = SynchronizableAny
query[MatchLimit] = MatchLimitAll
query[ReturnAttributes] = kCFBooleanTrue

if #available(iOS 13.0, OSX 10.15, watchOS 6.0, tvOS 13.0, *) {
if accessGroupsCompatible {
query[UseDataProtectionKeychain] = true
}
}

var result: AnyObject?
let status = SecItemCopyMatching(query as CFDictionary, &result)
Expand Down Expand Up @@ -1293,6 +1299,9 @@ private let UseAuthenticationUIFail = String(kSecUseAuthenticationUIFail)
@available(iOS 9.0, macOS 10.11, watchOS 2.0, tvOS 9.0, *)
private let UseAuthenticationUISkip = String(kSecUseAuthenticationUISkip)

@available(iOS 13.0, OSX 10.15, watchOS 6.0, tvOS 13.0, *)
private let UseDataProtectionKeychain = String(kSecUseDataProtectionKeychain)

#if os(iOS) && !targetEnvironment(macCatalyst)
/** Credential Key Constants */
private let SharedPassword = String(kSecSharedPassword)
Expand Down Expand Up @@ -1355,6 +1364,12 @@ extension Options {
}
}
#endif

if #available(iOS 13.0, OSX 10.15, watchOS 6.0, tvOS 13.0, *) {
// if accessGroup != nil {
query[UseDataProtectionKeychain] = true
// }
}

return query
}
Expand Down Expand Up @@ -1397,6 +1412,12 @@ extension Options {
}

attributes[AttributeSynchronizable] = synchronizable ? kCFBooleanTrue : kCFBooleanFalse

if #available(iOS 13.0, OSX 10.15, watchOS 6.0, tvOS 13.0, *) {
// if accessGroup != nil {
attributes[UseDataProtectionKeychain] = true
// }
}

return (attributes, nil)
}
Expand Down

0 comments on commit 0d5aedd

Please sign in to comment.