• Stars
    star
    484
  • Rank 90,873 (Top 2 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created almost 9 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Cross-platform library and utility to manage passwords

Keyring-rs

build dependencies crates.io docs.rs

A cross-platform library to manage storage and retrieval of passwords (and other secrets) in the underlying platform secure store, with a fully-developed example that provides a command-line interface.

Usage

To use this library in your project add the following to your Cargo.toml file:

[dependencies]
keyring = "2"

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 takes a service name and a user name which together identify the entry.

Passwords can be added to an entry using its set_password method. They can then be read back using the get_password method, and removed using the delete_password method.

use keyring::{Entry, Result};

fn main() -> Result<()> {
    let entry = Entry::new("my_service", "my_name")?;
    entry.set_password("topS3cr3tP4$$w0rd")?;
    let password = entry.get_password()?;
    println!("My password is '{}'", password);
    entry.delete_password()?;
    Ok(())
}

Errors

Creating and operating on entries can yield a keyring::Error which provides both a platform-independent code that classifies the error and, where relevant, underlying platform errors or more information about what went wrong.

Examples

The keychain-rs project contains a sample application (cli) and a sample library (ios).

The cli application is a command-line interface to the keyring. It can be used to explore how the library is used. It can also be used in debugging keyring-based applications to probe the contents of the credential store.

The ios 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. 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.

Client Testing

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.

Extensibility

This crate allows clients to "bring their own credential store" by providing traits that clients can implement. See the developer docs for details.

Platforms

This crate provides secure storage support for Linux (secret-service and kernel keyutils), iOS (keychain), macOS (keychain), and Windows (credential manager).

It also builds on FreeBSD (secret-service), and probably works there, but since neither the maintainers nor GitHub do building and testing on FreeBSD, we can't be sure.

Please file issues if you have questions or problems.

Upgrading from v1

The v2 release, although it adds a lot of functionality relative to v1, is fully compatible with respect to persisted entry data: it will both read and set passwords on entries that were originally written by v1, and entries written by v2 will be readable and updatable by v1.

From a client API point of view, the biggest difference between v2 and v1 is that entry creation using Entry::new and Entry::new_with_target can now fail, so v1 client code will need to add an unwrap or other error handling in order to work with v2.

There are also new Error variants in v2, and the enum has been declared non-exhaustive (to allow for variants to be added without breaking client code). This means that v1 client code that relies on exhaustive matching will need to be updated.

License

Licensed under either of

at your option.

Contributors

Thanks to the following for helping make this library better, whether through contributing code, discussion, or bug reports!

  • @Alexei-Barnes
  • @bhkaminski
  • @brotskydotcom
  • @complexspaces
  • @connor4312
  • @dario23
  • @dten
  • @gondolyr
  • @hwchen
  • @jankatins
  • @jasikpark
  • @jkhsjdhjs
  • @jonathanmorley
  • @jyuch
  • @landhb
  • @lexxvir
  • @MaikKlein
  • @Phrohdoh
  • @phlip9
  • @Rukenshia
  • @ryanavella
  • @samuela
  • @stankec
  • @steveatinfincia
  • @Sytten

If you should be on this list, but don't find yourself, please contact @brotskydotcom.

Contribution

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.

More Repositories

1

secret-service-rs

Rust library for interfacing with Secret Service API
Rust
69
star
2

llamas2

llamas, but trying with enums for dynamic dispatch
Rust
11
star
3

tophat

A small, pragmatic, and flexible async HTTP server library, in Rust
Rust
11
star
4

llamas

dataframe in Rust, inspired by pandas 2.0
Rust
8
star
5

manx-rs

wscat clone in rust
Rust
6
star
6

lemurdb

toy sql db
Rust
5
star
7

beryl

Rust
4
star
8

mondrian-schema-cat

utility for concatenating fragments of mondrian schemas into one valid schema
Rust
4
star
9

acs-explorer

cli for investigating US census ACS variables and data
Rust
4
star
10

tetris-rs

Tetris, using Rust and ncurses
Rust
3
star
11

clickhouse-stream

Rust
2
star
12

essentials-of-compilation

Implementation of languages and exercises in "Essentials of Compilation"
Rust
2
star
13

geta-rs

Neural Network. Geta is the "net" technique in the game of Go (direct translation of geta is actually clog/sandal)
Rust
2
star
14

ika

rest api on postgres
Rust
2
star
15

pour

When it rains it pours. Specialized load tester for http requests, in rust
Rust
2
star
16

ml100scratch

exploring some of the algorithms from ml100 book, in rust
Rust
2
star
17

dns-toy-zig

dns toy implementation
Zig
1
star
18

reddit-focus

personal util to get just links from rust subreddit
Rust
1
star
19

zuniq

Zig
1
star
20

monetdb-tokio

rust driver for monet columnar database, for tokio async framework.
Rust
1
star
21

percent-encoding-cli-rs

cli wrapper for percent encoding lib
Rust
1
star
22

finmath-rs

Rust
1
star
23

nextbus-rs

Rust library for consuming NextBus public API
Rust
1
star
24

sumrs

Sum line-separated numbers on the command line
Rust
1
star
25

evntsrc-client

Client library for Eventsource/Server-Sent Events, built on async Rust and `std::futures`
Rust
1
star
26

codeforces

codeforces
Rust
1
star
27

melt

melt csv on the command line
Rust
1
star
28

raytracer-zig

Zig
1
star
29

tesseract-deprecated

exploratory rolap with web api fronend
Rust
1
star
30

toml-zig

TOML parser for ziglang
Zig
1
star
31

lox

Following Crafting Interpreters book
Zig
1
star
32

shp2pgsql2csv

shp2gpsql output (insert value statements) to csv conversion
Rust
1
star
33

test-github-release

Rust
1
star
34

euler-rs

Project euler in rust, to explore data structures and algorithms and optimization
Rust
1
star
35

olox

Crafting Interpreters clox, but in odin
Odin
1
star
36

brillig

Following Cornell cs6120 advanced compilers course
Zig
1
star
37

algorithms

Zig
1
star
38

bumidb

sql on rocks
Zig
1
star
39

ray-tracer

ray tracer in Rust following ray tracer in a weekend
Rust
1
star
40

moarsql

Rust
1
star
41

pangolin-lang

following thorsten ball's interpreter book (porting golang to rust)
Rust
1
star
42

beetl

etl for Rust
Rust
1
star
43

unboilerplate

Rust
1
star
44

jsonrow2csv

small utility for converting rows of json to csv, with ability to select keys
Rust
1
star
45

slackit-cli

cli interface for sending slack messages through web api
Rust
1
star
46

roots

experimental, finding roots of a polynomial
Rust
1
star
47

unproxy

proxy for chaos testing
Rust
1
star
48

k-dimensional-trees

in-memory and on-disk data structures for queries on k-dimensional data
Rust
1
star
49

clickhouse-query

quick tester for querying with rust clickhouse driver
Rust
1
star
50

calliope

data integrity tool
Rust
1
star
51

automata-zig

Zig
1
star
52

mondrian-rest-cli

cli for interacting with mondrian-rest
Rust
1
star
53

clickhouse-hang

testing for clickhouse driver hanging.
Rust
1
star
54

advent-2018

Rust
1
star
55

automata-rs

Conway's Game of Life in Rust
Rust
1
star
56

mondrian-schema-builder-rs

mondrian schema builder api for rust
Rust
1
star