#credentials #keyring #secret #api-secret #keychain #password #secret-management

keyring-lib

High-level, asynchronous API for keyring-rs, a cross-platform Rust library to manage credentials

1 stable release

1.0.2 Oct 27, 2024
1.0.1 Oct 26, 2024
0.4.3 Jun 3, 2024
0.4.2 Apr 8, 2024
0.1.0 Aug 27, 2023

#217 in Asynchronous

Download history 64/week @ 2024-07-29 47/week @ 2024-08-05 55/week @ 2024-08-12 74/week @ 2024-08-19 147/week @ 2024-08-26 108/week @ 2024-09-02 65/week @ 2024-09-09 73/week @ 2024-09-16 141/week @ 2024-09-23 36/week @ 2024-09-30 85/week @ 2024-10-07 63/week @ 2024-10-14 323/week @ 2024-10-21 131/week @ 2024-10-28 24/week @ 2024-11-04 15/week @ 2024-11-11

496 downloads per month
Used in 10 crates (6 directly)

MIT license

18KB
147 lines

🔐 keyring-lib

High-level, asynchronous API for keyring-rs, a cross-platform Rust library to manage credentials.

Features

  • Uses Secret Service on Linux
  • Uses the keyutils secure, in-memory Linux kernel cache (if available)
  • Uses default system security credential on MacOS and Windows
  • Supports tokio and async-std async runtimes
  • Supports rustls and openssl crypto libs
  • Supports serde (de)serialization from/to String

The library comes with 6 cargo features, including 2 default ones:

  • tokio: enables the tokio async runtime
  • async-std: enables the async-std async runtime
  • rustls: enables the rustls crypto
  • openssl: enables the openssl crypto
  • derive: enables serde support
  • vendored: compiles and statically link to a copy of non-Rust vendors like OpenSSL

Example

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();

    // delete a secret entry
    entry.delete_secret().await.unwrap();
}

See the full API documentation on docs.rs.

FAQ

Why not using keyring-rs directly?

This library can be seen as a convenient async wrapper around keyring-rs. If you have an async app and just want to have a default keystore for any target OS, then keyring-lib is the right choice. If you do not have an async app, or you want more control over keystores, using keyring-rs is a much better choice.

Sponsoring

nlnet

Special thanks to the NLnet foundation and the European Commission that helped the project to receive financial support from various programs:

All the credits go to keyring-rs. The maintainers are doing a great job there, consider supporting them first.

That said, if you appreciate this project, feel free to donate using one of the following providers:

GitHub Ko-fi Buy Me a Coffee Liberapay thanks.dev PayPal

Dependencies

~3–17MB
~223K SLoC