stanfordspezi/speziaccessguard
This source file is part of the Stanford Spezi open-source project.
Overview
Enforce code or biometrics-guarded access to SwiftUI views.
For more information, please refer to the API documentation.
Setup
You need to add the SpeziAccessGuard Swift package to your app in Xcode or Swift package.
[!IMPORTANT] If your application is not yet configured to use Spezi, follow the Spezi setup article to set up the core Spezi infrastructure.
Usage
You use the `AccessGuards` module to define your app's access guards, as part of the overall Spezi configuration:
import Spezi
import SpeziAccessGuard
class ExampleDelegate: SpeziAppDelegate {
override var configuration: Configuration {
Configuration {
AccessGuards {
CodeAccessGuard(.transactions)
BiometricAccessGuard(.accountInfo)
CodeAccessGuard(.hiddenFeature, fixed: "7184")
}
}
}
}
extension AccessGuardIdentifier where AccessGuard == CodeAccessGuard {
static let transactions: Self = .passcode("com.myApp.transactions")
static let hiddenFeature: Self = .passcode("com.myApp.hiddenFeature")
}
extension AccessGuardIdentifier where AccessGuard == BiometricAccessGuard {
static let accountInfo: Self = .passcode("com.myApp.accountInfo")
}You then can use these Access Guards in your app, e.g. via the `AccessGuarded` view, which automatically manages the presentation and unlocking of the access guard for you:
var body: some View {
TabView {
// ...
Tab("Account", systemImage: "person.circle") {
AccessGuarded(.accountInfo) {
AccountTab()
}
}
}
}For more information, please refer to the API documentation.
Contributing
Contributions to this project are welcome. Please make sure to read the contribution guidelines and the contributor covenant code of conduct first.
License
This project is licensed under the MIT License. See Licenses for more information.
[Spezi Footer] [Spezi Footer]
Package Metadata
Repository: stanfordspezi/speziaccessguard
Default branch: main
README: README.md