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:
parent
b0875beb36
commit
ada6d6b36a
@ -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
|
||||||
@ -50,6 +56,7 @@ static NSDictionary *keyIDQuery() {
|
|||||||
|
|
||||||
- (IBAction)signOut:(id)sender {
|
- (IBAction)signOut:(id)sender {
|
||||||
|
|
||||||
|
[MPConfig get].saveKey = [NSNumber numberWithBool:NO];
|
||||||
[self updateKey:nil];
|
[self updateKey:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -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 {
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user