Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPC authentication #86

Closed
wants to merge 9 commits into from
Prev Previous commit
Next Next commit
Implemented rpc authentication for RemoteCaller::daemon_rpc_call() us…
…ed for certain monerod rpc calls
  • Loading branch information
refring committed Oct 17, 2022
commit 59ad587382147b6cce58cf3657368aa233aa8287
26 changes: 18 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,13 @@ impl RemoteCaller {
.json(&method_call);

let rsp = if let Credentials{username, password} = &self.rpc_auth {
req.send_with_digest_auth(username, password).await?
req.send_with_digest_auth(username, password)
.await?
.json::<response::Output>()
.await?
} else{
req.send().await?
req.send()
.await?
.json::<response::Output>()
.await?
};
Expand All @@ -161,13 +163,21 @@ impl RemoteCaller {
json_params
);

let rsp = client
let req = client
.post(uri)
.json(&json_params)
.send()
.await?
.json::<T>()
.await?;
.json(&json_params);

let rsp = if let Credentials{username, password} = &self.rpc_auth {
req.send_with_digest_auth(username, password)
.await?
.json::<T>()
.await?
} else{
req.send()
.await?
.json::<T>()
.await?
};

trace!("Received daemon RPC response: {:?}", rsp);

Expand Down