Class: Samlr::Tools::MetadataBuilder
- Defined in:
- lib/samlr/tools/metadata_builder.rb
Overview
Builds you some SP metadata. Accepts a hash with the below keys. No support for arrays of name id formats or asserion consumer services, build it if you need it.
:entity_id => "https://sp.example.org/saml", # mandatory
:name_identity_format => Samlr::EMAIL_FORMAT,
:consumer_service_url => "https://sp.example.org/saml"
Class Method Summary collapse
Class Method Details
.build(options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/samlr/tools/metadata_builder.rb', line 12 def self.build( = {}) name_identity_format = [:name_identity_format] consumer_service_url = [:consumer_service_url] consumer_service_binding = [:consumer_service_binding] || "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" = [:metadata_id] || Samlr::Tools.uuid = [:sign_metadata] || false # Mandatory entity_id = .fetch(:entity_id) builder = Nokogiri::XML::Builder.new do |xml| xml.EntityDescriptor("xmlns:md" => NS_MAP["md"], "ID" => , "entityID" => entity_id) do xml.doc.root.namespace = xml.doc.root.namespace_definitions.find { |ns| ns.prefix == "md" } xml["md"].SPSSODescriptor("protocolSupportEnumeration" => NS_MAP["samlp"]) do unless name_identity_format.nil? xml["md"].NameIDFormat(name_identity_format) end unless consumer_service_url.nil? xml["md"].AssertionConsumerService("index" => "0", "Binding" => consumer_service_binding, "Location" => consumer_service_url) end end end end = builder.doc if = .merge(namespaces: []) = ResponseBuilder.sign(, , ) end .to_xml(COMPACT) end |