Coder Social home page Coder Social logo

carlbrown / pdkeychainbindingscontroller Goto Github PK

View Code? Open in Web Editor NEW
601.0 601.0 85.0 109 KB

Mac OSX and iOS Keychain Access patterned after NSUserDefaults.

Home Page: http://www.escortmissions.com/blog/2011/9/3/steal-this-code-and-protect-their-data-simplifying-keychain.html

License: MIT License

Ruby 4.41% Objective-C 95.59%

pdkeychainbindingscontroller's People

Contributors

carlbrown avatar drewish avatar gnyrd avatar jeffreyjackson avatar mralexgray avatar vtourraine avatar yosit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pdkeychainbindingscontroller's Issues

Tests Not Passing for iOS 8

Hello there, I'd like to get my app working for iOS 8 and it appears that while I can write to the keychain and read from it in the same run in the simulator, when I re-start my app from the simulator the value is missing.

This was not the case for the iOS 7.1 simulator.

After running your tests for iOS, the last test fails. Not sure if it's related, but here's the output to the tests.

2014-06-06 14:55:03.621 PDKeychainBindingsControlleriOSExample[11590:258171] SetAppThreadPriority: setpriority failed with error 45
Test Suite 'All tests' started at 2014-06-06 18:55:04 +0000
Test Suite '/Users/seenickcode/Library/Developer/Xcode/DerivedData/PDKeychainBindingsController-ckokylkdryveqzeykbsbwkqeawbn/Build/Products/Debug-iphonesimulator/PDKeychainBindingsControlleriOSExampleTests.octest(Tests)' started at 2014-06-06 18:55:04 +0000
Test Suite 'PDKeychainBindingsTest' started at 2014-06-06 18:55:04 +0000
Test Case '-[PDKeychainBindingsTest testStandardBindingsExists]' started.
Test Case '-[PDKeychainBindingsTest testStandardBindingsExists]' passed (0.000 seconds).
Test Case '-[PDKeychainBindingsTest testStandardBindingsTalksToKeychain]' started.
2014-06-06 14:55:04.227 PDKeychainBindingsControlleriOSExample[11590:258171] Could not store(Add) string. Error was:-34018
/Users/seenickcode/Desktop/PDKeychainBindingsController-master/PDKeychainBindingsControlleriOSExampleTests/PDKeychainBindingsTest.m:65: error: -[PDKeychainBindingsTest testStandardBindingsTalksToKeychain] : '0' should be equal to '4294933278': Failed to retrive data, status was '-34018'
/Users/seenickcode/Desktop/PDKeychainBindingsController-master/PDKeychainBindingsControlleriOSExampleTests/PDKeychainBindingsTest.m:68: error: -[PDKeychainBindingsTest testStandardBindingsTalksToKeychain] : '' should be equal to '9018C564-A3BA-44C8-AA20-65015A0E3561' retrieved string from keychain '' not equal to expected 'foo'
2014-06-06 14:55:04.230 PDKeychainBindingsControlleriOSExample[11590:258171] Could not store(Delete) string. Error was:-34018
Test Case '-[PDKeychainBindingsTest testStandardBindingsTalksToKeychain]' failed (0.005 seconds).
Test Case '-[PDKeychainBindingsTest testStandardBindingsWorksAtAll]' started.
2014-06-06 14:55:04.232 PDKeychainBindingsControlleriOSExample[11590:258171] Could not store(Add) string. Error was:-34018
2014-06-06 14:55:04.235 PDKeychainBindingsControlleriOSExample[11590:258171] Could not store(Delete) string. Error was:-34018
Test Case '-[PDKeychainBindingsTest testStandardBindingsWorksAtAll]' passed (0.005 seconds).
Test Suite 'PDKeychainBindingsTest' finished at 2014-06-06 18:55:04 +0000.
Executed 3 tests, with 2 failures (0 unexpected) in 0.010 (0.010) seconds
Test Suite '/Users/seenickcode/Library/Developer/Xcode/DerivedData/PDKeychainBindingsController-ckokylkdryveqzeykbsbwkqeawbn/Build/Products/Debug-iphonesimulator/PDKeychainBindingsControlleriOSExampleTests.octest(Tests)' finished at 2014-06-06 18:55:04 +0000.
Executed 3 tests, with 2 failures (0 unexpected) in 0.010 (0.011) seconds
Test Suite 'All tests' finished at 2014-06-06 18:55:04 +0000.
Executed 3 tests, with 2 failures (0 unexpected) in 0.010 (0.011) seconds

Thanks,

removeObjectForKey: gives "Could not store(Delete) string. Error was:-25300"

Calling

[[PDKeychainBindings sharedKeychainBindings] removeObjectForKey:@"myKey"];

returns

Could not store(Delete) string. Error was:-25300

While investigating it, I've found that this is a custom NSLog string, logged when the following operation fails:

OSStatus result=SecItemDelete((__bridge CFDictionaryRef)spec);
if (result!=0) {
    NSLog(@"Could not store(Delete) string. Error was:%i",(int)result);
}

The error code from OSStatus enum declared in <Security/SecBase.h>has this description:

