[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

Paulo Ricardo Paz Vital pvital at linux.vnet.ibm.com
Wed Jul 20 18:06:31 UTC 2016


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?

> +
>      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
> 

-- 
Paulo Ricardo Paz Vital
Linux Technology Center, IBM Systems
http://www.ibm.com/linux/ltc/




More information about the Kimchi-devel mailing list