[prev in list] [next in list] [prev in thread] [next in thread] 

List:       luci-commits
Subject:    [Luci-commits] [luci/pkg-update] repoze.who.auth_tkt: avoid problem with v. <1.0.14
From:       jpokorny () fedoraproject ! org (Jan Pokorny)
Date:       2010-11-29 22:40:25
Message-ID: 20101129224025.B71A6120276 () lists ! fedorahosted ! org
[Download RAW message or body]

commit 030b718ceba136758a7795c9d64682f25fa15c02
Author: Jan Pokorny <jpokorny at redhat.com>
Date:   Tue Nov 23 18:46:18 2010 +0100

    repoze.who.auth_tkt: avoid problem with v. <1.0.14

 luci/config/config.tmpl.in |    2 +-
 luci/initwrappers.py       |   34 ++++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 1 deletions(-)
---
diff --git a/luci/config/config.tmpl.in b/luci/config/config.tmpl.in
index 5e9a8bb..a5d7f77 100644
--- a/luci/config/config.tmpl.in
+++ b/luci/config/config.tmpl.in
@@ -179,7 +179,7 @@ post_login_url =
 post_logout_url =
 
 [plugin:auth_tkt]
-use = repoze.who.plugins.auth_tkt:make_plugin
+use = luci.initwrappers:auth_tkt_make_plugin
 secret = ${app_instance_secret}
 timeout = 900
 reissue_time = 60
diff --git a/luci/initwrappers.py b/luci/initwrappers.py
index 1b8b8ca..c9339cc 100644
--- a/luci/initwrappers.py
+++ b/luci/initwrappers.py
@@ -13,3 +13,37 @@ from pylons.util import PylonsInstaller as _PylonsInstaller
 
 class PylonsInstaller(_PylonsInstaller):
     config_file = 'config/config.tmpl'
+
+
+# This is a workaround for problem, that repoze.who < 1.0.14 cannot handle
+# "timeout" and "reissue_time" (+ "userid_checker") parameters when passed
+# into make_plugin function of repoze.who.plugins.auth_tkt.
+#
+# The only remaining problem is that the session will not timeout after some
+# time of inactivity in case of repoze.who < 1.0.14.
+def auth_tkt_make_plugin(secret=None,
+                         secretfile=None,
+                         cookie_name='auth_tkt',
+                         secure=False,
+                         include_ip=False,
+                         timeout=None,
+                         reissue_time=None,
+                         userid_checker=None):
+    # We can presume that this package and function exist (see setup.py).
+    from repoze.who.plugins.auth_tkt import make_plugin
+    try:
+        return make_plugin(secret=secret,
+                           secretfile=secretfile,
+                           cookie_name=cookie_name,
+                           secure=secure,
+                           include_ip=include_ip,
+                           timeout=timeout,
+                           reissue_time=reissue_time,
+                           userid_checker=userid_checker)
+    except TypeError:
+        # Workaround for repoze.who < 1.0.14 case.
+        return make_plugin(secret=secret,
+                           secretfile=secretfile,
+                           cookie_name=cookie_name,
+                           secure=secure,
+                           include_ip=include_ip)

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic