summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2014-03-26 15:20:16 -0400
committerSimo Sorce <simo@redhat.com>2014-03-28 14:12:39 -0400
commit0338db2eb3197ce0024d0192bd981120a58de573 (patch)
tree2609cc56f09a5d1513c432db448e28ad408b9aaf
parentd06318be2430b6863a5695f76811bf43a617bade (diff)
downloadipsilon.git-0338db2eb3197ce0024d0192bd981120a58de573.tar.gz
ipsilon.git-0338db2eb3197ce0024d0192bd981120a58de573.tar.xz
ipsilon.git-0338db2eb3197ce0024d0192bd981120a58de573.zip
Basic Identity providers plugin configuration
Signed-off-by: Simo Sorce <simo@redhat.com>
-rwxr-xr-xipsilon/admin/providers.py78
-rwxr-xr-xipsilon/root.py2
-rw-r--r--templates/admin/providers.html20
3 files changed, 100 insertions, 0 deletions
diff --git a/ipsilon/admin/providers.py b/ipsilon/admin/providers.py
new file mode 100755
index 0000000..26e96a7
--- /dev/null
+++ b/ipsilon/admin/providers.py
@@ -0,0 +1,78 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2014 Simo Sorce <simo@redhat.com>
+#
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+import cherrypy
+from ipsilon.util.page import Page
+from ipsilon.providers.common import FACILITY
+from ipsilon.admin.common import AdminPluginPage
+
+
+class ProviderPlugins(Page):
+ def __init__(self, site, parent):
+ super(ProviderPlugins, self).__init__(site)
+ self._master = parent
+ self.title = 'Identity Providers'
+ self.url = '%s/providers' % parent.url
+ self.facility = FACILITY
+ parent.add_subtree('providers', self)
+
+ for plugin in self._site[FACILITY]['available']:
+ cherrypy.log.error('Admin provider plugin: %s' % plugin)
+ obj = self._site[FACILITY]['available'][plugin]
+ self.__dict__[plugin] = AdminPluginPage(obj, self)
+
+ def root_with_msg(self, message=None, message_type=None):
+ plugins = self._site[FACILITY]
+ return self._template('admin/providers.html', title=self.title,
+ baseurl=self.url,
+ message=message,
+ message_type=message_type,
+ available=plugins['available'],
+ enabled=plugins['enabled'],
+ menu=self._master.menu)
+
+ def root(self, *args, **kwargs):
+ return self.root_with_msg()
+
+ def enable(self, plugin):
+ msg = None
+ plugins = self._site[FACILITY]
+ if plugin not in plugins['available']:
+ msg = "Unknown plugin %s" % plugin
+ return self.root_with_msg(msg, "error")
+ obj = plugins['available'][plugin]
+ if obj not in plugins['enabled']:
+ obj.enable(self._site)
+ msg = "Plugin %s enabled" % obj.name
+ return self.root_with_msg(msg, "success")
+ enable.exposed = True
+
+ def disable(self, plugin):
+ msg = None
+ plugins = self._site[FACILITY]
+ if plugin not in plugins['available']:
+ msg = "Unknown plugin %s" % plugin
+ return self.root_with_msg(msg, "error")
+ obj = plugins['available'][plugin]
+ if obj in plugins['enabled']:
+ obj.disable(self._site)
+ msg = "Plugin %s disabled" % obj.name
+ return self.root_with_msg(msg, "success")
+ disable.exposed = True
diff --git a/ipsilon/root.py b/ipsilon/root.py
index c308c95..9451d22 100755
--- a/ipsilon/root.py
+++ b/ipsilon/root.py
@@ -24,6 +24,7 @@ from ipsilon.login.common import Logout
from ipsilon.admin.common import Admin
from ipsilon.providers.common import LoadProviders
from ipsilon.admin.login import LoginPlugins
+from ipsilon.admin.providers import ProviderPlugins
import cherrypy
sites = dict()
@@ -53,6 +54,7 @@ class Root(Page):
# after all plugins are setup we can instantiate the admin pages
self.admin = Admin(self._site, 'admin')
LoginPlugins(self._site, self.admin)
+ ProviderPlugins(self._site, self.admin)
def root(self):
return self._template('index.html', title='Ipsilon')
diff --git a/templates/admin/providers.html b/templates/admin/providers.html
new file mode 100644
index 0000000..18445b6
--- /dev/null
+++ b/templates/admin/providers.html
@@ -0,0 +1,20 @@
+{% extends "master-admin.html" %}
+{% block main %}
+{% if user.is_admin %}
+ <h2>Provider plugins</h2>
+
+ {% for p in available %}
+ <div class="row">
+ <div class="col-md-3 col-sm-3 col-xs-6">{{ p }}</div>
+ <div class="col-md-3 col-sm-3 col-xs-6">
+ {% if available[p] in enabled %}
+ <a class="btn btn-default" href="{{ baseurl }}/disable/{{ p }}">Disable</a>
+ <a class="btn btn-default" href="{{ baseurl }}/{{ p }}">Configure</a>
+ {% else %}
+ <a class="btn btn-default" href="{{ baseurl }}/enable/{{ p }}">Enable</a>
+ {% endif %}
+ </div>
+ </div>
+ {% endfor %}
+{% endif %}
+{% endblock %}