2
0

Keychain fix + signout fix.

[FIXED]     GenericPassword class keychain items should have both an
            Account and a Service attribute.
[FIXED]     OS X: Logout when key is saved.
This commit is contained in:
Maarten Billemont 2012-05-13 19:50:40 +02:00
parent b0875beb36
commit ada6d6b36a
4 changed files with 17 additions and 12 deletions

View File

@ -17,8 +17,10 @@ static NSDictionary *keyQuery() {
static NSDictionary *MPKeyQuery = nil; static NSDictionary *MPKeyQuery = nil;
if (!MPKeyQuery) if (!MPKeyQuery)
MPKeyQuery = [PearlKeyChain createQueryForClass:kSecClassGenericPassword MPKeyQuery = [PearlKeyChain createQueryForClass:kSecClassGenericPassword
attributes:[NSDictionary dictionaryWithObject:@"Saved Master Password" attributes:[NSDictionary dictionaryWithObjectsAndKeys:
forKey:(__bridge id)kSecAttrService] @"Saved Master Password", (__bridge id)kSecAttrService,
@"default", (__bridge id)kSecAttrAccount,
nil]
matches:nil]; matches:nil];
return MPKeyQuery; return MPKeyQuery;
@ -29,8 +31,10 @@ static NSDictionary *keyIDQuery() {
static NSDictionary *MPKeyIDQuery = nil; static NSDictionary *MPKeyIDQuery = nil;
if (!MPKeyIDQuery) if (!MPKeyIDQuery)
MPKeyIDQuery = [PearlKeyChain createQueryForClass:kSecClassGenericPassword MPKeyIDQuery = [PearlKeyChain createQueryForClass:kSecClassGenericPassword
attributes:[NSDictionary dictionaryWithObject:@"Master Password Verification" attributes:[NSDictionary dictionaryWithObjectsAndKeys:
forKey:(__bridge id)kSecAttrService] @"Master Password Check", (__bridge id)kSecAttrService,
@"default", (__bridge id)kSecAttrAccount,
nil]
matches:nil]; matches:nil];
return MPKeyIDQuery; return MPKeyIDQuery;
@ -39,8 +43,10 @@ static NSDictionary *keyIDQuery() {
- (void)forgetKey { - (void)forgetKey {
inf(@"Deleting key and ID from keychain."); inf(@"Deleting key and ID from keychain.");
[PearlKeyChain deleteItemForQuery:keyQuery()]; if ([PearlKeyChain deleteItemForQuery:keyQuery()] != errSecItemNotFound)
[PearlKeyChain deleteItemForQuery:keyIDQuery()]; inf(@"Removed key from keychain.");
if ([PearlKeyChain deleteItemForQuery:keyIDQuery()] != errSecItemNotFound)
inf(@"Removed key ID from keychain.");
[[NSNotificationCenter defaultCenter] postNotificationName:MPNotificationKeyForgotten object:self]; [[NSNotificationCenter defaultCenter] postNotificationName:MPNotificationKeyForgotten object:self];
#ifdef TESTFLIGHT_SDK_VERSION #ifdef TESTFLIGHT_SDK_VERSION
@ -49,7 +55,8 @@ static NSDictionary *keyIDQuery() {
} }
- (IBAction)signOut:(id)sender { - (IBAction)signOut:(id)sender {
[MPConfig get].saveKey = [NSNumber numberWithBool:NO];
[self updateKey:nil]; [self updateKey:nil];
} }

View File

@ -212,9 +212,10 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
#pragma mark - UbiquityStoreManagerDelegate #pragma mark - UbiquityStoreManagerDelegate
- (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didSwitchToiCloud:(BOOL)didSwitch { - (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didSwitchToiCloud:(BOOL)iCloudEnabled {
self.useICloudItem.state = didSwitch? NSOnState: NSOffState; self.useICloudItem.state = iCloudEnabled? NSOnState: NSOffState;
self.useICloudItem.enabled = !iCloudEnabled;
} }
@end @end

View File

@ -105,8 +105,6 @@
// "Unlock" button. // "Unlock" button.
[[MPAppDelegate get] tryMasterPassword:[(NSSecureTextField *)alert.accessoryView stringValue]]; [[MPAppDelegate get] tryMasterPassword:[(NSSecureTextField *)alert.accessoryView stringValue]];
} }
[self unlock];
} }
- (NSArray *)control:(NSControl *)control textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(NSInteger *)index { - (NSArray *)control:(NSControl *)control textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(NSInteger *)index {

View File

@ -425,7 +425,6 @@
case 5: case 5:
#endif #endif
{ {
[MPConfig get].saveKey = [NSNumber numberWithBool:NO];
[[MPAppDelegate get] signOut:self]; [[MPAppDelegate get] signOut:self];
[[MPAppDelegate get] loadKey:YES]; [[MPAppDelegate get] loadKey:YES];
break; break;