You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge pull request #114 from brotskydotcom/doc-updates
Revamp the docs for v2. Also tweaked visibility of a few classes for documentation purposes.
This brings us to 2.0.0-rc.3, and will likely be promoted to our 2.0 release.
[](https://docs.rs/keyring)
5
5
6
-
A cross-platform library to manage storage and retrieval of passwords (and other credential-like secrets) in the underlying platform secure store, with a fully-developed example that provides a command-line interface.
7
-
8
-
Published on [crates.io](https://crates.io/crates/keyring)
6
+
A cross-platform library to manage storage and retrieval of passwords
7
+
(and other secrets) in the underlying platform secure store,
8
+
with a fully-developed example that provides a command-line interface.
9
9
10
10
## Usage
11
11
12
-
__Currently supports Linux, iOS, macOS, and Windows.__ Please file issues if you have any problems or bugs!
12
+
**Currently supports Linux, iOS, macOS, and Windows.**
13
+
Please file issues if you have have questions or problems.
13
14
14
15
To use this library in your project add the following to your `Cargo.toml` file:
15
16
16
17
```toml
17
18
[dependencies]
18
-
keyring = "1"
19
+
keyring = "2"
19
20
```
20
21
21
-
This will give you access to the `keyring` crate in your code. Now you can use the `Entry::new` function to create a new keyring entry. The `new` function expects a non-empty `service` name and a non-empty `username` which together identify the entry.
22
+
This will give you access to the `keyring` crate in your code.
23
+
Now you can use the `Entry::new` function to create a new keyring entry.
24
+
The `new` function takes a service name
25
+
and a user name which together identify the entry.
22
26
23
-
Passwords can be added to an entry using its `set_password` method. They can then be read back using the `get_password` method, and deleted using the `delete_password` method. (The persistence of the `Entry` is determined via Rust rules, so deleting the password doesn't delete the entry, but it does delete the underlying platform credential which was used to store the password.)
27
+
Passwords can be added to an entry using its `set_password` method.
28
+
They can then be read back using the `get_password` method,
29
+
and removed using the `delete_password` method.
30
+
(The persistence of the `Entry` is determined via Rust rules,
31
+
so deleting the password doesn't delete the entry,
32
+
but it does delete the underlying platform credential
Creating and operating on entries can yield a `keyring::Error` which provides both a platform-independent code that classifies the error and, where available, underlying platform errors and/or more information about what went wrong.
50
+
Creating and operating on entries can yield a `keyring::Error`
51
+
which provides both a platform-independent code
52
+
that classifies the error and, where relevant,
53
+
underlying platform errors or more information about what went wrong.
51
54
52
55
## Examples
53
56
54
-
The keychain-rs project contains a sample application (`cli`) and a sample library (`ios`).
55
-
56
-
The application is a command-line interface to the keyring. This can be a great way to explore how the library is used, and it allows experimentation with the use of different service names, usernames, and targets. When run in "singly verbose" mode (-v), it outputs the retrieved credentials on each `get` run. When run in "doubly verbose" mode (-vv), it also outputs any errors returned. This can be a great way to see which errors result from which conditions on each platform.
57
-
58
-
The sample library is a full exercise of all the iOS functionality; it's meant to be loaded into an iOS test harness such as the one found in [this project](https://github.com/brotskydotcom/rust-on-ios). While the library can be compiled and linked to on macOS as well, doing so doesn't provide any advantages over the standard macOS tests.
57
+
The keychain-rs project contains a sample application (`cli`)
58
+
and a sample library (`ios`).
59
+
60
+
The application is a command-line interface to the keyring.
61
+
It can be used to explore how the library is used.
62
+
It can also be used in debugging keyring-based applications
63
+
to probe the contents of the credential store.
64
+
When run in "singly verbose" mode (-v),
65
+
it outputs the retrieved credentials on each `get` run.
66
+
When run in "doubly verbose" mode (-vv),
67
+
it also outputs any errors returned.
68
+
69
+
The sample library is a full exercise of all the iOS functionality;
While the library can be compiled and linked to on macOS as well,
74
+
doing so doesn't provide any advantages over the standard macOS tests.
59
75
60
76
## Client Testing
61
77
62
-
This crate comes with a "mock" credential store that can be used by clients who want to test without accessing the native platform store. The mock store is cross-platform and allows mocking errors as well as successes.
78
+
This crate comes with a "mock" credential store
79
+
that can be used by clients who want to test
80
+
without accessing the native platform store.
81
+
The mock store is cross-platform
82
+
and allows mocking errors as well as successes.
63
83
64
84
## Extensibility
65
85
66
-
This crate comes with built-in support for the keychain on Mac, the credential manager on Windows, and both secret-service and the kernel keyring on Linux. But it's also designed to allow clients to "bring their own credential stores" by providing traits that clients can implement. See the [developer docs](https://docs.rs/keyring/latest/keyring/) for details.
67
-
68
-
## Dev Notes
69
-
70
-
* We build using GitHub CI.
71
-
* Each tag is built on Ubuntu x64, Win 10 x64, and Mac intel x64. The `cli` example executable is posted for all platforms with the tag.
72
-
73
-
### Headless Linux
74
-
75
-
If you are trying to use keyring on a headless linux box, be aware that there are known issues with getting dbus and secret-service and the gnome keyring to work properly in headless environments. For a quick workaround, look at how this project's [CI workflow](https://github.com/hwchen/keyring-rs/blob/master/.github/workflows/build.yaml) uses the [linux-test.sh](https://github.com/hwchen/keyring-rs/blob/master/linux-test.sh) script; a similar solution is also documented in the [Python Keyring docs](https://pypi.org/project/keyring/) (search for "Using Keyring on headless Linux systems"). For an excellent treatment of all the headless dbus issues, see [this answer on ServerFault](https://serverfault.com/a/906224/79617).
76
-
77
-
Note that you can build this crate without secret-service support; this makes the Linux keyring (which works normally on headless linux) the default credential store on Linux platforms.
86
+
This crate comes with built-in support for the keychain on Mac,
87
+
the credential manager on Windows,
88
+
and both secret-service and the kernel keyutils on Linux.
89
+
But it's also designed to allow clients
90
+
to "bring their own credential stores"
91
+
by providing traits that clients can implement.
92
+
See the [developer docs](https://docs.rs/keyring/latest/keyring/)
93
+
for details.
78
94
79
95
## License
80
96
@@ -87,7 +103,8 @@ at your option.
87
103
88
104
## Contributors
89
105
90
-
Thanks to the following for helping make this library better, whether through contributing code, discussion, or bug reports!
106
+
Thanks to the following for helping make this library better,
107
+
whether through contributing code, discussion, or bug reports!
91
108
92
109
-@Alexei-Barnes
93
110
-@bhkaminski
@@ -111,8 +128,14 @@ Thanks to the following for helping make this library better, whether through co
111
128
-@steveatinfincia
112
129
-@Sytten
113
130
114
-
If you should be on this list, but don't find yourself, please contact @brotskydotcom.
131
+
If you should be on this list, but don't find yourself,
132
+
please contact @brotskydotcom.
115
133
116
134
### Contribution
117
135
118
-
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
0 commit comments