Swiftpack.co - auth0/Lock.swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by auth0.
auth0/Lock.swift 2.24.1
A Swift & iOS framework to authenticate using Auth0 and with a Native Look & Feel
⭐️ 249
🕓 1 year ago
iOS
.package(url: "https://github.com/auth0/Lock.swift.git", from: "2.24.1")

Lock.swift

Version CircleCI Coverage Status License

📚 Documentation • 🚀 Getting Started • 💬 Feedback

Migrating from v1? Check the Migration Guide.

Documentation

Getting Started

Requirements

  • iOS 9+
  • Xcode 13.x / 14.x
  • Swift 4.x / 5.x

Lock.swift uses Auth0.swift 1.x.

Installation

Cocoapods

Add the following line to your Podfile:

pod "Lock", "~> 2.24"

Then, run pod install.

Carthage

Add the following line to your Cartfile:

github "auth0/Lock.swift" ~> 2.24

Then, run carthage bootstrap --use-xcframeworks --platform iOS.

Swift Package Manager

Open the following menu item in Xcode:

File > Add Packages...

In the Search or Enter Package URL search box enter this URL:

https://github.com/auth0/Lock.swift

Then, select the dependency rule and press Add Package.

Configure the SDK

Head to the Auth0 Dashboard and create a new Native application.

Lock.swift needs the Client ID and Domain of the Auth0 application to communicate with Auth0. You can find these details in the settings page of your Auth0 application. If you are using a custom domain, use the value of your custom domain instead of the value from the settings page.

Configure Client ID and Domain with a plist

Create a plist file named Auth0.plist in your app bundle with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>ClientId</key>
    <string>YOUR_AUTH0_CLIENT_ID</string>
    <key>Domain</key>
    <string>YOUR_AUTH0_DOMAIN</string>
</dict>
</plist>

Configure Client ID and Domain programmatically

For Classic Lock
Lock
    .classic(clientId: "YOUR_AUTH0_CLIENT_ID", domain: "YOUR_AUTH0_DOMAIN")
    // ...
For Passwordless Lock
Lock
    .passwordless(clientId: "YOUR_AUTH0_CLIENT_ID", domain: "YOUR_AUTH0_DOMAIN")
    // ...

Configure your app

Make sure Lock.swift can receive callback URLs.

Using the UIKit app lifecycle
// AppDelegate.swift

import Lock

// ...

func application(_ app: UIApplication,
                 open url: URL,
                 options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool {
    return Lock.resumeAuth(url, options: options)
}
Using the UIKit app lifecycle with Scenes
// SceneDelegate.swift

import Lock

// ...

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
    guard let url = URLContexts.first?.url else { return }
    Lock.resumeAuth(url, options: [:])
}

Next steps

Learn how to use Lock.swift in Examples ↗

  • Lock Classic - handles authentication using Database, Social, and Enterprise connections.
  • Lock Passwordless - handles authentication using Passwordless and Social connections.

Feedback

Contributing

We appreciate feedback and contribution to this repo! Before you get started, please see the following:

Raise an issue

To provide feedback or report a bug, please raise an issue on our issue tracker.

Vulnerability reporting

Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.


Auth0 Logo

Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout Why Auth0?

This project is licensed under the MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 249
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

2.24.1
1 year ago

Fixed

  • Add Carthage/Build to the frameworks search path #690 (Widcket)

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics