Allow turning off security at install time
[cascardo/ipsilon.git] / ipsilon / providers / saml2idp.py
index 0ac2a72..e89fe0c 100755 (executable)
@@ -246,16 +246,16 @@ class Installer(object):
     def install_args(self, group):
         group.add_argument('--saml2', choices=['yes', 'no'], default='yes',
                            help='Configure SAML2 Provider')
-        group.add_argument('--saml2-storage',
-                           default='/var/lib/ipsilon/saml2',
-                           help='SAML2 Provider storage area')
+        group.add_argument('--saml2-secure',
+                           choices=['yes', 'no'], default='yes',
+                           help='Configure SAML2 Provider')
 
     def configure(self, opts):
         if opts['saml2'] != 'yes':
             return
 
         # Check storage path is present or create it
-        path = opts['saml2_storage']
+        path = os.path.join(opts['data_dir'], 'saml2')
         if not os.path.exists(path):
             os.makedirs(path, 0700)
 
@@ -264,14 +264,17 @@ class Installer(object):
         cert.generate('idp', opts['hostname'])
 
         # Generate Idp Metadata
-        url = 'https://' + opts['hostname'] + '/idp/saml2'
+        proto = 'https'
+        if opts['saml2_secure'].lower() == 'no':
+            proto = 'http'
+        url = '%s://%s/%s/saml2' % (proto, opts['hostname'], opts['instance'])
         meta = metadata.Metadata(metadata.IDP_ROLE)
         meta.set_entity_id(url + '/metadata')
         meta.add_certs(cert, cert)
         meta.add_service(metadata.SAML2_SERVICE_MAP['sso-post'],
-                         url + 'SSO/POST')
+                         url + '/SSO/POST')
         meta.add_service(metadata.SAML2_SERVICE_MAP['sso-redirect'],
-                         url + 'SSO/Redirect')
+                         url + '/SSO/Redirect')
 
         meta.add_allowed_name_format(
             lasso.SAML2_NAME_IDENTIFIER_FORMAT_TRANSIENT)
@@ -294,7 +297,8 @@ class Installer(object):
         config = {'idp storage path': path,
                   'idp metadata file': 'metadata.xml',
                   'idp certificate file': cert.cert,
-                  'idp key file': cert.key}
+                  'idp key file': cert.key,
+                  'enabled': '1'}
         po.set_config(config)
         po.save_plugin_config(FACILITY)