summaryrefslogtreecommitdiffstats
path: root/ipsilon/providers/saml2idp.py
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2014-09-12 17:17:59 -0400
committerPatrick Uiterwijk <puiterwijk@redhat.com>2014-09-24 20:29:08 +0200
commite841faf4a5e729aff8831ef72dab41adb51d6cf0 (patch)
treec908fe817707ed46ee208a4d8e80a540671b775f /ipsilon/providers/saml2idp.py
parentb6429073a1c3e158adb9f4c32be99d96a289ac74 (diff)
downloadipsilon-e841faf4a5e729aff8831ef72dab41adb51d6cf0.tar.gz
ipsilon-e841faf4a5e729aff8831ef72dab41adb51d6cf0.tar.xz
ipsilon-e841faf4a5e729aff8831ef72dab41adb51d6cf0.zip
Allow deferred initialization of providers
This fixes enabling a provider after the sever is started. Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
Diffstat (limited to 'ipsilon/providers/saml2idp.py')
-rwxr-xr-xipsilon/providers/saml2idp.py52
1 files changed, 31 insertions, 21 deletions
diff --git a/ipsilon/providers/saml2idp.py b/ipsilon/providers/saml2idp.py
index a1247d5..a19899c 100755
--- a/ipsilon/providers/saml2idp.py
+++ b/ipsilon/providers/saml2idp.py
@@ -113,27 +113,6 @@ class SAML2(ProviderPageBase):
def __init__(self, *args, **kwargs):
super(SAML2, self).__init__(*args, **kwargs)
self.metadata = Metadata(*args, **kwargs)
-
- # Init IDP data
- try:
- self.cfg.idp = IdentityProvider(self.cfg)
- except Exception, e: # pylint: disable=broad-except
- self._debug('Failed to init SAML2 provider: %r' % e)
- return
-
- # Import all known applications
- data = self.cfg.get_data()
- for idval in data:
- sp = data[idval]
- if 'type' not in sp or sp['type'] != 'SP':
- continue
- if 'name' not in sp or 'metadata' not in sp:
- continue
- try:
- self.cfg.idp.add_provider(sp)
- except Exception, e: # pylint: disable=broad-except
- self._debug('Failed to add SP %s: %r' % (sp['name'], e))
-
self.SSO = SSO(*args, **kwargs)
@@ -233,10 +212,41 @@ Provides SAML 2.0 authentication infrastructure. """
return self.get_config_value('default email domain')
def get_tree(self, site):
+ self.idp = self.init_idp()
self.page = SAML2(site, self)
self.admin = AdminPage(site, self)
return self.page
+ def init_idp(self):
+ idp = None
+ # Init IDP data
+ try:
+ idp = IdentityProvider(self)
+ except Exception, e: # pylint: disable=broad-except
+ self._debug('Failed to init SAML2 provider: %r' % e)
+ return None
+
+ # Import all known applications
+ data = self.get_data()
+ for idval in data:
+ sp = data[idval]
+ if 'type' not in sp or sp['type'] != 'SP':
+ continue
+ if 'name' not in sp or 'metadata' not in sp:
+ continue
+ try:
+ idp.add_provider(sp)
+ except Exception, e: # pylint: disable=broad-except
+ self._debug('Failed to add SP %s: %r' % (sp['name'], e))
+
+ return idp
+
+ def on_enable(self):
+ self.init_idp()
+ if hasattr(self, 'admin'):
+ if self.admin:
+ self.admin.add_sps()
+
class Installer(object):