aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_http.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-12-30 09:49:28 +0100
committerKim Alvefur <zash@zash.se>2019-12-30 09:49:28 +0100
commit5d4446cd13b3dd9900ebc169b2e7f2d032a8e6c9 (patch)
tree7536cbef1bea50752a2fd6742978a4dd43400215 /plugins/mod_http.lua
parent24974dc1c6f7ec772b56e6c081d4adabbcf4b93f (diff)
downloadprosody-5d4446cd13b3dd9900ebc169b2e7f2d032a8e6c9.tar.gz
prosody-5d4446cd13b3dd9900ebc169b2e7f2d032a8e6c9.zip
mod_http: Allow setting the CORS credentials flag via :provides API
E.g. module:provides("http", { cors = { credentials = true; }; route = { ... }; });
Diffstat (limited to 'plugins/mod_http.lua')
-rw-r--r--plugins/mod_http.lua10
1 files changed, 9 insertions, 1 deletions
diff --git a/plugins/mod_http.lua b/plugins/mod_http.lua
index b9c0c1a4..3a33e408 100644
--- a/plugins/mod_http.lua
+++ b/plugins/mod_http.lua
@@ -129,10 +129,11 @@ function module.add_host(module)
local app_handlers = apps[app_name];
local app_methods = opt_methods;
+ local app_credentials = opt_credentials;
local function cors_handler(event_data)
local request, response = event_data.request, event_data.response;
- apply_cors_headers(response, app_methods, opt_headers, opt_max_age, opt_credentials, request.headers.origin);
+ apply_cors_headers(response, app_methods, opt_headers, opt_max_age, app_credentials, request.headers.origin);
end
local function options_handler(event_data)
@@ -140,6 +141,13 @@ function module.add_host(module)
return "";
end
+ if event.item.cors then
+ local cors = event.item.cors;
+ if cors.credentials ~= nil then
+ app_credentials = cors.credentials;
+ end
+ end
+
local streaming = event.item.streaming_uploads;
for key, handler in pairs(event.item.route or {}) do