9 unstable releases (3 breaking)
0.4.3 | Jun 3, 2024 |
---|---|
0.4.2 | Apr 8, 2024 |
0.4.0 | Mar 14, 2024 |
0.3.2 | Dec 31, 2023 |
0.1.0 | Aug 27, 2023 |
#361 in Database interfaces
399 downloads per month
Used in 9 crates
(6 directly)
20KB
224 lines
🔐 keyring-lib
Manage credentials using OS-specific keyrings: Secret Service
on Linux, Security Framework
on MacOS and Security Credentials
on Windows.
This library aims to be a High-level API for keyring, a cross-platform library to manage credentials, and can be seen as a convenient wrapper around it:
- Made the lib async using
tokio
. - Simplified cargo features:
tokio
by default,tokio-openssl
,async-io
andasync-io-openssl
available. - Added the cargo feature
serde
that enables serialization and deserialization of a keyring entry from and to aString
. - Changed the way the service name is declared: instead of declaring it everytime you declare a keyring entry, you just need to declare it once at the beginning of you program, using the function
keyring::set_global_service_name
. - Added new function
find_secret
that returns aResult<Option<String>>
. - Enabled logging using the log crate.
- Added keyring cache based on the linux keyutils keyring (only works on Linux machines).
See the full API documentation and some examples.
use keyring::{set_global_service_name, KeyringEntry};
#[tokio::main]
async fn main() {
// define the global keyring service name once
set_global_service_name("example");
// create a keyring entry from a key string
let entry = KeyringEntry::try_new("key").unwrap();
// define a secret
entry.set_secret("secret").await.unwrap();
// get a secret
entry.get_secret().await.unwrap();
// find a secret
entry.find_secret().await.unwrap();
// deletea secret
entry.delete_secret().await.unwrap();
}
Development
The development environment is managed by Nix. Running nix-shell
will spawn a shell with everything you need to get started with the lib: cargo
, cargo-watch
, rust-bin
, rust-analyzer
…
# Start a Nix shell
$ nix-shell
# then build the lib
$ cargo build -p keyring-lib
Contributing
A bug tracker is available on SourceHut. [send an email]
A mailing list is available on SourceHut. [send an email] [subscribe] [unsubscribe]
If you want to report a bug, please send an email at ~soywod/pimalaya@todo.sr.ht.
If you want to propose a feature or fix a bug, please send a patch at ~soywod/pimalaya@lists.sr.ht. The simplest way to send a patch is to use git send-email, follow this guide to configure git properly.
If you just want to discuss about the project, feel free to join the Matrix workspace #pimalaya or contact me directly @soywod. You can also use the mailing list.
Sponsoring
Special thanks to the NLnet foundation and the European Commission that helped the project to receive financial support from:
- NGI Assure in 2022
- NGI Zero Entrust in 2023
If you appreciate the project, feel free to donate using one of the following providers:
Dependencies
~2–14MB
~184K SLoC