Skip to content

Commit 6b1d60f

Browse files
authored
fix(auth): allow to pass a Keychain storage without a service defined (#730)
1 parent 340d769 commit 6b1d60f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Sources/Auth/Internal/Keychain.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import Security
44

55
struct Keychain {
6-
let service: String
6+
let service: String?
77
let accessGroup: String?
88

99
init(
10-
service: String,
10+
service: String?,
1111
accessGroup: String? = nil
1212
) {
1313
self.service = service
@@ -55,8 +55,10 @@
5555
private func baseQuery(withKey key: String? = nil, data: Data? = nil) -> [String: Any] {
5656
var query: [String: Any] = [:]
5757
query[kSecClass as String] = kSecClassGenericPassword
58-
query[kSecAttrService as String] = service
5958

59+
if let service {
60+
query[kSecAttrService as String] = service
61+
}
6062
if let key {
6163
query[kSecAttrAccount as String] = key
6264
}

Sources/Auth/Storage/KeychainLocalStorage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
public struct KeychainLocalStorage: AuthLocalStorage {
66
private let keychain: Keychain
77

8-
public init(service: String = "supabase.gotrue.swift", accessGroup: String? = nil) {
8+
public init(service: String? = "supabase.gotrue.swift", accessGroup: String? = nil) {
99
keychain = Keychain(service: service, accessGroup: accessGroup)
1010
}
1111

0 commit comments

Comments
 (0)