Requirements
- iOS 9+
- Xcode 11.4+ / 12.x
- Swift 4.x / 5.x
Install
Cocoapods
If you are using Cocoapods, add this line to yourPodfile
:
pod 'Lock', '~> 2.0'
Then run pod install
.
For more information on Cocoapods, check their official documentation.
Carthage
If you are using Carthage, add the following line to yourCartfile
:
github "auth0/Lock.swift" ~> 2.0
Then run carthage bootstrap
.
For more information about Carthage usage, check their official documentation.
SPM
If you are using the Swift Package Manager, open the following menu item in Xcode: File > Swift Packages > Add Package Dependency… In the Choose Package Repository prompt add this url:https://github.com/auth0/Lock.swift.git
Then press Next and complete the remaining steps.
For further reference on SPM, check the official documentation.
Set up
Integrate with your Application
Lock needs to be notified when the application is asked to open a URL. You can do this in theAppDelegate
file.
Import Lock
Import Lock wherever you’ll need itimport lock
Auth0 Credentials
In order to use Lock you need to provide your Auth0 and Domain, which can be found in your Auth0 Dashboard, under your Application’s settings. In your application bundle you can add aplist
file named Auth0.plist
that will include your credentials with the following format.
Implementation of Lock Classic
Lock Classic handles authentication using Database, Social, and Enterprise connections.OIDC Conformant Mode
It is strongly encouraged that this SDK be used in OIDC Conformant mode. When this mode is enabled, it will force the SDK to use Auth0’s current authentication pipeline and will prevent it from reaching legacy endpoints. By default this isfalse
Use Auth0.Swift Library to access user profile
To access user profile information, you will need to use theAuth0.Swift
library:
Specify Connections
Lock will automatically load the connections configured for your application. If you wish to override the default behavior, you can manually specify which connections it should display to users as authentication options. This can be done by calling the method and supplying a closure that can specify the connection(s). Adding a database connection:Styling and Customization
Lock provides many styling options to help you apply your own brand identity to Lock usingwithStyle
. For example, changing the primary color and header text of your Lock widget:
Customize your title, logo, and primary color
Configuration Options
There are numerous options to configure Lock’s behavior. Below is an example of Lock configured to allow it to be closable, to limit it to only usernames (and not emails), and to only show the Login and Reset Password screens.Password Manager Support
By default, password manager support using 1Password is enabled for database connections. 1Password support will still require the user to have the 1Password app installed for the option to be visible in the login and signup screens. You can disable 1Password support using the enabled property of the passwordManager.appIdentifier
will be set to the app’s bundle identifier and the displayName
will be set to the app’s display name. You can customize these as follows:
info.plist
: