aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-01-26 14:39:11 +0100
committerKim Alvefur <zash@zash.se>2021-01-26 14:39:11 +0100
commita28c769e1af28d7fdae6b6b65f456bcfd7504ea8 (patch)
tree5a9256c8b6d5e5d5d03c02de03b9afe074d383c3 /plugins
parent52a969df34354155df073277f16869092b2895de (diff)
downloadprosody-a28c769e1af28d7fdae6b6b65f456bcfd7504ea8.tar.gz
prosody-a28c769e1af28d7fdae6b6b65f456bcfd7504ea8.zip
mod_http_file_share: Add basic access control
Partly lifted from mod_external_services
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_http_file_share.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/plugins/mod_http_file_share.lua b/plugins/mod_http_file_share.lua
index c6091bd0..8f230ef4 100644
--- a/plugins/mod_http_file_share.lua
+++ b/plugins/mod_http_file_share.lua
@@ -28,12 +28,18 @@ local uploads = module:open_store("uploads", "archive");
local secret = module:get_option_string(module.name.."_secret", require"util.id".long());
local external_base_url = module:get_option_string(module.name .. "_base_url");
+local access = module:get_option_set(module.name .. "_access", {});
+
if not external_base_url then
module:depends("http");
end
function may_upload(uploader, filename, filesize, filetype) -- > boolean, error
- -- TODO authz
+ local uploader_host = jid.host(uploader);
+ if not ((access:empty() and prosody.hosts[uploader_host]) or access:contains(uploader) or access:contains(uploader_host)) then
+ return false;
+ end
+
return true;
end