Adds option to disable session autologut via web preferences

Automatic logout can be toggled via web preferences. Precedence is
given to the startup parameter -p, i.e., if auto-logout has been
explicitly disabled via command line, no toggle button is shown.
Contrarily, if the auto-logout has not been explicitly disabled during startup, then
the user can toggle it via web preferences.

Implements #440
This commit is contained in:
Simone Mainardi 2016-03-14 20:25:44 +01:00
parent fe8d39419e
commit 77adcbef0e
4 changed files with 55 additions and 31 deletions

View file

@ -36,6 +36,17 @@ if(haveAdminPrivileges()) then
"Select the throughput unit to be displayed in traffic reports.",
"Bytes", "bps", "primary","Packets", "pps", "primary","toggle_thpt_content", "ntopng.prefs.thpt_content")
-- if autologout has not been explicitly disabled via command-line, then we allow
-- changes at runtime
if prefs.is_autologout_enabled == true then
print('<tr><th colspan=2 class="info">Web User Interface</th></tr>')
toggleTableButton("Auto Logout",
"Toggle the automatic logout of web interface users with expired sessions.",
"On", "1", "success", "Off", "0", "danger", "toggle_autologout", "ntopng.prefs.is_autologon_enabled")
end
-- ================================================================================
print('<tr><th colspan=2 class="info">Traffic Metrics Storage (RRD)</th></tr>')
@ -49,10 +60,10 @@ if(haveAdminPrivileges()) then
"On", "1", "success", "Off", "0", "danger", "toggle_local_ndpi", "ntopng.prefs.host_ndpi_rrd_creation")
toggleTableButton("Category RRDs For Local Hosts and Networks",
"Toggle the creation of Category RRDs for local hosts and defined networks. Enabling their creation allows you "..
"to keep persistent traffic category statistics (e.g., social networks, news) at the cost of using more disk space.<br>"..
"Creation is only possible if the ntopng instance has been launched with option -k flashstart:&lt;user&gt;:&lt;password&gt;.",
"On", "1", "success", "Off", "0", "danger", "toggle_local_categorization", "ntopng.prefs.host_categories_rrd_creation", not prefs.is_categorization_enabled)
"Toggle the creation of Category RRDs for local hosts and defined networks. Enabling their creation allows you "..
"to keep persistent traffic category statistics (e.g., social networks, news) at the cost of using more disk space.<br>"..
"Creation is only possible if the ntopng instance has been launched with option -k flashstart:&lt;user&gt;:&lt;password&gt;.",
"On", "1", "success", "Off", "0", "danger", "toggle_local_categorization", "ntopng.prefs.host_categories_rrd_creation", not prefs.is_categorization_enabled)
-- ================================================================================
print('<tr><th colspan=2 class="info">MySQL Database</th></tr>')
@ -97,8 +108,8 @@ if (ntop.isPro()) then
if((nbox_password == nil) or (nbox_password == "")) then nbox_password = "nbox" end
toggleTableButton("Enable nBox Support",
"Enable sending ntopng requests (e.g., to download pcap files) to an nBox. Pcap requests are issued from the historical data browser when browsing 'Talkers' and 'Protocols'. Each request carry information on the search criteria generated by the user when drilling-down historical data. Requests are queued and pcaps become available for download from a dedicated 'Pcaps' tab once generated.",
"On", "1", "success", "Off", "0", "danger", "toggle_nbox_integration", "ntopng.prefs.nbox_integration")
"Enable sending ntopng requests (e.g., to download pcap files) to an nBox. Pcap requests are issued from the historical data browser when browsing 'Talkers' and 'Protocols'. Each request carry information on the search criteria generated by the user when drilling-down historical data. Requests are queued and pcaps become available for download from a dedicated 'Pcaps' tab once generated.",
"On", "1", "success", "Off", "0", "danger", "toggle_nbox_integration", "ntopng.prefs.nbox_integration")
if ntop.getCache("ntopng.prefs.nbox_integration") == "1" then
prefsInputField("nBox Host", "Address of the nBox host. Default: localhost", "nbox_host", nbox_host)
prefsInputField("nBox User", "User that has privileges to access the nBox. Default: nbox", "nbox_user", nbox_user)
@ -124,32 +135,32 @@ if (ntop.isPro()) then
local labels = {"Local","LDAP","LDAP/Local"}
local values = {"local","ldap","ldap_local"}
local retVal = multipleTableButton("LDAP Authentication",
"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")
"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")
if ((retVal == "ldap") or (retVal == "ldap_local")) then
local ldap_server = ntop.getCache("ntopng.prefs.ldap.server")
if((ldap_server == nil) or (ldap_server == "")) then
ldap_server = "ldap://localhost:389"
ntop.setCache("ntopng.prefs.ldap.server", ldap_server)
ldap_server = "ldap://localhost:389"
ntop.setCache("ntopng.prefs.ldap.server", ldap_server)
end
local labels_account = {"Posix","sAMAccount"}
local values_account = {"posix","samaccount"}
multipleTableButton("LDAP Accounts Type",
"Choose your account type",
labels_account, values_account, "posix", "primary", "multiple_ldap_account_type", "ntopng.prefs.ldap.account_type")
"Choose your account type",
labels_account, values_account, "posix", "primary", "multiple_ldap_account_type", "ntopng.prefs.ldap.account_type")
prefsInputFieldWithParamCheck("LDAP Server Address", "IP address and port of LDAP server (e.g. ldaps://localhost:636). Default: \"ldap://localhost:389\".", "ntopng.prefs.ldap", "server", ldap_server, "text", js_body_funtion_script)
local anonymous_bind = ntop.getCache("ntopng.prefs.ldap.anonymous_bind")
if((anonymous_bind == nil) or (anonymous_bind == "")) then ntop.setCache("ntopng.prefs.ldap.anonymous_bind", "0") end
toggleTableButton("LDAP Anonymous Binding",
"Enable anonymous binding.",
"On", "1", "success", "Off", "0", "danger", "toggle_ldap_anonymous_bind", "ntopng.prefs.ldap.anonymous_bind")
"Enable anonymous binding.",
"On", "1", "success", "Off", "0", "danger", "toggle_ldap_anonymous_bind", "ntopng.prefs.ldap.anonymous_bind")
if ntop.getCache("ntopng.prefs.ldap.anonymous_bind") == "0" then
local ldap_bind_dn = ntop.getCache("ntopng.prefs.ldap.bind_dn")
if(ldap_bind_dn == nil) then ldap_bind_dn = "" end
prefsInputFieldWithParamCheck("LDAP Bind DN", "Bind Distinguished Name of LDAP server. Example: \"CN=ntop_users,DC=ntop,DC=org,DC=local\".", "ntopng.prefs.ldap", "bind_dn", ldap_bind_dn, "text", nil)
local ldap_bind_pwd = ntop.getCache("ntopng.prefs.ldap.bind_pwd")
if(ldap_bind_pwd == nil) then ldap_bind_pwd = "" end
prefsInputFieldWithParamCheck("LDAP Bind Authentication Password", "Bind password used for authenticating with the LDAP server.", "ntopng.prefs.ldap", "bind_pwd", ldap_bind_pwd, "password", nil)
local ldap_bind_dn = ntop.getCache("ntopng.prefs.ldap.bind_dn")
if(ldap_bind_dn == nil) then ldap_bind_dn = "" end
prefsInputFieldWithParamCheck("LDAP Bind DN", "Bind Distinguished Name of LDAP server. Example: \"CN=ntop_users,DC=ntop,DC=org,DC=local\".", "ntopng.prefs.ldap", "bind_dn", ldap_bind_dn, "text", nil)
local ldap_bind_pwd = ntop.getCache("ntopng.prefs.ldap.bind_pwd")
if(ldap_bind_pwd == nil) then ldap_bind_pwd = "" end
prefsInputFieldWithParamCheck("LDAP Bind Authentication Password", "Bind password used for authenticating with the LDAP server.", "ntopng.prefs.ldap", "bind_pwd", ldap_bind_pwd, "password", nil)
end
local ldap_search_path = ntop.getCache("ntopng.prefs.ldap.search_path")
if(ldap_search_path == nil) then ldap_search_path = "" end
@ -171,15 +182,15 @@ if(false) then
local message = "Toggle generation of daily reports in PDF format."
local disable = false
if (not havePDFRenderer(getUsedPDFRenderer())) then
disable = true
message = message.." Install "..getUsedPDFRenderer().." to enable this."
disable = true
message = message.." Install "..getUsedPDFRenderer().." to enable this."
elseif (not ntop.isLoginDisabled()) then
disable = true
message = message..' Start ntopng with the "-l" option to enable this.'
disable = true
message = message..' Start ntopng with the "-l" option to enable this.'
end
toggleTableButton("Generate Reports Daily",
message, "On", "1", "success", "Off", "0", "danger",
"toggle_daily_reports", "ntopng.prefs.daily_reports", disable)
message, "On", "1", "success", "Off", "0", "danger",
"toggle_daily_reports", "ntopng.prefs.daily_reports", disable)
end
end