6 releases (3 breaking)
0.4.1 | Apr 4, 2021 |
---|---|
0.4.0 | Mar 21, 2021 |
0.3.0 | Mar 20, 2021 |
0.2.1 | Mar 20, 2021 |
0.1.0 | Nov 5, 2020 |
#612 in Authentication
Used in credent
28KB
622 lines
🔑 Credent
Manages ~/.config/<app>/credentials
.
Usage
Add the following to Cargo.toml:
credent = { version = "0.4.1", features = ["backend-smol"] } # or "backend-tokio"
Example code:
use credent::{
cli::CredentialsCliReader,
fs::{model::AppName, CredentialsFile, CredentialsFileStorer},
model::Credentials,
};
/// Application name
const CREDENT: AppName<'_> = AppName("credent");
fn main() -> Result<(), Box<dyn std::error::Error>> {
smol::run(async {
let credentials = CredentialsCliReader::<Credentials>::read_from_tty().await?;
println!("credentials: {}", credentials);
CredentialsFileStorer::<Credentials>::store(CREDENT, &credentials).await?;
println!(
"credentials written to: {}",
CredentialsFile::<Credentials>::path(CREDENT)?.display()
);
Result::<(), Box<dyn std::error::Error>>::Ok(())
})
}
More examples can be seen in the examples.
# Use either "backend-smol" or "backend-tokio"
cargo run --features "backend-smol" --example simple
cargo run --features "backend-smol" --example demo
cargo run --features "backend-smol" --example profiles
cargo run --features "backend-smol" --example profiles -- --profile development
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
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.
Dependencies
~0.3–11MB
~126K SLoC