mod_http: Allow disabling CORS in the http_cors_override option and by default
Fixes #1779.
Due to an oversight in the logic, if the user set 'enabled' to false in an
override, it would disable the item's requested CORS settings, but still apply
Prosody's default CORS policy.
This change ensures that 'enabled = false' will now disable CORS entirely for
the requested item.
Due to the new structure of the code, it was necessary to have a flag to say
whether CORS is to be applied at all. Rather than hard-coding 'true' here, I
chose to add a new option: 'http_default_cors_enabled'. This is a boolean that
allows the operator to disable Prosody's default CORS policy entirely (the one
that is used when a module or config does not override it). This makes it
easier to disable CORS and then selectively enable it only on services you
want it on.
-- Compatibility layer for bitwise operations
-- First try the bit32 lib
-- Lua 5.3 has it with compat enabled
-- Lua 5.2 has it by default
if _G.bit32 then
return _G.bit32;
else
-- Lua 5.1 may have it as a standalone module that can be installed
local ok, bitop = pcall(require, "bit32")
if ok then
return bitop;
end
end
do
-- Lua 5.3 and 5.4 would be able to use native infix operators
local ok, bitop = pcall(require, "util.bit53")
if ok then
return bitop;
end
end
do
-- Lastly, try the LuaJIT bitop library
local ok, bitop = pcall(require, "bit")
if ok then
return bitop;
end
end
error "No bit module found. See https://prosody.im/doc/depends#bitop";