Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SimpleKeychain to v1.0.0 & JWTDecode.swift to v3.0.0 #725

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ workflows:
matrix:
parameters:
platform: [ios, macos, tvos]
xcode: ["13.0.0", "12.5.1"]
xcode: ['13.0.0']
4 changes: 2 additions & 2 deletions Auth0.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ Pod::Spec.new do |s|
s.source_files = 'Auth0/*.swift'
s.swift_versions = ['5.3', '5.4', '5.5']

s.dependency 'SimpleKeychain', '~> 0.12'
s.dependency 'JWTDecode', '~> 2.0'
s.dependency 'SimpleKeychain', '~> 1.0'
s.dependency 'JWTDecode', '~> 3.0'

s.ios.deployment_target = '12.0'
s.ios.exclude_files = macos_files
Expand Down
4 changes: 2 additions & 2 deletions Auth0/CredentialsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public struct CredentialsManager {
/// - Parameters:
/// - authentication: Auth0 Authentication API client.
/// - storeKey: Key used to store user credentials in the Keychain. Defaults to 'credentials'.
/// - storage: The ``CredentialsStorage`` instance used to manage credentials storage. Defaults to a standard `A0SimpleKeychain` instance.
public init(authentication: Authentication, storeKey: String = "credentials", storage: CredentialsStorage = A0SimpleKeychain()) {
/// - storage: The ``CredentialsStorage`` instance used to manage credentials storage. Defaults to a standard `SimpleKeychain` instance.
public init(authentication: Authentication, storeKey: String = "credentials", storage: CredentialsStorage = SimpleKeychain()) {
self.storeKey = storeKey
self.authentication = authentication
self.storage = storage
Expand Down
25 changes: 22 additions & 3 deletions Auth0/CredentialsStorage.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import SimpleKeychain
import Foundation

/// Generic storage API for storing credentials.
public protocol CredentialsStorage {
Expand All @@ -25,14 +26,14 @@ public protocol CredentialsStorage {

}

extension A0SimpleKeychain: CredentialsStorage {
extension SimpleKeychain: CredentialsStorage {

/// Retrieves a storage entry.
///
/// - Parameter key: The key to get from the Keychain.
/// - Returns: The stored data.
public func getEntry(forKey key: String) -> Data? {
return data(forKey: key)
return try? self.data(forKey: key)
}

/// Sets a storage entry.
Expand All @@ -42,7 +43,25 @@ extension A0SimpleKeychain: CredentialsStorage {
/// - key: The key to store it to.
/// - Returns: If the data was stored.
public func setEntry(_ data: Data, forKey key: String) -> Bool {
return setData(data, forKey: key)
do {
try self.set(data, forKey: key)
return true
} catch {
return false
}
}

/// Deletes a storage entry.
///
/// - Parameter key: The key to delete from the Keychain.
/// - Returns: If the data was deleted.
public func deleteEntry(forKey key: String) -> Bool {
do {
try self.deleteItem(forKey: key)
return true
} catch {
return false
}
}

}
7 changes: 4 additions & 3 deletions Auth0Tests/CredentialsManagerSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -774,17 +774,18 @@ class CredentialsManagerSpec: QuickSpec {
}

context("custom keychain") {
let storage = A0SimpleKeychain(service: "test_service")
let storage = SimpleKeychain(service: "test_service")

beforeEach {
credentialsManager = CredentialsManager(authentication: authentication,
storage: storage)
}

it("custom keychain should successfully set and clear credentials") {
_ = credentialsManager.store(credentials: credentials)
expect(storage.data(forKey: "credentials")).toNot(beNil())
expect { try storage.data(forKey: "credentials") }.toNot(beNil())
_ = credentialsManager.clear()
expect(storage.data(forKey: "credentials")).to(beNil())
expect { try storage.data(forKey: "credentials") }.to(throwError(SimpleKeychainError.itemNotFound))
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "auth0/SimpleKeychain" ~> 0.12
github "auth0/JWTDecode.swift" ~> 2.0
github "auth0/SimpleKeychain" ~> 1.0
github "auth0/JWTDecode.swift" ~> 3.0
4 changes: 2 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github "AliSoftware/OHHTTPStubs" "9.1.0"
github "Quick/Nimble" "v10.0.0"
github "Quick/Quick" "v5.0.1"
github "auth0/JWTDecode.swift" "2.6.3"
github "auth0/SimpleKeychain" "0.12.5"
github "auth0/JWTDecode.swift" "3.0.0"
github "auth0/SimpleKeychain" "1.0.0"
2 changes: 1 addition & 1 deletion FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Auth0

Note that with `useEphemeralSession()` you don't need to call `clearSession(federated:)` at all. Just clearing the credentials from the app will suffice. What `clearSession(federated:)` does is clear the shared session cookie, so that in the next login call the user gets asked to log in again. But with `useEphemeralSession()` there will be no shared cookie to remove.

> ⚠️ `useEphemeralSession()` relies on the `prefersEphemeralWebBrowserSession` configuration option of `ASWebAuthenticationSession`. This option is only available on [iOS 13+](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/3237231-prefersephemeralwebbrowsersessio), so `useEphemeralSession()` will have no effect on iOS 12. To improve the experience for iOS 12 users, see the approach described below.
> ⚠️ `useEphemeralSession()` relies on the `prefersEphemeralWebBrowserSession` configuration option of `ASWebAuthenticationSession`. This option is only available on [iOS 13+ and macOS](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/3237231-prefersephemeralwebbrowsersessio), so `useEphemeralSession()` will have no effect on iOS 12. To improve the experience for iOS 12 users, see the approach described below.

An alternative is to use `SFSafariViewController` instead of `ASWebAuthenticationSession`. You can do so with the built-in `SFSafariViewController` Web Auth provider:

Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ let package = Package(
platforms: [.iOS(.v12), .macOS(.v10_15), .tvOS(.v12), .watchOS("6.2")],
products: [.library(name: "Auth0", targets: ["Auth0"])],
dependencies: [
.package(name: "SimpleKeychain", url: "https://github.com/auth0/SimpleKeychain.git", .upToNextMajor(from: "0.12.0")),
.package(name: "JWTDecode", url: "https://github.com/auth0/JWTDecode.swift.git", .upToNextMajor(from: "2.5.0")),
.package(name: "SimpleKeychain", url: "https://github.com/auth0/SimpleKeychain.git", .upToNextMajor(from: "1.0.0")),
.package(name: "JWTDecode", url: "https://github.com/auth0/JWTDecode.swift.git", .upToNextMajor(from: "3.0.0")),
.package(name: "Quick", url: "https://github.com/Quick/Quick.git", .upToNextMajor(from: "5.0.0")),
.package(name: "Nimble", url: "https://github.com/Quick/Nimble.git", .upToNextMajor(from: "10.0.0")),
.package(name: "OHHTTPStubs", url: "https://github.com/AliSoftware/OHHTTPStubs.git", .upToNextMajor(from: "9.0.0"))
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Easily integrate Auth0 into iOS, macOS, tvOS, and watchOS apps. Add **login** an
## Requirements

- iOS 12+ / macOS 10.15+ / tvOS 12.0+ / watchOS 6.2+
- Xcode 12.x / 13.x
- Xcode 13.x / 14.x
- Swift 5.3+

> ⚠️ Check the [Support Policy](#support-policy) to learn when dropping Xcode, Swift, and platform versions will not be considered a **breaking change**.
Expand Down