add authorization to ntfy
Signed-off-by: Simon Smith <simonsmith5521@gmail.com>
Simon Smith committed
Oct 4, 2023 at 12:49 UTC
d8d13bda426598aa923aad4e218539117bca436c
5 files changed
+17
-2
docs/docs/meshcentral/config.md
+4
@@ -3410,6 +3410,10 @@ See description for information about each item.
3410
"userurl": {
3411
"type": "string",
3412
"description": "A URL given to users to help them setup this service."
3413
+ },
3414
+ "authorization": {
3415
+ "type": "string",
3416
+ "description": "Authorization Header to include in the request"
3417
}
3418
},
3419
"description": "Enabled ntfy.sh integration support."
docs/docs/messaging/index.md
+2
-1
@@ -202,7 +202,8 @@ For [self-hosting your own ntfy server](https://ntfy.sh/docs/install/) with [ACL
202
"messaging": {
203
"ntfy": {
204
"host": "https://[my]ntfy.sh",
205
- "userurl": "https://[my]ntfy.sh/userhelp"
205
+ "userurl": "https://[my]ntfy.sh/userhelp",
206
+ "authorization": "Basic cGhpbDpteXBhc3M="
207
}
208
}
209
}
meshcentral-config-schema.json
+4
@@ -3408,6 +3408,10 @@
3408
"userurl": {
3409
"type": "string",
3410
"description": "A URL given to users to help them setup this service."
3411
+ },
3412
+ "authorization": {
3413
+ "type": "string",
3414
+ "description": "Authorization Header to include in the request"
3415
}
3416
},
3417
"description": "Enabled ntfy.sh integration support."
meshmessaging.js
+2
-1
@@ -335,7 +335,8 @@ module.exports.CreateServer = function (parent) {
335
push.send(domain.title ? domain.title : 'MeshCentral', msg, function (err, res) { if (func != null) { func(err == null); } });
336
} else if ((to.startsWith('ntfy:')) && (obj.ntfyClient != null)) { // ntfy
337
const url = 'https://' + (((typeof parent.config.messaging.ntfy == 'object') && (typeof parent.config.messaging.ntfy.host == 'string')) ? parent.config.messaging.ntfy.host : 'ntfy.sh') + '/' + encodeURIComponent(to.substring(5));
338
- const req = require('https').request(new URL(url), { method: 'POST' }, function (res) { if (func != null) { func(true); } });
338
+ const headers = (typeof parent.config.messaging.ntfy.authorization == 'string') ? { 'Authorization': parent.config.messaging.ntfy.authorization } : {};
339
+ const req = require('https').request(new URL(url), { method: 'POST', headers: headers }, function (res) { if (func != null) { func(true); } });
340
req.on('error', function (err) { if (func != null) { func(false); } });
341
req.end(msg);
342
} else if ((to.startsWith('zulip:')) && (obj.zulipClient != null)) { // zulip
sample-config-advanced.json
+5
@@ -628,6 +628,11 @@
628
"_discord": {
629
"serverurl": "https://discord.gg/xxxxxxxxx",
630
"token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
631
+ },
632
+ "_ntfy": {
633
+ "host": "https://[my]ntfy.sh",
634
+ "userurl": "https://[my]ntfy.sh/userhelp",
635
+ "authorization": "Basic xxxxxxxxxxxxxxxxxxxx"
636
}
637
}
638
}