diff --git a/scripts/lua/admin/prefs.lua b/scripts/lua/admin/prefs.lua index 8f09bfa8ff..8884724354 100644 --- a/scripts/lua/admin/prefs.lua +++ b/scripts/lua/admin/prefs.lua @@ -54,6 +54,7 @@ if(haveAdminPrivileges()) then local menu_subpages = { {id="users", label="Users", advanced=false, pro_only=false, disabled=false}, + {id="auth", label="Authentication", advanced=false, pro_only=true, disabled=false}, {id="ifaces", label="Network Interfaces", advanced=true, pro_only=false, disabled=false}, {id="in_memory", label="In-Memory Data", advanced=true, pro_only=false, disabled=false}, {id="on_disk_rrds", label="On-Disk Timeseries", advanced=false, pro_only=false, disabled=false}, @@ -62,7 +63,8 @@ if(haveAdminPrivileges()) then {id="protocols", label="Protocols", advanced=false, pro_only=false, disabled=false}, {id="report", label="Units of Measurement", advanced=false, pro_only=false, disabled=false}, {id="logging", label="Logging", advanced=false, pro_only=false, disabled=(prefs.has_cmdl_trace_lvl == true)}, - {id="nbox", label="nBox Integration", advanced=true, pro_only=true, disabled=false}, + {id="snmp", label="SNMP", advanced=true, pro_only=true, disabled=false}, + {id="nbox", label="nBox Integration", advanced=false, pro_only=true, disabled=false}, } if(info["version.enterprise_edition"]) then @@ -429,94 +431,80 @@ function printUsers() "google_apis_browser_key", "", false, nil, nil, nil, {style={width="25em;"}, attributes={spellcheck="false"} --[[ Note: Google API keys can vary in format ]] }) - if ntop.isPro() then - print('Authentication') - local labels = {"Local","LDAP","LDAP/Local"} - local values = {"local","ldap","ldap_local"} - local elementToSwitch = {"row_multiple_ldap_account_type", "row_toggle_ldap_anonymous_bind","server","bind_dn", "bind_pwd", "ldap_server_address", "search_path", "user_group", "admin_group"} - local showElementArray = {false, true, true} - local javascriptAfterSwitch = ""; - javascriptAfterSwitch = javascriptAfterSwitch.." if($(\"#id-toggle-multiple_ldap_authentication\").val() != \"local\" ) {\n" - javascriptAfterSwitch = javascriptAfterSwitch.." if($(\"#toggle_ldap_anonymous_bind_input\").val() == \"0\") {\n" - javascriptAfterSwitch = javascriptAfterSwitch.." $(\"#bind_dn\").css(\"display\",\"table-row\");\n" - javascriptAfterSwitch = javascriptAfterSwitch.." $(\"#bind_pwd\").css(\"display\",\"table-row\");\n" - javascriptAfterSwitch = javascriptAfterSwitch.." } else {\n" - javascriptAfterSwitch = javascriptAfterSwitch.." $(\"#bind_dn\").css(\"display\",\"none\");\n" - javascriptAfterSwitch = javascriptAfterSwitch.." $(\"#bind_pwd\").css(\"display\",\"none\");\n" - javascriptAfterSwitch = javascriptAfterSwitch.." }\n" - javascriptAfterSwitch = javascriptAfterSwitch.." }\n" - local retVal = multipleTableButtonPrefs("Authentication Method", - "Local (Local only), LDAP (LDAP server only), LDAP/Local (Authenticate with LDAP server, if fails it uses local authentication).", - labels, values, "local", "primary", "multiple_ldap_authentication", "ntopng.prefs.auth_type", nil, - elementToSwitch, showElementArray, javascriptAfterSwitch) - - local showElements = true; - if ntop.getPref("ntopng.prefs.auth_type") == "local" then - showElements = false - end - - local labels_account = {"Posix","sAMAccount"} - local values_account = {"posix","samaccount"} - multipleTableButtonPrefs("LDAP Accounts Type", - "Choose your account type", - labels_account, values_account, "posix", "primary", "multiple_ldap_account_type", "ntopng.prefs.ldap.account_type", nil, nil, nil, nil, showElements) - - prefsInputFieldPrefs("LDAP Server Address", "IP address and port of LDAP server (e.g. ldaps://localhost:636). Default: \"ldap://localhost:389\".", "ntopng.prefs.ldap", "ldap_server_address", "ldap://localhost:389", nil, showElements, true, true, {attributes={pattern="ldap(s)?://[0-9.\\-A-Za-z]+(:[0-9]+)?", spellcheck="false", required="required"}}) - - local elementToSwitchBind = {"bind_dn","bind_pwd"} - toggleTableButtonPrefs("LDAP Anonymous Binding","Enable anonymous binding.","On", "1", "success", "Off", "0", "danger", "toggle_ldap_anonymous_bind", "ntopng.prefs.ldap.anonymous_bind", "0", nil, elementToSwitchBind, true, showElements) - - local showEnabledAnonymousBind = false - if ntop.getPref("ntopng.prefs.ldap.anonymous_bind") == "0" then - showEnabledAnonymousBind = true - end - local showElementsBind = showElements - if showElements == true then - showElementsBind = showEnabledAnonymousBind - end - -- These two fields are necessary to prevent chrome from filling in LDAP username and password with saved credentials - -- Chrome, in fact, ignores the autocomplete=off on the input field. The input fill-in triggers un-necessary are-you-sure leave message - print('') - print('') - -- - prefsInputFieldPrefs("LDAP Bind DN", "Bind Distinguished Name of LDAP server. Example: \"CN=ntop_users,DC=ntop,DC=org,DC=local\".", "ntopng.prefs.ldap", "bind_dn", "", nil, showElementsBind, true, false, {attributes={spellcheck="false"}}) - prefsInputFieldPrefs("LDAP Bind Authentication Password", "Bind password used for authenticating with the LDAP server.", "ntopng.prefs.ldap", "bind_pwd", "", "password", showElementsBind, true, false) - - prefsInputFieldPrefs("LDAP Search Path", "Root path used to search the users.", "ntopng.prefs.ldap", "search_path", "", "text", showElements, nil, nil, {attributes={spellcheck="false"}}) - prefsInputFieldPrefs("LDAP User Group", "Group name to which user has to belong in order to authenticate as unprivileged user.", "ntopng.prefs.ldap", "user_group", "", "text", showElements, nil, nil, {attributes={spellcheck="false"}}) - prefsInputFieldPrefs("LDAP Admin Group", "Group name to which user has to belong in order to authenticate as an administrator.", "ntopng.prefs.ldap", "admin_group", "", "text", showElements, nil, nil, {attributes={spellcheck="false"}}) - - end print('') print('') - print [[ - - - ]] + print('
') + print('') + + print('') + local labels = {"Local","LDAP","LDAP/Local"} + local values = {"local","ldap","ldap_local"} + local elementToSwitch = {"row_multiple_ldap_account_type", "row_toggle_ldap_anonymous_bind","server","bind_dn", "bind_pwd", "ldap_server_address", "search_path", "user_group", "admin_group"} + local showElementArray = {false, true, true} + local javascriptAfterSwitch = ""; + javascriptAfterSwitch = javascriptAfterSwitch.." if($(\"#id-toggle-multiple_ldap_authentication\").val() != \"local\" ) {\n" + javascriptAfterSwitch = javascriptAfterSwitch.." if($(\"#toggle_ldap_anonymous_bind_input\").val() == \"0\") {\n" + javascriptAfterSwitch = javascriptAfterSwitch.." $(\"#bind_dn\").css(\"display\",\"table-row\");\n" + javascriptAfterSwitch = javascriptAfterSwitch.." $(\"#bind_pwd\").css(\"display\",\"table-row\");\n" + javascriptAfterSwitch = javascriptAfterSwitch.." } else {\n" + javascriptAfterSwitch = javascriptAfterSwitch.." $(\"#bind_dn\").css(\"display\",\"none\");\n" + javascriptAfterSwitch = javascriptAfterSwitch.." $(\"#bind_pwd\").css(\"display\",\"none\");\n" + javascriptAfterSwitch = javascriptAfterSwitch.." }\n" + javascriptAfterSwitch = javascriptAfterSwitch.." }\n" + local retVal = multipleTableButtonPrefs("Authentication Method", + "Local (Local only), LDAP (LDAP server only), LDAP/Local (Authenticate with LDAP server, if fails it uses local authentication).", + labels, values, "local", "primary", "multiple_ldap_authentication", "ntopng.prefs.auth_type", nil, + elementToSwitch, showElementArray, javascriptAfterSwitch) + + local showElements = true; + if ntop.getPref("ntopng.prefs.auth_type") == "local" then + showElements = false + end + + local labels_account = {"Posix","sAMAccount"} + local values_account = {"posix","samaccount"} + multipleTableButtonPrefs("LDAP Accounts Type", + "Choose your account type", + labels_account, values_account, "posix", "primary", "multiple_ldap_account_type", "ntopng.prefs.ldap.account_type", nil, nil, nil, nil, showElements) + + prefsInputFieldPrefs("LDAP Server Address", "IP address and port of LDAP server (e.g. ldaps://localhost:636). Default: \"ldap://localhost:389\".", "ntopng.prefs.ldap", "ldap_server_address", "ldap://localhost:389", nil, showElements, true, true, {attributes={pattern="ldap(s)?://[0-9.\\-A-Za-z]+(:[0-9]+)?", spellcheck="false", required="required"}}) + + local elementToSwitchBind = {"bind_dn","bind_pwd"} + toggleTableButtonPrefs("LDAP Anonymous Binding","Enable anonymous binding.","On", "1", "success", "Off", "0", "danger", "toggle_ldap_anonymous_bind", "ntopng.prefs.ldap.anonymous_bind", "0", nil, elementToSwitchBind, true, showElements) + + local showEnabledAnonymousBind = false + if ntop.getPref("ntopng.prefs.ldap.anonymous_bind") == "0" then + showEnabledAnonymousBind = true + end + local showElementsBind = showElements + if showElements == true then + showElementsBind = showEnabledAnonymousBind + end + -- These two fields are necessary to prevent chrome from filling in LDAP username and password with saved credentials + -- Chrome, in fact, ignores the autocomplete=off on the input field. The input fill-in triggers un-necessary are-you-sure leave message + print('') + print('') + -- + prefsInputFieldPrefs("LDAP Bind DN", "Bind Distinguished Name of LDAP server. Example: \"CN=ntop_users,DC=ntop,DC=org,DC=local\".", "ntopng.prefs.ldap", "bind_dn", "", nil, showElementsBind, true, false, {attributes={spellcheck="false"}}) + prefsInputFieldPrefs("LDAP Bind Authentication Password", "Bind password used for authenticating with the LDAP server.", "ntopng.prefs.ldap", "bind_pwd", "", "password", showElementsBind, true, false) + + prefsInputFieldPrefs("LDAP Search Path", "Root path used to search the users.", "ntopng.prefs.ldap", "search_path", "", "text", showElements, nil, nil, {attributes={spellcheck="false"}}) + prefsInputFieldPrefs("LDAP User Group", "Group name to which user has to belong in order to authenticate as unprivileged user.", "ntopng.prefs.ldap", "user_group", "", "text", showElements, nil, nil, {attributes={spellcheck="false"}}) + prefsInputFieldPrefs("LDAP Admin Group", "Group name to which user has to belong in order to authenticate as an administrator.", "ntopng.prefs.ldap", "admin_group", "", "text", showElements, nil, nil, {attributes={spellcheck="false"}}) + + print('') + print('
Authentication
') + print [[]] + print('
') end -- ================================================================================ @@ -621,12 +609,6 @@ function printStatsRrds() toggleTableButtonPrefs("Host Pools Timeseries", "Toggle the creation of bytes and nDPI timeseries for defined Host Pools.", "On", "1", "success", "Off", "0", "danger", "toggle_pools_rrds", "ntopng.prefs.host_pools_rrd_creation", "0") - - toggleTableButtonPrefs("SNMP Devices Timeseries", - "Toggle the creation of bytes timeseries for each port of the SNMP devices. For each device port" .. - " will be created an RRD with ingress/egress bytes.", - "On", "1", "success", "Off", "0", "danger", "toggle_snmp_rrds", "ntopng.prefs.snmp_devices_rrd_creation", "0", - not info["version.enterprise_edition"]) end toggleTableButtonPrefs("Category Timeseries", @@ -690,6 +672,26 @@ function printLogging() ]] end +function printSnmp() + if not ntop.isPro() then return end + + print('
') + print('') + print('') + + toggleTableButtonPrefs("SNMP Devices Timeseries", + "Toggle the creation of bytes timeseries for each port of the SNMP devices. For each device port" .. + " will be created an RRD with ingress/egress bytes.", + "On", "1", "success", "Off", "0", "danger", "toggle_snmp_rrds", "ntopng.prefs.snmp_devices_rrd_creation", "0", + not info["version.enterprise_edition"]) + + print('') + + print [[ + +
SNMP
]] +end + print[[ @@ -784,12 +786,18 @@ end if(tab == "users") then printUsers() end +if(tab == "auth") then + printAuthentication() +end if(tab == "ifaces") then printInterfaces() end if(tab == "logging") then printLogging() end +if(tab == "snmp") then + printSnmp() +end print[[