-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(auth): adding support for keychain sharing using app groups (#3947)
* feat(Auth) Keychain Sharing (App Reload Required) * Remove migrateKeychainItemsOfUserSession bool from SecureStoragePreferences * Reconfigure when fetching auth session if sharing keychain * Update API dumps for new version * Indentation, clean up, and batch migration to avoid inconsistent state * Update API dumps for new version * Addressing review comments: documentation, no more credentials valid check, only delete items if absolutely necessary * Style fixes --------- Co-authored-by: Yaro Luchko <yaluchko@amazon.com> Co-authored-by: aws-amplify-ops <aws-amplify@amazon.com>
- Loading branch information
1 parent
695039d
commit f15cc45
Showing
23 changed files
with
1,341 additions
and
2,070 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import Foundation | ||
|
||
/// A structure representing an access group for managing keychain items. | ||
public struct AccessGroup { | ||
/// The name of the access group. | ||
public let name: String? | ||
|
||
/// A flag indicating whether to migrate keychain items. | ||
public let migrateKeychainItems: Bool | ||
|
||
/** | ||
Initializes an `AccessGroup` with the specified name and migration option. | ||
|
||
- Parameter name: The name of the access group. | ||
- Parameter migrateKeychainItemsOfUserSession: A flag indicating whether to migrate keychain items. Defaults to `false`. | ||
*/ | ||
public init(name: String, migrateKeychainItemsOfUserSession: Bool = false) { | ||
self.init(name: name, migrateKeychainItems: migrateKeychainItemsOfUserSession) | ||
} | ||
|
||
/** | ||
Creates an `AccessGroup` instance with no specified name. | ||
|
||
- Parameter migrateKeychainItemsOfUserSession: A flag indicating whether to migrate keychain items. | ||
- Returns: An `AccessGroup` instance with the migration option set. | ||
*/ | ||
public static func none(migrateKeychainItemsOfUserSession: Bool) -> AccessGroup { | ||
return .init(migrateKeychainItems: migrateKeychainItemsOfUserSession) | ||
} | ||
|
||
/** | ||
A static property representing an `AccessGroup` with no name and no migration. | ||
|
||
- Returns: An `AccessGroup` instance with no name and the migration option set to `false`. | ||
*/ | ||
public static var none: AccessGroup { | ||
return .none(migrateKeychainItemsOfUserSession: false) | ||
} | ||
|
||
private init(name: String? = nil, migrateKeychainItems: Bool) { | ||
self.name = name | ||
self.migrateKeychainItems = migrateKeychainItems | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...Plugins/Auth/Sources/AWSCognitoAuthPlugin/Models/AWSCognitoSecureStoragePreferences.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import Foundation | ||
import Amplify | ||
|
||
/// A struct to store preferences for how the plugin uses storage | ||
public struct AWSCognitoSecureStoragePreferences { | ||
|
||
/// The access group that the keychain will use for auth items | ||
public let accessGroup: AccessGroup? | ||
|
||
/// Creates an intstance of AWSCognitoSecureStoragePreferences | ||
/// - Parameters: | ||
/// - accessGroup: access group to be used | ||
public init(accessGroup: AccessGroup? = nil) { | ||
self.accessGroup = accessGroup | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.