Commit b778bcb
Changed files (4)
lib
saml
kit
lib/saml/kit/builders/authentication_request.rb
@@ -42,7 +42,9 @@ module Saml
IssueInstant: now.utc.iso8601,
Destination: destination,
}
- options[:AssertionConsumerServiceURL] = assertion_consumer_service_url if assertion_consumer_service_url.present?
+ if assertion_consumer_service_url.present?
+ options[:AssertionConsumerServiceURL] = assertion_consumer_service_url
+ end
options
end
end
lib/saml/kit/templatable.rb
@@ -1,27 +1,8 @@
module Saml
module Kit
module Templatable
- def template_name
- "#{self.class.name.split("::").last.underscore}.builder"
- end
-
- def template_path
- File.join(File.expand_path(File.dirname(__FILE__)), "builders/templates/#{template_name}")
- end
-
- def template
- Tilt.new(template_path)
- end
-
def to_xml(xml: ::Builder::XmlMarkup.new)
- signature = Saml::Kit::Signature.new(
- xml,
- configuration: configuration,
- sign: sign
- )
- signature.apply_to(
- template.render(self, xml: xml, signature: signature)
- )
+ Template.new(self).to_xml(xml: xml)
end
end
end
lib/saml/kit/template.rb
@@ -0,0 +1,30 @@
+module Saml
+ module Kit
+ class Template
+ attr_reader :target
+
+ def initialize(target)
+ @target = target
+ end
+
+ def to_xml(xml: ::Builder::XmlMarkup.new)
+ signature = Saml::Kit::Signature.new(xml, configuration: target.configuration, sign: target.sign)
+ signature.apply_to(template.render(target, xml: xml, signature: signature))
+ end
+
+ private
+
+ def template_name
+ "#{target.class.name.split("::").last.underscore}.builder"
+ end
+
+ def template_path
+ File.join(File.expand_path(File.dirname(__FILE__)), "builders/templates/#{template_name}")
+ end
+
+ def template
+ Tilt.new(template_path)
+ end
+ end
+ end
+end
lib/saml/kit.rb
@@ -44,6 +44,7 @@ require "saml/kit/invalid_document"
require "saml/kit/self_signed_certificate"
require "saml/kit/service_provider_metadata"
require "saml/kit/signature"
+require "saml/kit/template"
require "saml/kit/xml"
require "saml/kit/xml_decryption"