-
Notifications
You must be signed in to change notification settings - Fork 794
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
Fix macOS Access Groups #538
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -887,12 +887,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 | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code is from a class function, so we can't check if options has access groups set or not... |
||
} | ||
|
||
var result: AnyObject? | ||
let status = SecItemCopyMatching(query as CFDictionary, &result) | ||
|
@@ -1299,6 +1305,9 @@ private let UseAuthenticationUIFail = String(kSecUseAuthenticationUIFail) | |
@available(iOS 9.0, OSX 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) | ||
|
@@ -1361,6 +1370,12 @@ extension Options { | |
} | ||
} | ||
#endif | ||
|
||
if #available(iOS 13.0, OSX 10.15, watchOS 6.0, tvOS 13.0, *) { | ||
if accessGroup != nil { | ||
query[UseDataProtectionKeychain] = true | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Automatically set |
||
} | ||
|
||
return query | ||
} | ||
|
@@ -1403,6 +1418,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 | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing here |
||
} | ||
|
||
return (attributes, nil) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...so I added an optional
accessGroupsCompatible
that defaults totrue
(per Apple documentation Tip)