flowchart TD
AuthViewModel -->|calls| AuthService
AuthService -->|uses| KeychainService
AuthService -->|uses| LocalAuthentication
AuthViewModel -.->|publishes| UIStates
A Swift-based authentication module for iOS that provides secure user login using password and biometric authentication (Face ID), with credential storage managed by the Keychain.
- User Registration & Login:
Supports first-time user registration and returning user login with password validation. - Biometric Authentication:
Integrates with iOS LocalAuthentication framework for Face ID login. - Keychain Integration:
Stores and manages user credentials securely in the device Keychain. - MVVM Architecture:
Uses a ViewModel for state management and logic separation. - Logout Support:
Provides logout functionality and user session management. - Test Coverage:
Includes integration and unit tests for authentication and keychain services.
Login/Service/AuthService.swift– Business logic for authentication and credential management.KeychainService.swift– Handles secure storage and retrieval of credentials.
Login/Protocol/AuthServiceProtocol.swift&KeychainServiceProtocol.swift– Protocol definitions for services.
Login/ViewModel/AuthViewModel.swift– Observable object for handling UI state and validation.
LoginTests/&LoginUITests/- Test cases for services and UI flows.
- AuthService:
Validates credentials, manages user registration, supports biometric authentication, and handles logout. - KeychainService:
Provides save, update, retrieve, and delete operations for credential data in the Keychain. - AuthViewModel:
Publishes authentication state and error messages, manages form validation and biometric support.
To check if biometric authentication is available and trigger it:
if viewModel.isBiometricsAvailable {
let result = try? authService.authenticateWithBiometrics()
// Handle result: true (authenticated), false (failed)
}This project includes unit and integration tests for all major components.
Run tests using Xcode's test navigator or with the following command:
xcodebuild test -scheme Login- iOS 18.5+
- Swift 5.6+
- Xcode 16+
MIT
Created by DAO, 2025