apple_native_keyring_store/
lib.rs

1/*!
2
3# Apple native credential store
4
5This is a
6[keyring credential store provider](https://github.com/open-source-cooperative/keyring-rs/wiki/Keyring)
7that stores credentials in the native macOS and iOS secure stores.
8
9On iOS there is just one secure store: the "protected data" store.
10Its _items_ are stored in "access groups" associated with specific applications.
11
12On macOS there are two secure stores: the "legacy keychain" store and the "protected data" store.
13
14- The "legacy keychain" store is available to all applications, and its credentials are stored
15  in _keychain entries_ in encrypted files.
16- The "protected data" store is available to sandboxed applications
17  in macOS 10.15 (_Catalina_, 2019) or later. Some of its features are only available
18  to applications with provisioning profiles.
19
20Because the two native stores are different, this crate provides two different modules,
21one for each store. Choose the one that best suits your needs or use both. See the module
22documentation for the details of each store.
23
24## Features
25
26Each module has a feature that enables it. At least one relevant feature must be enabled,
27and both can be enabled.
28
29- `keychain`: Provides access to the "legacy keychain" store. Ignored on iOS.
30- `protected`: Provides access to the "protected data" store. Requires macOS 10.15 or later.
31
32This crate has no default features.
33
34 */
35
36#[cfg(all(
37    target_os = "macos",
38    not(any(feature = "keychain", feature = "protected"))
39))]
40compile_error!("At least one of the `keychain` or `protected` features must be enabled on macOS");
41
42#[cfg(all(target_os = "macos", feature = "keychain"))]
43pub mod keychain;
44
45#[cfg(all(target_os = "macos", feature = "keychain", not(feature = "protected")))]
46#[cfg(test)]
47mod keychain_test;
48
49#[cfg(all(target_os = "ios", not(feature = "protected")))]
50compile_error!("The `protected` feature is required on iOS");
51
52#[cfg(feature = "protected")]
53pub mod protected;