# HG changeset patch # User Kim Alvefur # Date 1611668351 -3600 # Node ID 9edda2026e57d4abf7acd4e66bdfcf950cf2a419 # Parent d1a0f2e918c057730ec71a3b78c1c475f78fb092 mod_http_file_share: Add basic access control Partly lifted from mod_external_services diff -r d1a0f2e918c0 -r 9edda2026e57 plugins/mod_http_file_share.lua --- a/plugins/mod_http_file_share.lua Tue Jan 26 14:27:51 2021 +0100 +++ b/plugins/mod_http_file_share.lua Tue Jan 26 14:39:11 2021 +0100 @@ -28,12 +28,18 @@ 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