Commit 453ac5b

mokha <mokha@cisco.com>
2017-12-19 21:21:47
generate multiple signing certificates.
1 parent b5a5701
Changed files (2)
app
models
config
initializers
app/models/idp.rb
@@ -5,22 +5,24 @@ class Idp
         begin
           host = "#{request.protocol}#{request.host}:#{request.port}"
           url_helpers = Rails.application.routes.url_helpers
-          Saml::Kit::IdentityProviderMetadata.build do |builder|
-            builder.sign = false
+          Saml::Kit::Metadata.build do |builder|
+            builder.embed_signature = false
             builder.contact_email = 'hi@example.com'
             builder.organization_name = "Acme, Inc"
             builder.organization_url = url_helpers.root_url(host: host)
-            builder.add_single_sign_on_service(url_helpers.new_session_url(host: host), binding: :http_post)
-            builder.add_single_sign_on_service(url_helpers.new_session_url(host: host), binding: :http_redirect)
-            builder.add_single_logout_service(url_helpers.logout_url(host: host), binding: :http_post)
-            builder.name_id_formats = [
-              Saml::Kit::Namespaces::EMAIL_ADDRESS,
-              Saml::Kit::Namespaces::PERSISTENT,
-              Saml::Kit::Namespaces::TRANSIENT,
-            ]
-            builder.attributes << :id
-            builder.attributes << :email
-            builder.attributes << :created_at
+            builder.build_identity_provider do |x|
+              x.add_single_sign_on_service(url_helpers.new_session_url(host: host), binding: :http_post)
+              x.add_single_sign_on_service(url_helpers.new_session_url(host: host), binding: :http_redirect)
+              x.add_single_logout_service(url_helpers.logout_url(host: host), binding: :http_post)
+              x.name_id_formats = [
+                Saml::Kit::Namespaces::EMAIL_ADDRESS,
+                Saml::Kit::Namespaces::PERSISTENT,
+                Saml::Kit::Namespaces::TRANSIENT,
+              ]
+              x.attributes << :id
+              x.attributes << :email
+              x.attributes << :created_at
+            end
           end
         end
     end
config/initializers/saml_kit.rb
@@ -13,6 +13,5 @@ Saml::Kit.configure do |configuration|
   configuration.issuer = ENV['ISSUER']
   configuration.registry = OnDemandRegistry.new(configuration.registry)
   configuration.logger = Rails.logger
-  configuration.generate_key_pair_for(use: :signing)
-  configuration.generate_key_pair_for(use: :signing)
+  5.times { configuration.generate_key_pair_for(use: :signing) }
 end