From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 6 Feb 2008 05:19:58 -0000 Subject: [Cluster-devel] conga/luci/site/luci/Extensions LuciZope.py Lu ... Message-ID: <20080206051958.7254.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 --- conga/luci/site/luci/Extensions/LuciZope.py 2008/01/02 21:00:31 1.7 +++ conga/luci/site/luci/Extensions/LuciZope.py 2008/02/06 05:19:57 1.8 @@ -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) --- conga/luci/site/luci/Extensions/LuciZopeExternal.py 2008/01/22 15:05:17 1.7 +++ conga/luci/site/luci/Extensions/LuciZopeExternal.py 2008/02/06 05:19:57 1.8 @@ -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 --- conga/luci/site/luci/Extensions/conga_constants.py 2008/01/02 21:00:32 1.47 +++ conga/luci/site/luci/Extensions/conga_constants.py 2008/02/06 05:19:57 1.48 @@ -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.'