Skip to content

Conversation

@PanArtemG
Copy link

Title

Extend provider API and fixed deprecated LocalAuthentication policies on macOS

Motivation

The LocalAuthentication provider protocol was limited in flexibility:
it did not allow explicit owner authentication setup, policy-based authentication, or retrieving the biometric type in the context of a specific policy.

Additionally, the LocalAuthentication API on macOS contains deprecated policy combinations that can lead to warnings and unclear behavior when evaluating authentication capabilities.

Modifications

  1. Extended LocalAuthenticationProviderProtocol.

  2. Fixed deprecated LAPolicy usage on macOS.

The provider protocol was expanded to support additional authentication scenarios and clearer separation of responsibilities.

New methods added:

setOwnerAuthentication(localizedReason:)

authenticate(with:localizedReason:)

getBiometricType(for:)

Result

  • Deprecated LocalAuthentication policies are no longer used on macOS
  • Authentication policy resolution is centralized and explicit
  • The provider API is more complete, extensible, and future-proof
  • Consumers can authenticate and query biometric capabilities based on specific policies
  • Overall, this improves API clarity, platform correctness, and long-term maintainability.

@PanArtemG PanArtemG requested review from AndriyVasyk and mcmikius and removed request for mcmikius January 20, 2026 09:38
@PanArtemG PanArtemG self-assigned this Jan 20, 2026
@PanArtemG PanArtemG added the enhancement New feature or request label Jan 20, 2026
@codecov
Copy link

codecov bot commented Jan 20, 2026

Codecov Report

❌ Patch coverage is 93.25843% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.46%. Comparing base (f848728) to head (1400f01).

Files with missing lines Patch % Lines
...ticationProvider/LocalAuthenticationProvider.swift 81.48% 5 Missing ⚠️
...lAuthenticationProvider/LAContext+Extensions.swift 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main       #6      +/-   ##
==========================================
- Coverage   97.01%   96.46%   -0.56%     
==========================================
  Files           6        7       +1     
  Lines         536      565      +29     
==========================================
+ Hits          520      545      +25     
- Misses         16       20       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@mcmikius mcmikius left a comment

Choose a reason for hiding this comment

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

Need improve implementation

}

/// Resolves the biometric type supported by the current context.
var resolvedBiometricType: BiometricType {
Copy link
Contributor

Choose a reason for hiding this comment

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

Чому не через switch case? Треба використати switch case

Copy link
Author

Choose a reason for hiding this comment

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

Зроблено через opticID

Ок, переробив

import LocalAuthentication

extension LocalAuthenticationPolicy {
var laPolicy: LAPolicy {
Copy link
Contributor

Choose a reason for hiding this comment

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

var policy: LAPolicy

Copy link
Author

Choose a reason for hiding this comment

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

ok

/// - Throws: An appropriate `LocalAuthenticationError` if an error occurs during authentication.
public func authenticate(with police: LocalAuthenticationPolicy, localizedReason: String) async throws -> Bool {
_ = try await checkBiometricAvailable(with: police)
guard context.biometryType != .none else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Не зрозумілий guard. Наскільки я розумію то none це що не має LA а в помилку виводиться що не розмізнано. Потрібно покращити обробку помилки.

Copy link
Author

Choose a reason for hiding this comment

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

реалізацію є скопійованою з поточної.

Замінено на biometryNotEnrolled в поточній і попередній реалізації

Copy link
Contributor

Choose a reason for hiding this comment

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

Ці зміни не дуже зрозумілі і глобальні.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ці зміни не дуже зрозумілі і глобальні.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants