summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2014-09-26 17:38:30 -0400
committerPatrick Uiterwijk <puiterwijk@redhat.com>2014-10-06 20:27:49 +0200
commita6ed2bba137df5fb8a9fb2931ccb2d92ca3fa0e0 (patch)
tree3f5be4b5a17f99978e9090b3ed1e3668d70c06e0
parentfec439b3d8d3d636388fa4a72bb48adfe51520f2 (diff)
downloadipsilon-a6ed2bba137df5fb8a9fb2931ccb2d92ca3fa0e0.tar.gz
ipsilon-a6ed2bba137df5fb8a9fb2931ccb2d92ca3fa0e0.tar.xz
ipsilon-a6ed2bba137df5fb8a9fb2931ccb2d92ca3fa0e0.zip
Fix storing login plugin status and order
When plugins were enabled or disabled their status was not stored in the database, unless the order was explicitly manipulated. Moreover if the order was changed that fact would not be refrlected in the actual authntication order until a restart. Fix the code to always permanently store the enabled/disabled status, and to immediately change the authentication order. Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
-rwxr-xr-xipsilon/admin/login.py31
1 files changed, 25 insertions, 6 deletions
diff --git a/ipsilon/admin/login.py b/ipsilon/admin/login.py
index 62522fc..bb79f90 100755
--- a/ipsilon/admin/login.py
+++ b/ipsilon/admin/login.py
@@ -25,6 +25,15 @@ from ipsilon.admin.common import AdminPluginPage
from ipsilon.login.common import FACILITY
+def save_enabled_plugins(names):
+ po = PluginObject()
+ po.name = "global"
+ globalconf = dict()
+ globalconf['order'] = ','.join(names)
+ po.set_config(globalconf)
+ po.save_plugin_config(FACILITY)
+
+
class LoginPluginsOrder(Page):
def __init__(self, site, parent):
@@ -32,6 +41,18 @@ class LoginPluginsOrder(Page):
self.url = '%s/order' % parent.url
self.menu = [parent]
+ def _reorder_plugins(self, order):
+ plugins = self._site[FACILITY]['available']
+ root = self._site[FACILITY]['root']
+ prev_obj = None
+ for name in order:
+ if prev_obj is None:
+ root.first_login = plugins[name]
+ else:
+ prev_obj.next_login = plugins[name]
+ prev_obj = plugins[name]
+ prev_obj.next_login = None
+
@admin_protect
def GET(self, *args, **kwargs):
opts = [p.name for p in self._site[FACILITY]['enabled']]
@@ -66,12 +87,8 @@ class LoginPluginsOrder(Page):
new_names.append(val)
new_plugins.append(plugins_by_name[val])
- po = PluginObject()
- po.name = "global"
- globalconf = dict()
- globalconf['order'] = ','.join(new_names)
- po.set_config(globalconf)
- po.save_plugin_config(FACILITY)
+ save_enabled_plugins(new_names)
+ self._reorder_plugins(new_names)
# When all is saved update also live config. The
# live config is a list of the actual plugin
@@ -139,6 +156,7 @@ class LoginPlugins(Page):
obj = plugins['available'][plugin]
if obj not in plugins['enabled']:
obj.enable(self._site)
+ save_enabled_plugins(list(x.name for x in plugins['enabled']))
msg = "Plugin %s enabled" % obj.name
return self.root_with_msg(msg, "success")
enable.exposed = True
@@ -152,6 +170,7 @@ class LoginPlugins(Page):
obj = plugins['available'][plugin]
if obj in plugins['enabled']:
obj.disable(self._site)
+ save_enabled_plugins(list(x.name for x in plugins['enabled']))
msg = "Plugin %s disabled" % obj.name
return self.root_with_msg(msg, "success")
disable.exposed = True