mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
Fix CSRF issues
This commit is contained in:
parent
88ad118f47
commit
330ea6f017
2 changed files with 29 additions and 15 deletions
|
|
@ -2333,6 +2333,24 @@ function jsRedirect(subpage, withoutTag)
|
|||
if not withoutTag then print("</script>") end
|
||||
end
|
||||
|
||||
-- Add a form submit lister to add the CRSF on form submit
|
||||
-- The form listener will not intercept plain 'onsubmit' html field
|
||||
function jsFormCSRF(formid, withoutTag)
|
||||
local html = "";
|
||||
|
||||
if not withoutTag then html = html .. "<script>" end
|
||||
html = html .. [[$('#]] .. formid .. [[').submit(function(e) {
|
||||
$('<input>').attr({
|
||||
type: "hidden",
|
||||
name: "csrf",
|
||||
value: "]] .. (ntop.getRandomCSRFValue()) .. [["
|
||||
}).appendTo($('#]] .. formid .. [['));
|
||||
});
|
||||
]]
|
||||
if not withoutTag then html = html .. "</script>" end
|
||||
return html
|
||||
end
|
||||
|
||||
-- ####################################################
|
||||
|
||||
-- Compute the difference in seconds between local time and UTC.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue