🧪
Multi-user (beta)
Use Keyless to authenticate many users on a shared, non-trusted device.
Different Keyless users can use their Keyless account(s) on the same device.
The user is identified by user information stored in a "blob":
UserInfo
. You can see the UserInfo
blob as a snapshot of the Keyless SDK for the current user.You can decide to populate the Keyless SDK with the
UserInfo
that you retrieved in the past from the Keyless SDK. You are responsible to store the
UserInfo
securely in your application or elsewhere in a custom vault. You can retrieve the
UserInfo
either during the enrollment or during the authentication by adding the retrievingUserInfo
parameter to the EnrollmentConfiguration
or the AuthenticationConfiguration
builders.The
EnrollmentSuccess
or the AuthenticationSuccess
will contain an optional parameter userInfo
that is a valid json containing the Keyless SDK snapshot for the current user. Below you can find an example on how to retrieve the user information during an authentication:
Android
iOS
val configuration = AuthenticationConfiguration.builder
.retrievingUserInfo()
.build()
Keyless.authenticate(
authenticationConfiguration = configuration,
onCompletion = { result ->
when (result) {
is Keyless.KeylessResult.Success -> Log.d("KeylessSDK ", "Authentication success - userInfo = ${result.userInfo}")
is Keyless.KeylessResult.Failure -> Log.d("KeylessSDK ", "Authentication failure - error code ${result.error.code}")
}
}
)
let configuration = Keyless.AuthenticationConfiguration.builder
.retrievingUserInfo()
.build()
Keyless.authenticate(
authenticationConfiguration: configuration,
onCompletion: { result in
switch result {
case .success(let success):
print(success.userInfo)
case .failure(let error):
break
}
})
To swap from a user to another you can set the user information using the
setUserInfo(userInfo:String)
. After this call the SDK will be configured to perform all operations on the provided user extracted from the userInfo
json string provided as parameter.If you never call
setUserInfo
the Keyless SDK behaves as if there is only one default user.Below is an example to set the user information from a
UserInfo
blob that you retrieved in the past from the Keyless SDK:Android
iOS
Keyless.setUserInfo(
userInfo = userInfo,
onCompletion = { result ->
when (result) {
is Keyless.KeylessResult.Success -> Log.d("KeylessSDK ", "User set succcessfully")
is Keyless.KeylessResult.Failure -> Log.d("KeylessSDK ", "Set userInfo failure - error code ${result.error.code}")
}
}
)
if let error = Keyless.setUserInfo(userInfo: userInfo) {
print("Keyless.setUserInfo failed with error: \(error)")
}
Last modified 6mo ago