Skip to content

Commit 7d86e95

Browse files
committed
Use basic auth in publish requests
Fixes #12
1 parent 80154ca commit 7d86e95

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ntfy-daemon/src/system_client.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,16 @@ impl SubscriptionImpl {
202202

203203
fn _publish<'a>(&'a mut self, msg: &'a str) -> impl Future<Output = Result<(), capnp::Error>> {
204204
let msg = msg.to_owned();
205-
let req = self.env.http.post(&self.model.borrow().server).body(msg);
205+
let server = &self.model.borrow().server;
206+
let creds = self.env.credentials.get(server);
207+
let mut req = self.env.http.post(server);
208+
if let Some(creds) = creds {
209+
req = req.basic_auth(creds.username, Some(creds.password));
210+
}
206211

207212
async move {
208213
info!("sending message");
209-
let res = req.send().await;
214+
let res = req.body(msg).send().await;
210215
match res {
211216
Err(e) => Err(capnp::Error::failed(e.to_string())),
212217
Ok(res) => {

0 commit comments

Comments
 (0)