But there’s a gotcha here. Nokogiri has a Nokogiri::XML module with a few constants: XML_C14N_1_0, XML_C14N_EXCLUSIVE_1_0, and. XML_C14N_1_1. These constants are utilized depending on the standard serialization of the SAML XML being processed during the single sign on handshakes between your application and the identity provider.
Now during SAML authentication, a request is made to a SAML initialization action in your controller. This action collects some settings, which are then passed to your identity provider.
If you are using the Ruby SAML Toolkit, your identity provider is probably OneLogin, but it doesn’t have to be.
It is during the response.is_valid? call that you can run into problems. The Ruby SAMLToolkit requires nokogiri to contain the XML module constants mentioned above. Older versions of nokogiri may give you a “Missing Constant Error: XML_C14N_EXCLUSIVE_1_0”, or a missing constant error with one of the other constants.
To remedy this, try updating to the latest version of nokogiri, which at the time of this article is 1.6.2.1. But be careful, nokogiri 1.6 and higher now bundles libxml2 with the gem. If this update gives you any trouble, this StackOverflow article may help.