Skip to content

Conversation

@subhankarmaiti
Copy link
Contributor

This PR introduces configurable biometric authentication policies for CredentialsManager, allowing developers to control when biometric prompts are shown. This reduces authentication friction while maintaining security.

New Features:

  • BiometricPolicy enum with three strategies: .always, .session(timeoutInSeconds:), .appLifecycle(timeoutInSeconds:)
  • isBiometricSessionValid() - Check session validity
  • clearBiometricSession() - Manually invalidate session
  • Thread-safe session management using NSLock

Files Modified:

  • New: Auth0/BiometricPolicy.swift
  • Modified: Auth0/CredentialsManager.swift, Auth0/BioAuthentication.swift
  • New: Auth0Tests/BiometricPolicySpec.swift (33 test cases)
  • Updated: EXAMPLES.md, sample app with policy demonstrations

References

Usage Examples

Always Policy (Default)

credentialsManager.enableBiometrics(withTitle: "Unlock with Face ID")

Session Policy

credentialsManager.enableBiometrics(
    withTitle: "Unlock with Face ID",
    policy: .session(timeoutInSeconds: 300)
)

App Lifecycle Policy

credentialsManager.enableBiometrics(
    withTitle: "Unlock with Face ID",
    policy: .appLifecycle() // Default: 3600 seconds
)

Manual Session Management

// Check validity
let isValid = credentialsManager.isBiometricSessionValid()

// Force re-authentication
CredentialsManager.clearBiometricSession()

Migration Guide

No breaking changes. Existing code works unchanged:

// Before and After - no changes needed
credentialsManager.enableBiometrics(withTitle: "Unlock")

Opt into new policies:

// Session-based authentication
credentialsManager.enableBiometrics(
    withTitle: "Unlock", 
    policy: .session(timeoutInSeconds: 300)
)

// Clear on background (optional)
func applicationDidEnterBackground(_ application: UIApplication) {
    CredentialsManager.clearBiometricSession()
}

Checklist

  • Matches design document and Android PR Release 2.9.0 #867
  • 33 new test cases added and passing
  • Documentation updated (EXAMPLES.md)
  • Sample app demonstrates all policies
  • Thread-safe implementation
  • Backward compatible
  • No breaking changes

…ents and update CredentialsManager to support it
@subhankarmaiti subhankarmaiti requested a review from a team as a code owner November 16, 2025 11:29
Copy link
Contributor

@NandanPrabhu NandanPrabhu left a comment

Choose a reason for hiding this comment

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

NandanPrabhu
NandanPrabhu previously approved these changes Nov 19, 2025
@subhankarmaiti subhankarmaiti merged commit 4d9fe7b into master Nov 25, 2025
11 of 12 checks passed
@subhankarmaiti subhankarmaiti deleted the SDK-6524-biometric-policy branch November 25, 2025 05:11
NandanPrabhu added a commit that referenced this pull request Nov 27, 2025
* master:
  feat: Add configurable biometric authentication policies for CredentialsManager (#1019)
  Support a new offering from Auth0 #1021 (#1024)
  Bump actions/checkout from 5 to 6 (#1023)
  chore: added snyk scan workflow (#1025)
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