Skip to contentSkip to conversation

conga/luci/site/luci/Extensions LuciZope.py Lu ...

Cluster-devel [email protected] 1 participant 1 message Feb 6, 2008

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2008-02-06 05:19:57

Modified files:
luci/site/luci/Extensions: LuciZope.py LuciZopeExternal.py
conga_constants.py

Log message:
backend support for automatic logout due to user inactivity

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZope.py.diff?cvsroot=cluster&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZopeExternal.py.diff?cvsroot=cluster&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_constants.py.diff?cvsroot=cluster&r1=1.47&r2=1.48

luci/site/luci/Extensions/LuciZope.py +24 -0
@@ -163,4 +163,28 @@
 
 	return '/luci/cluster/index_html?pagetype=7&clustername=%s' % clustername
 
+def user_check_inactive(self, request):
+	from time import time
+	from conga_constants import INACTIVITY_TIMEOUT_SEC as INACTIVITY_TIMEOUT
 
+	if not userAuthenticated(self):
+		return
+
+	cur_time = int(time())
+	old_time = request.SESSION.get('last_activity', None)
+	if old_time is None:
+		request.SESSION.set('last_activity', cur_time)
+		return
+	old_time = int(old_time)
+
+	time_diff = cur_time - old_time
+	if time_diff >= INACTIVITY_TIMEOUT:
+		try:
+			request.SESSION.getBrowserIdManager().flushBrowserIdCookie()
+			request.SESSION.invalidate()
+		except Exception, e:
+			if LUCI_DEBUG_MODE is True:
+				luci_log.debug_verbose('UCI0: %r %s' % (e, str(e)))
+		request.RESPONSE.redirect('/luci/logout')
+	else:
+		request.SESSION.set('last_activity', cur_time)
luci/site/luci/Extensions/LuciZopeExternal.py +1 -1
@@ -35,7 +35,7 @@
 
 from LuciZope import appendModel, bytes_to_value_prefunits, \
 	set_persistent_var, strFilter, getTabs, siteIsSetup, \
-	getClusterURL
+	getClusterURL, user_check_inactive
 
 from LuciZopeClusterPortal import createCluChooser, createCluConfigTree
 
luci/site/luci/Extensions/conga_constants.py +1 -0
@@ -136,6 +136,7 @@
 ]
 
 REDIRECT_SEC = 5
+INACTIVITY_TIMEOUT_SEC = 600
 
 # cluster/node create error status messages
 PRE_INSTALL = 'The install state is not yet complete.'