Latest 0.9.0
Homepage https://github.com/auth0/SimpleKeychain
License MIT
Platforms ios 9.0, osx 10.11, watchos 2.0, tvos 9.0, requires ARC
Authors ,

CircleCI
Version
License
Platform
Carthage compatible

A wrapper to make it really easy to deal with iOS Keychain and store your user’s credentials securely.

Key Features

  • Simple interface to store user’s credentials (e.g. JWT) in the Keychain.
  • Store credentials under an Access Group to enable Keychain Sharing.
  • Support for iOS 8 Access Control for fine grained access control.
  • TouchID and Keychain integration with iOS 8 new accessibility field kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly.

Requirements

  • iOS 9.0+ / macOS 10.11+ / tvOS 9.0+ / watchOS 2.0+
  • Xcode 10.x
  • Swift 4.x/5.x

Installation

CocoaPods

SimpleKeychain is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "SimpleKeychain"

Carthage

In your Cartfile add

github "auth0/SimpleKeychain"

Before Getting Started

Swift

Import Lock module in your swift file:

import SimpleKeychain

Usage

Save a JWT token or password

let jwt = //user's JWT token obtained after login
A0SimpleKeychain().setString(jwt, forKey:"auth0-user-jwt")

Obtain a JWT token or password

let jwt = A0SimpleKeychain().string(forKey: "auth0-user-jwt")

Share JWT Token with other apps using iOS Access Group

let jwt = //user's JWT token obtained after login
let keychain = A0SimpleKeychain(service: "Auth0", accessGroup: "ABCDEFGH.com.mydomain.myaccessgroup")
keychain.setString(jwt, forKey:"auth0-user-jwt")

Store and retrieve JWT token using TouchID and Keychain AcessControl attribute (iOS 8 Only).

Let’s save the JWT first:

let jwt = //user's JWT token obtained after login
let keychain = A0SimpleKeychain()
keychain.useAccessControl = true
keychain.defaultAccessiblity = .whenPasscodeSetThisDeviceOnly
keychain.setString(jwt, forKey:"auth0-user-jwt")

If there is an existent value under the key auth0-user-jwt saved with AccessControl and A0SimpleKeychainItemAccessibleWhenPasscodeSetThisDeviceOnly, iOS will prompt the user to enter their passcode or fingerprint before updating the value.

Then let’s obtain the value

let message = NSLocalizedString("Please enter your passcode/fingerprint to login with awesome App!.", comment: "Prompt TouchID message")
let keychain = A0SimpleKeychain()
let jwt = keychain.string(forKey: "auth0-user-jwt", promptMessage:message)

Remove a JWT token or password

A0SimpleKeychain().deleteEntry(forKey: "auth0-user-jwt")

Contributing

Just clone the repo, and run pod install from the Example directory and you’re ready to contribute!

Issue Reporting

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.

License

SimpleKeychain is available under the MIT license. See the LICENSE file for more info.

Author

Auth0

What is Auth0?

Auth0 helps you to:

  • Add authentication with multiple authentication sources, either social like Google, Facebook, Microsoft Account, LinkedIn, GitHub, Twitter, Box, Salesforce, amont others, or enterprise identity systems like Windows Azure AD, Google Apps, Active Directory, ADFS or any SAML Identity Provider.
  • Add authentication through more traditional username/password databases.
  • Add support for linking different user accounts with the same user.
  • Support for generating signed Json Web Tokens to call your APIs and flow the user identity securely.
  • Analytics of how, when and where users are logging in.
  • Pull data from other sources and add it to the user profile, through JavaScript rules.

Create a free account in Auth0

  1. Go to Auth0 and click Sign Up.
  2. Use Google, GitHub or Microsoft Account to login.

Latest podspec

{
    "name": "SimpleKeychain",
    "version": "0.9.0",
    "summary": "A wrapper to make it really easy to deal with iOS Keychain and store your user's credentials securely.",
    "description": "A simple way to store items in iOS Keychain, without the hassle of dealing with iOS Keychain API directly.nIt has support for the new AccessControl for Keychain items added in iOS 8.",
    "homepage": "https://github.com/auth0/SimpleKeychain",
    "license": "MIT",
    "authors": {
        "Auth0": "[email protected]",
        "Hernan Zalazar": "[email protected]"
    },
    "source": {
        "git": "https://github.com/auth0/SimpleKeychain.git",
        "tag": "0.9.0"
    },
    "social_media_url": "https://twitter.com/auth0",
    "platforms": {
        "ios": "9.0",
        "osx": "10.11",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "requires_arc": true,
    "source_files": "SimpleKeychain/*.{h,m}"
}

Pin It on Pinterest

Share This