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

Remove generic key which over-constrains query #79

Merged
merged 2 commits into from Jun 22, 2015
Merged

Remove generic key which over-constrains query #79

merged 2 commits into from Jun 22, 2015

Conversation

ghost
Copy link

@ghost ghost commented Jun 18, 2015

Aims: Fix bug where passcode is sometimes not accepted.

Test:

  1. Go through consent process, enter a passcode.
  2. Go to Device Settings and put the device time forward by 1 hour.
  3. Reopen the app from the background.
  4. Enter the passcode.

Expected:
Passcode is accepted and previously viewed tab is shown.

Actual without fix:
Passcode is denied

@@ -191,7 +189,6 @@ + (BOOL) removeItemForKey: (NSString *) key
NSMutableDictionary *itemToDelete = [[NSMutableDictionary alloc] init];
[itemToDelete setObject:(__bridge id)kSecClassGenericPassword forKey:(__bridge id)kSecClass];
[itemToDelete setObject:service forKey:(__bridge id)kSecAttrService];
[itemToDelete setObject:key forKey:(__bridge id)kSecAttrGeneric];
[itemToDelete setObject:key forKey:(__bridge id)kSecAttrAccount];
#if !TARGET_IPHONE_SIMULATOR && defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this dictionary generation code be consolidated into one place?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The objects set on the dictionary/query are not consistent between methods, and removeAllItemsForService uses the dictionary in a loop. The only consistent line is
[query setObject:(__bridge id)kSecClassGenericPassword forKey:(__bridge id)kSecClass];

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work?

static NSMutableDictionary* NSMutableDictionary createQuery(id class, id service, id account) {
    ...
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do that, providing we cover all the parameters for all the methods, such as kSecReturnData, kSecReturnAttributes, kSecMatchLimit, kSecAttrAccessGroup...
@insha any comment to add?

@YuanZhu-apple
Copy link
Member

@insha @chrisinsfo Can you address this?
Then I can get it merged.

@insha
Copy link

insha commented Jun 22, 2015

While the code is working, consolidating this code will affect all our apps and therefore will take a while with testing. Is it possible that we create an issue on GitHub to track this?

@YuanZhu-apple
Copy link
Member

OK, @insha Can you create a issue from @chrisinsfo 's comment?

YuanZhu-apple added a commit that referenced this pull request Jun 22, 2015
Remove generic key which over-constrains query
@YuanZhu-apple YuanZhu-apple merged commit 0cef976 into ResearchKit:master Jun 22, 2015
@ghost
Copy link
Author

ghost commented Jun 22, 2015

I'm concerned that setting nil as a query parameter via a class method to create the query, may actually constrain the query, which is what I'm trying to avoid. Will need testing or advice - @YuanZhu-apple ?

@insha
Copy link

insha commented Jun 22, 2015

@YuanZhu-apple Will do. Thank you.

@YuanZhu-apple
Copy link
Member

@chrisinsfo How about we discuss it when the PR for #80 is submitted?

@ghost ghost deleted the J245 branch July 21, 2015 17:48
Erin-Mounts added a commit to Erin-Mounts/AppCore that referenced this pull request Feb 23, 2016
Unit test fixes and added hook for onboarding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants