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

Split authenticationValidityDurationSeconds between android and iOS #77

Merged
merged 7 commits into from
May 21, 2024

Conversation

hpoul
Copy link
Collaborator

@hpoul hpoul commented Jul 18, 2022

  • Deprecated authenticationValidityDurationSeconds
  • Create androidAuthenticationValidityDuration
  • Create iosTouchIDAuthenticationAllowableReuseDuration
  • Create iosTouchIDAuthenticationForceReuseContextDuration

replaces

@CLAassistant
Copy link

CLAassistant commented Jul 18, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@luckyrat luckyrat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the option names are better now - it's probably still not what I would choose but that might be mainly down to a different opinion on how much abstraction this library should offer over the various native implementations so it's your opinion that matters.

I think the context expiry time needs adjustment but apart from that and those other minor suggestions this looks good to me.

I have also not had a chance to test it out yet and might not be able to find enough time to do that thoroughly for a little while but I'll try to at least build my project against the branch and test in some emulators in the next week or two.

@@ -74,8 +77,8 @@ class BiometricStorageFile(
}

private fun validateOptions() {
if (options.authenticationValidityDurationSeconds == -1 && !options.androidBiometricOnly) {
throw IllegalArgumentException("when authenticationValidityDurationSeconds is -1, androidBiometricOnly must be true")
if (options.androidAuthenticationValidityDuration == null && !options.androidBiometricOnly) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also validate that the user doesn't set androidAuthenticationValidityDuration to a negative number (especially since the similar old API gave special meaning to -1)?

? null
: Duration(seconds: authenticationValidityDurationSeconds));

@Deprecated('use androidAuthenticationValidityDuration instead')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At various times this has affected iOS behaviour too so maybe:
'use androidAuthenticationValidityDuration, iosTouchIDAuthenticationAllowableReuseDuration or iosTouchIDAuthenticationForceReuseContextDuration instead'

}

if let duration = initOptions.iosTouchIDAuthenticationForceReuseContextDuration {
_context = (context: context, expireAt: Date(timeIntervalSinceNow: Double(duration)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with assigning the expiry time when creating the context is that this will not reflect the actual time since successful keychain authentication occurred. That will be particularly noticeable any time a reasonably low (<30 seconds?) iosTouchIDAuthenticationForceReuseContextDuration is used and the user has to attempt authentication a number of times before the biometrics are confirmed.

@hpoul hpoul merged commit 0094e79 into main May 21, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants