Skip to content
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

Disabled LAContext attribute in simulator [SDK-1476] #91

Merged
merged 2 commits into from
Mar 26, 2020

Conversation

Widcket
Copy link
Contributor

@Widcket Widcket commented Mar 26, 2020

Changes

The iOS 13.4 simulator seems to have introduced a bug in the behavior of SecItemCopyMatching when a LAContext instance is used in the query.

Using any key will result in a successful OSCode:

let laContext = LAContext()

let loadQuery = [
  kSecClass as String: kSecClassGenericPassword,
  kSecAttrService as String: UUID().uuidString,
  kSecUseAuthenticationContext as String: laContext // 👈🏻
] as [String : Any]

let result = SecItemCopyMatching(loadQuery as CFDictionary, nil)
print("Result: \(result == errSecSuccess)")

// Result: true

And no data will actually be retrieved:

let laContext = LAContext()
let key = "foo"

let saveQuery = [
    kSecClass as String: kSecClassGenericPassword,
    kSecAttrService as String: key,
    kSecValueData as String: "bar".data(using: .utf8)!,
    kSecUseAuthenticationContext as String: laContext // 👈🏻
] as [String : Any]

SecItemAdd(saveQuery as CFDictionary, nil)

let loadQuery = [
    kSecClass as String: kSecClassGenericPassword,
    kSecAttrService as String: key,
    kSecReturnData as String: kCFBooleanTrue!,
    kSecUseAuthenticationContext as String: laContext // 👈🏻
] as [String : Any]

var dataTypeRef: CFTypeRef?
SecItemCopyMatching(loadQuery as CFDictionary, &dataTypeRef)

print(String(data: (dataTypeRef as? Data) ?? "nope!".data(using: .utf8)!, encoding: .utf8)!)

// nope!

This PR disables the use of kSecUseAuthenticationContext in simulator targets.

References

Fixes #90

Testing

[ ] This change adds unit test coverage (or why not)
[X] This change has been tested on the latest version of the platform/language or why not

Checklist

[X] I have read the Auth0 general contribution guidelines
[X] I have read the Auth0 Code of Conduct
[ ] All existing and new tests complete without errors

@Widcket Widcket added this to the vNext milestone Mar 26, 2020
@Widcket Widcket requested a review from a team March 26, 2020 19:17
@Widcket Widcket changed the title Disabled LAContext attribute in simulator Disabled LAContext attribute in simulator [SDK-1476] Mar 26, 2020
@Widcket Widcket merged commit 98393f0 into master Mar 26, 2020
@Widcket Widcket deleted the fix/simulator-workaround branch March 26, 2020 20:21
@Widcket Widcket mentioned this pull request Mar 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Does not work in iOS13.4 simulator
2 participants