Name: SimpleKeychain
Owner: Auth0
Description: A Keychain helper for iOS to make it very simple to store/obtain values from iOS Keychain
Created: 2014-10-16 21:53:59.0
Updated: 2018-01-15 07:11:49.0
Pushed: 2017-07-14 21:40:24.0
Size: 358
Language: Objective-C
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A wrapper to make it really easy to deal with iOS Keychain and store your user's credentials securely.
kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly
. (Only for iOS 8+)At least iOS 7, if you want to use kSecAttrAccessControl
with the flag useAccessControl
you need to have iOS 8+.
SimpleKeychain is available through CocoaPods. To install it, simply add the following line to your Podfile:
"SimpleKeychain"
Or you can add A0SimpleKeychain.h
and A0SimpleKeychain.m
to your project.
In your Cartfile add
ub "auth0/SimpleKeychain"
Just import in your source file's header:
ort <SimpleKeychain/SimpleKeychain.h>
Import Lock module in your swift file:
rt SimpleKeychain
ring *jwt = //user's JWT token obtained after login
SimpleKeychain keychain] setString:jwt forKey:@"auth0-user-jwt"];
wift
jwt = //user's JWT token obtained after login
mpleKeychain().setString(jwt, forKey:"auth0-user-jwt")
ring *jwt = [[A0SimpleKeychain keychain] stringForKey:@"auth0-user-jwt"];
wift
jwt = A0SimpleKeychain().string(forKey: "auth0-user-jwt")
ring *jwt = //user's JWT token obtained after login
mpleKeychain *keychain = [A0SimpleKeychain keychainWithService:@"Auth0" accessGroup:@"ABCDEFGH.com.mydomain.myaccessgroup"];
chain setString:jwt forKey:@"auth0-user-jwt"];
wift
jwt = //user's JWT token obtained after login
keychain = A0SimpleKeychain(service: "Auth0", accessGroup: "ABCDEFGH.com.mydomain.myaccessgroup")
hain.setString(jwt, forKey:"auth0-user-jwt")
Let's save the JWT first:
ring *jwt = //user's JWT token obtained after login
mpleKeychain *keychain = [A0SimpleKeychain keychain];
hain.useAccessControl = YES;
hain.defaultAccessiblity = A0SimpleKeychainItemAccessibleWhenPasscodeSetThisDeviceOnly;
chain setString:jwt forKey:@"auth0-user-jwt"];
wift
jwt = //user's JWT token obtained after login
keychain = A0SimpleKeychain()
hain.useAccessControl = true
hain.defaultAccessiblity = .whenPasscodeSetThisDeviceOnly
hain.setString(jwt, forKey:"auth0-user-jwt")
If there is an existent value under the key
auth0-user-jwt
saved with AccessControl andA0SimpleKeychainItemAccessibleWhenPasscodeSetThisDeviceOnly
, iOS will prompt the user to enter their passcode or fingerprint before updating the value.
Then let's obtain the value
ring *message = NSLocalizedString(@"Please enter your passcode/fingerprint to login with awesome App!.", @"Prompt TouchID message");
mpleKeychain *keychain = [A0SimpleKeychain keychain];
ring *jwt = [keychain stringForKey:@"auth0-user-jwt" promptMessage:message];
wift
message = NSLocalizedString("Please enter your passcode/fingerprint to login with awesome App!.", comment: "Prompt TouchID message")
keychain = A0SimpleKeychain()
jwt = keychain.string(forKey: "auth0-user-jwt", promptMessage:message)
SimpleKeychain keychain] deleteEntryForKey:@"auth0-user-jwt"];
wift
mpleKeychain().deleteEntry(forKey: "auth0-user-jwt")
Just clone the repo, and run pod install from the Example directory and you're ready to contribute!.
If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.
SimpleKeychain is available under the MIT license. See the [LICENSE file](LICENSE file) for more info.
Auth0 helps you to: