Skip to content

Commit 4ca88dc

Browse files
Merge pull request #199 from brotskydotcom/doc-fixes
Update the README for known platform issues. This will be version 3.0.5
2 parents 47c8daf + 0eb5eeb commit 4ca88dc

File tree

5 files changed

+56
-78
lines changed

5 files changed

+56
-78
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ keywords = ["password", "credential", "keychain", "keyring", "cross-platform"]
66
license = "MIT OR Apache-2.0"
77
name = "keyring"
88
repository = "https://github.com/hwchen/keyring-rs.git"
9-
version = "3.0.4"
9+
version = "3.0.5"
1010
rust-version = "1.75"
1111
edition = "2021"
1212
exclude = [".github/"]

README.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,23 @@ To enable the stores you want, you use features: there is one feature for each p
6565

6666
If you don't enable any credential stores that are supported on a specific target, the _mock_ keystore will be the default on that target. If you enable multiple credential stores for a specific target, you will get a compile error. See the [developer docs](https://docs.rs/keyring/) for details of which features control the inclusion of which credential stores (and which platforms each credential store targets).
6767

68-
Please note: Since neither the maintainers nor GitHub do testing on BSD variants, we rely on contributors to support these platforms. Thanks for your help!
68+
### Platform-specific issues
69+
70+
Since neither the maintainers nor GitHub do testing on BSD variants, we rely on contributors to support these platforms. Thanks for your help!
71+
72+
If you use the *Secret Service* as your credential store, be aware of the following:
73+
74+
* Access to credential stores via this crate is always *synchronous*; that is, it blocks the thread on which it was invoked. This is true *even if* your feature set specifies using the Zbus-based `secret-service` crate, which offers an async interface, because this crate always uses the blocking interface. If your application is using an async runtime already, and you build with the `async-secret-service` feature in this crate, you should (1) specify the same async runtime you are using as a feature for this crate, and (2) be sure to have a separate thread that is used for all `keyring` calls that access the credential store. Failure to use a separate thread is known to cause deadlocks.
75+
* Because credential store access from this crate is always synchronous, there is really no reason not to use the `sync-secret-service` feature (rather than `async-secret-service`) with this crate, *even if* your code is already using one of the async runtimes. Yes, this feature requires that `libdbus` be installed on your user’s machines, but it is by default in all desktop OS installs that include a Secret Service implementation (such as the Gnome Keyring or the KWallet). If you want to be extra careful, you can use the additional `vendored` feature to this crate to statically link the dbus library with your app so it’s not required on user machines. Just keep in mind that, in the event of an update to `libdbus`, using the `vendored` feature will require a rebuild of your app to get the `libdbus` update to your users.
76+
* Every call to the Secret Service is done via an inter-process call, which takes time (typically tens if not hundreds of milliseconds). If, for some reason, your code is pounding on the Secret Service like a database, you will want to implement a write-through transactional backing cache to protect your users from slowdowns. The `mock` credential store can be adapted for this purpose.
77+
78+
If you use the *Windows-native credential store*, be careful about multi-threaded access, because the Windows credential store does not guarantee your calls will be serialized in the order they are made. Always access any single credential from just one thread at a time, and if you are doing operations on multiple credentials that require a particular serialization order, perform all those operations from the same thread.
79+
80+
The *macOS and iOS credential stores* do not allow service or user names to be empty, because empty fields are treated as wildcards on lookup. Use some default, non-empty value instead.
6981

7082
## Upgrading from v2
7183

72-
The major functional change between v2 and v3 is the addition of synchronous support for the Secret Service via the [dbus-secret-service crate](https://crates.io/crates/dbus-secret-service). This means that keyring users of the Secret Service no longer need to link with an async runtime.
84+
The major functional change between v2 and v3 is the addition of synchronous support for the Secret Service via the [dbus-secret-service crate](https://crates.io/crates/dbus-secret-service). This means that keyring users of the Secret Service no longer need to link with an async runtime. (There are other advantages as well; see [above](#platform-specific-issues) for details.)
7385

7486
The main API change between v2 and v3 is the addition of support for non-string (i.e., binary) "password" data. To accommodate this, two changes have been made:
7587

build-xplat-binaries.sh

-34
This file was deleted.

src/lib.rs

+40-40
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ credential stores. The implementations of these platform-specific stores are ca
2727
in two types (with associated traits):
2828
2929
- a _credential builder_, represented by the [CredentialBuilder] type
30-
(and [CredentialBuilderApi](credential::CredentialBuilderApi) trait). Credential
31-
builders are given the identifying information provided for an entry and map
32-
it to the identifying information for a platform-specific credential.
30+
(and [CredentialBuilderApi](credential::CredentialBuilderApi) trait). Credential
31+
builders are given the identifying information provided for an entry and map
32+
it to the identifying information for a platform-specific credential.
3333
- a _credential_, represented by the [Credential] type
34-
(and [CredentialApi](credential::CredentialApi) trait). The platform-specific credential
35-
identified by a builder for an entry is what provides the secure storage
36-
for that entry's password/secret.
34+
(and [CredentialApi](credential::CredentialApi) trait). The platform-specific credential
35+
identified by a builder for an entry is what provides the secure storage
36+
for that entry's password/secret.
3737
3838
## Crate-provided Credential Stores
3939
@@ -72,32 +72,32 @@ credential stores you intend to use.
7272
7373
Here are the available credential store features:
7474
75-
* `apple-native`: Provides access to the Keychain credential store on macOS and iOS.
76-
77-
* `windows-native`: Provides access to the Windows Credential Store on Windows.
78-
79-
* `linux-native`: Provides access to the `keyutils` storage on Linux.
80-
81-
* `sync-secret-service`: Provides access to the DBus-based
82-
[Secret Service](https://specifications.freedesktop.org/secret-service/latest/)
83-
storage on Linux, FreeBSD, and OpenBSD. This is a _synchronous_ keystore that provides
84-
support for encrypting secrets when they are transferred across the bus. If you wish
85-
to use this encryption support, additionally specify one (and only one) of the
86-
`crypto-rust` or `crypto-openssl` features (to choose the implementation libraries
87-
used for the encryption). By default, this keystore requires that the DBus library be
88-
installed on the user's machine (and the openSSL library if you specify it for
89-
encryption), but you can avoid this requirement by specifying the `vendored` feature
90-
(which will cause the build to include those libraries statically).
91-
92-
* `async-secret-service`: Provides access to the DBus-based
93-
[Secret Service](https://specifications.freedesktop.org/secret-service/latest/)
94-
storage on Linux, FreeBSD, and OpenBSD. This is an _asynchronous_ keystore that
95-
always encrypts secrets when they are transferred across the bus. You _must_ specify
96-
both an async runtime feature (either `tokio` or `async-io`) and a cryptographic
97-
implementation (either `crypto-rust` or `crypto-openssl`) when using this
98-
keystore. If you want to use openSSL encryption but those libraries are not
99-
installed on the user's machine, specify the `vendored` feature
100-
to statically link them with the built crate.
75+
- `apple-native`: Provides access to the Keychain credential store on macOS and iOS.
76+
77+
- `windows-native`: Provides access to the Windows Credential Store on Windows.
78+
79+
- `linux-native`: Provides access to the `keyutils` storage on Linux.
80+
81+
- `sync-secret-service`: Provides access to the DBus-based
82+
[Secret Service](https://specifications.freedesktop.org/secret-service/latest/)
83+
storage on Linux, FreeBSD, and OpenBSD. This is a _synchronous_ keystore that provides
84+
support for encrypting secrets when they are transferred across the bus. If you wish
85+
to use this encryption support, additionally specify one (and only one) of the
86+
`crypto-rust` or `crypto-openssl` features (to choose the implementation libraries
87+
used for the encryption). By default, this keystore requires that the DBus library be
88+
installed on the user's machine (and the openSSL library if you specify it for
89+
encryption), but you can avoid this requirement by specifying the `vendored` feature
90+
(which will cause the build to include those libraries statically).
91+
92+
- `async-secret-service`: Provides access to the DBus-based
93+
[Secret Service](https://specifications.freedesktop.org/secret-service/latest/)
94+
storage on Linux, FreeBSD, and OpenBSD. This is an _asynchronous_ keystore that
95+
always encrypts secrets when they are transferred across the bus. You _must_ specify
96+
both an async runtime feature (either `tokio` or `async-io`) and a cryptographic
97+
implementation (either `crypto-rust` or `crypto-openssl`) when using this
98+
keystore. If you want to use openSSL encryption but those libraries are not
99+
installed on the user's machine, specify the `vendored` feature
100+
to statically link them with the built crate.
101101
102102
## Client-provided Credential Stores
103103
@@ -106,16 +106,16 @@ are free to provide their own secure stores and use those. There are
106106
two mechanisms provided for this:
107107
108108
- Clients can give their desired credential builder to the crate
109-
for use by the [Entry::new] and [Entry::new_with_target] calls.
110-
This is done by making a call to [set_default_credential_builder].
111-
The major advantage of this approach is that client code remains
112-
independent of the credential builder being used.
109+
for use by the [Entry::new] and [Entry::new_with_target] calls.
110+
This is done by making a call to [set_default_credential_builder].
111+
The major advantage of this approach is that client code remains
112+
independent of the credential builder being used.
113113
114114
- Clients can construct their concrete credentials directly and
115-
then turn them into entries by using the [Entry::new_with_credential]
116-
call. The major advantage of this approach is that credentials
117-
can be identified however clients want, rather than being restricted
118-
to the simple model used by this crate.
115+
then turn them into entries by using the [Entry::new_with_credential]
116+
call. The major advantage of this approach is that credentials
117+
can be identified however clients want, rather than being restricted
118+
to the simple model used by this crate.
119119
120120
## Mock Credential Store
121121

tests/threading.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn test_simultaneous_create_then_move() {
6767
}
6868

6969
#[test]
70-
#[cfg(any(not(target_os = "windows"), feature = "windows-test-threading"))]
70+
#[cfg(not(target_os = "windows"))]
7171
fn test_create_set_then_move() {
7272
let name = generate_random_string();
7373
let entry = Entry::new(&name, &name).expect("Can't create entry");

0 commit comments

Comments
 (0)