forked from etcdv3/etcd-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.rs
25 lines (19 loc) · 737 Bytes
/
auth.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//! Auth example
use etcd_client::*;
#[tokio::main]
async fn main() -> Result<(), Error> {
println!("connect without user authenticate");
let mut client = Client::connect(["localhost:2379"], None).await?;
println!("enable authenticate by normal client");
client.auth_enable().await?;
// connect with authenticate, the user must already exists
println!("connect with user authenticate");
let options = Some(ConnectOptions::new().with_user(
"root", // user name
"rootpwd", // password
));
let mut client_auth = Client::connect(["localhost:2379"], options).await?;
println!("disable authenticate by authenticated client");
client_auth.auth_disable().await?;
Ok(())
}