Implemented origin handling in federation rest

This commit is contained in:
Luca Deri 2020-11-12 22:14:32 +01:00
parent 8deec26a1d
commit f38b71f6a7
3 changed files with 52 additions and 53 deletions

View file

@ -13,11 +13,6 @@ local tracker = require("tracker")
local rc = rest_utils.consts.success.ok
local res = {}
if not haveAdminPrivileges() then
rest_utils.answer(rest_utils.consts.err.not_granted, res)
return
end
-- TODO: collect real statistics about the running ntopng instance
res = {
total_traffic = {up = 100, down = 100},
@ -27,4 +22,8 @@ res = {
version = "v1"
}
rest_utils.answer(rc, res)
local origin = _SERVER["origin"] or '*'
local extra_headers = { 'Access-Control-Allow-Origin: '..origin }
rest_utils.answer(rc, res, extra_headers)