@@ -74,24 +74,33 @@ settings.security[:signature_method] = RubySaml::XML::RSA_SHA1
7474### Replacement of REXML with Nokogiri
7575
7676RubySaml ` 1.x ` used a combination of REXML and Nokogiri for XML parsing and generation.
77- In ` 2.0.0 ` , REXML has been replaced with Nokogiri. This change should be transparent
78- to most users, however, see note about Custom Metadata Fields below.
77+ In ` 2.0.0 ` , REXML has been replaced with Nokogiri. As a result, there are minor differences
78+ in how XML is generated, ncluding SAML requests and SP Metadata:
79+
80+ 1 . All XML namespace declarations will be on the root node of the XML. Previously,
81+ some declarations such as ` xmlns:ds ` were done on child nodes.
82+ 2 . The ordering of attributes on each node may be different.
83+
84+ These differences should not affect how the XML is parsed by various XML parsing libraries.
85+ However, if you are strictly asserting that the generated XML is an exact string in your tests,
86+ such tests may need to be adjusted accordingly.
7987
8088### Custom Metadata Fields now use Nokogiri XML Builder
8189
8290If you have added custom fields to your SP metadata generation by overriding
83- the ` RubySaml::Metadata#add_extras ` method, you will need to update your code to use
84- [ Nokogiri::XML::Builder] ( https://nokogiri.org/rdoc/Nokogiri/XML/Builder.html ) format
85- instead of REXML. Here is an example of the new format:
91+ the ` RubySaml::Metadata#add_extras ` method, you will need to update your code
92+ so that the first arg of the method is a
93+ [ Nokogiri::XML::Builder] ( https://nokogiri.org/rdoc/Nokogiri/XML/Builder.html )
94+ object. Here is an example of the new format:
8695
8796``` ruby
8897class MyMetadata < RubySaml ::Metadata
8998 private
9099
91- def add_extras (xml , _settings )
92- xml[ ' md ' ] .ContactPerson (' contactType' => ' technical' ) do
93- xml[ ' md ' ] .GivenName ( ' ACME SAML Team' )
94- xml[ ' md ' ] .EmailAddress ( ' saml@acme.com' )
100+ def add_extras (builder , _settings )
101+ builder .ContactPerson (' contactType' => ' technical' ) do
102+ builder .GivenName { builder.text ' ACME SAML Team' }
103+ builder .EmailAddress { builder.text ' saml@acme.com' }
95104 end
96105 end
97106end
0 commit comments