Registering a user for a MIRACL Trust project provisions user identity data (including the cryptographic client token) and is required for each app by default, unless the user storage is shared between your apps on the same device. To configure shared user storage so users can register once and authenticate across your apps, follow the instructions below.
# iOS
In the MIRACL Trust iOS SDK, you can share a user’s registration across multiple apps by configuring user storage to use a shared location. The default user storage in the MIRACL Trust iOS SDK is an encrypted SQLite database. Its encryption key is stored in the Keychain, and the database file location is configurable.
Note: This configuration applies only to newly created user storages. If your application already has an existing user storage, you must manually migrate the database file and Keychain entry to the shared container before applying this configuration.
To configure shared user storage, complete the following steps:
Enable the following two capabilities in Xcode for all targets that need access, using the same identifiers across all of them:
Note: When configuring Keychain Sharing in Xcode, enter only your
<KEYCHAIN_ACCESS_GROUP_IDENTIFIER>in the capability settings. Xcode automatically prepends your Team ID. In your Swift code you must include the full<TEAM_ID>.<KEYCHAIN_ACCESS_GROUP_IDENTIFIER>string.When initializing the SDK, pass the App Group container URL and Keychain access group to the configuration builder using the configureDefaultUserStorage method from the Configuration.Builder class:
let projectId = "<YOUR_PROJECT_ID>" let projectURL = "<YOUR_PROJECT_URL>" let applicationGroupIdentifier = "group.<SHARED_GROUP_IDENTIFIER>" guard let sharedGroupContainerURL = FileManager.default.containerURL( forSecurityApplicationGroupIdentifier: applicationGroupIdentifier ) else { // Handle missing App Group container return } let keychainAccessGroup = "<TEAM_ID>.<KEYCHAIN_ACCESS_GROUP_IDENTIFIER>" do { let configuration = try Configuration .Builder(projectId: projectId, projectURL: projectURL) .configureDefaultUserStorage { options in options.directoryURL = sharedGroupContainerURL options.keychainAccessGroup = keychainAccessGroup } .build() try MIRACLTrust.configure(with: configuration) } catch { // Handle configuration errors if any }
Additionally the MIRACL Trust iOS SDK supports custom user storage implementations. To use custom storage, conform to the UserStorage protocol and implement it to share storage between applications or extensions from the same developer. To attach the custom storage to the configuration, use the userStorage(userStorage:) method in the Configuration.Builder class.