errSecItemNotFound = -25300,  /* The specified item could not be found in the keychain. */

...which points out, that it's just the value being not found for respective key upon deleting.

Question

I wonder, what option here would be more preferable?

  1. I have to check for key existence, before attempting to delete it?
  2. The PDKeychainBindingsController has to have a fix to check the key, before deleting
  3. The PDKeychainBindingsController has to have a fix to make error codes processing and logging more accurate
  4. Ignore everything here (which was the way, it worked before this bug report was submitted)

Binding within nib

What is the best way to bind to the PDKeychainBindingsController within a nib? The example binds within code. Is there a simpler way then having a property point to the sharedKeychainBindingsController and binding to that within the nib? You could instantiate a PDKeychainBindingsController within the nib but then you could have multiple instances if you need access across different nibs.

CocoaPods?

Any chance of this being added? http://cocoapods.org/

Thanks for wrapping this up so conveniently! Adding it to CocoaPods would just add another level of convenience.

PDKeychain is not storing data in swift

Hi there,

I am trying to use the library with swift and objectiveC (mix & match).

Here is my code in the swift file

    var url:NSURL = NSURL(string: shopUrl.text)
    var secureStore: PDKeychainBindings = PDKeychainBindings()
    secureStore.setObject("url", forKey: "shopUrl")
    var usernameSecured:NSString = NSString(string: username.text)
     secureStore.setObject("usernameSecured", forKey: "username")
    var passwordSecured:NSString = NSString(string: password.text)
     secureStore.setObject("passwordSecured", forKey: "password")

Receiving an error "Could not store(Add) string. Error was:-34018". What would be the reason?

Thank you.

Not working in iOS 10?

This works great in iOS 9.x in latest stable Xcode(7.3.1). The problem happens when I start to run with iOS 10 beta with Xcode 8 beta 3.

For some reason, when I'm trying to read entries saved by [[PDKeychainBindings sharedKeychainBindings] objectForKey:@"my_key"] a nil is coming back instead of the expected saved object.

[[PDKeychainBindings sharedKeychainBindings] setObject:@"stringvalue" forKey:@"my_key"] is not reporting or causing any crashes.

`Synchronize` not supported.

Love this wrapper! I use CLANG macros to swap out the NSUserDefaults I was using with this instead; but, NSUserDefaults has a synchronize method that this does not have. For all I know it's necessary and would have no purpose for keychain, in which case I propose adding the method w/ no contents so that projects that swap defaults out for this will compile without error!

Remove all keychain data?

Hey man,

I love your keychain library. It's so easy to implement. I'm working on my first project with keychain and through testing I've realized that the keychain data lives on even though the app is deleted. I'm cache user info and I'm not keeping a list of users outside of the keychain so I don't have a list of keys. I want to delete all of the keychain data so I was expecting a "removeAll" or at least an "allKeys" method that I could use to wipe out the data.

I started looking at the code and realized it would take me a bit just to follow along and I thought it might be an easy add for you.

Just a thought. Thanks for the great work!

-M.

'Expression result unused' warning

I'm getting a warning:

PDKeychainBindingsController/PDKeychainBindingsController/PDKeychainBindingsController.m:131:13: Expression result unused

Which is coming from:

+ (PDKeychainBindingsController *)sharedKeychainBindingsController 
{
    @synchronized (self) {
        if (sharedInstance == nil) {
            [[self alloc] init]; // assignment not done here, see allocWithZone
        }
    }

    return sharedInstance;   
}

I get that the assignment happens over here:

+ (id)allocWithZone:(NSZone *)zone
{
    @synchronized(self) {
        if (sharedInstance == nil) {
            sharedInstance = [super allocWithZone:zone];
            return sharedInstance;  // assignment and return on first allocation
        }
    }

    return nil; //on subsequent allocation attempts return nil
}

Personally I think this is strange. Is there a specific reason for this pattern? Why not just do the assignment in the accessor method? At the very least we should just avoid the warning:

 // assignment not done here, see allocWithZone
__unused id unused = [[self alloc] init];

Crash, if request data very often

bildschirmfoto 2013-10-29 um 20 20 37

On app start, we really often ask the controller for data from the keychain. We then ran into EXC_BAD_ACESS. Do you have a clue how to solve this?

I expect that _valueBuffer is created two times in two threads and then it's tried to saving the data in the old _valueBuffer.

Do you have a clue? :)

Is this working on iOS 8?

Hi, I just have an app out there which has stopped working since iOS 8 release. :(

Google Analytics says that NSUnknownKeyException Trace: <redacted> <redacted> <redacted> -[DPEntity storeInKeychainWithPrefix:] -[BXUser populateFromKeychainOrWithDefaults] +[BX.... I was using -[PDKeychainBindings setString:forKey:] there. I was using a version from 2013 July, so the question is...

...were there any know issue with iOS 8 that is fixed in the most recent version of this repo?

Support for Touch ID Storage

It appears that you can store items in the keychain in such a way that when you ask for that item later, it shows the Touch ID prompt before giving you the value for that key. Is there any interest in adding support for Touch ID keychain values to this library?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.