[Kimchi-devel] [PATCH][Wok 2/2] Issue #133: Kimchi is logging out due to session timeout even when user is typing or using the webpage

Ramon Medeiros ramonn at linux.vnet.ibm.com
Wed Jul 20 19:38:56 UTC 2016



On 07/20/2016 03:06 PM, Paulo Ricardo Paz Vital wrote:
> On Jul 20 02:24PM, Ramon Medeiros wrote:
>> Adds a header "Session-Expires-On" returning the remaining time to
>> expire the session.
>>
>> Signed-off-by: Ramon Medeiros <ramonn at linux.vnet.ibm.com>
>> ---
>>   src/wok/template.py | 15 +++++++++++++++
>>   1 file changed, 15 insertions(+)
>>
>> diff --git a/src/wok/template.py b/src/wok/template.py
>> index 68243d9..43a34db 100644
>> --- a/src/wok/template.py
>> +++ b/src/wok/template.py
>> @@ -22,14 +22,18 @@
>>   import cherrypy
>>   import errno
>>   import json
>> +import time
>>   from Cheetah.Template import Template
>>   from glob import iglob
>>
>>
>> +from wok import config as config
>>   from wok.config import paths
>>
>> +EXPIRES_ON = 'Session-Expires-On'
>>   REFRESH = 'robot-refresh'
>>
>> +
>>   def get_lang():
>>       cookie = cherrypy.request.cookie
>>       if "wokLang" in cookie.keys():
>> @@ -110,6 +114,17 @@ def render_cheetah_file(resource, data):
>>
>>
>>   def render(resource, data):
>> +    # get timeout and last refresh
>> +    s_timeout = float(config.config.get("server", "session_timeout"))
>> +    cherrypy.session.acquire_lock()
>> +    last_req = cherrypy.session.get(REFRESH)
>> +    cherrypy.session.release_lock()
>> +
>> +    # last_request is present: calculate remaining time
>> +    if last_req is not None:
>> +        session_expires = (float(last_req) + (s_timeout * 60)) - time.time()
>> +        cherrypy.response.headers[EXPIRES_ON] = session_expires
> As commented by Aline on RFC, was requested on
> https://github.com/kimchi-project/wok/issues/133#issuecomment-232752799
> the time the session will expires since last request, so I guess the
> correct formula is:
>
> session_expires = (float(last_req) + (s_timeout * 60))
>
> Doesn't?
just check with Peter Pennings,

he says that is easier to deal just with the remaining time.

He is also copied here
>> +
>>       if can_accept('application/json'):
>>           cherrypy.response.headers['Content-Type'] = \
>>               'application/json;charset=utf-8'
>> -- 
>> 2.5.5
>>
>> _______________________________________________
>> Kimchi-devel mailing list
>> Kimchi-devel at ovirt.org
>> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>>

-- 

Ramon Nunes Medeiros
Kimchi Developer
Linux Technology Center Brazil
IBM Systems & Technology Group
Phone : +55 19 2132 7878
ramonn at br.ibm.com




More information about the Kimchi-devel mailing list