@@ -211,32 +211,8 @@ def validate_signature
211211 return true unless options . has_key? :get_params
212212 return true unless options [ :get_params ] . has_key? 'Signature'
213213
214- # SAML specifies that the signature should be derived from a concatenation
215- # of URI-encoded values _as sent by the IDP_:
216- #
217- # > Further, note that URL-encoding is not canonical; that is, there are multiple legal encodings for a given
218- # > value. The relying party MUST therefore perform the verification step using the original URL-encoded
219- # > values it received on the query string. It is not sufficient to re-encode the parameters after they have been
220- # > processed by software because the resulting encoding may not match the signer's encoding.
221- #
222- # <http://docs.oasis-open.org/security/saml/v2.0/saml-bindings-2.0-os.pdf>
223- #
224- # If we don't have the original parts (for backward compatibility) required to correctly verify the signature,
225- # then fabricate them by re-encoding the parsed URI parameters, and hope that we're lucky enough to use
226- # the exact same URI-encoding as the IDP. (This is not the case if the IDP is ADFS!)
227- options [ :raw_get_params ] ||= { }
228- if options [ :raw_get_params ] [ 'SAMLResponse' ] . nil? && !options [ :get_params ] [ 'SAMLResponse' ] . nil?
229- options [ :raw_get_params ] [ 'SAMLResponse' ] = CGI . escape ( options [ :get_params ] [ 'SAMLResponse' ] )
230- end
231- if options [ :raw_get_params ] [ 'RelayState' ] . nil? && !options [ :get_params ] [ 'RelayState' ] . nil?
232- options [ :raw_get_params ] [ 'RelayState' ] = CGI . escape ( options [ :get_params ] [ 'RelayState' ] )
233- end
234- if options [ :raw_get_params ] [ 'SigAlg' ] . nil? && !options [ :get_params ] [ 'SigAlg' ] . nil?
235- options [ :raw_get_params ] [ 'SigAlg' ] = CGI . escape ( options [ :get_params ] [ 'SigAlg' ] )
236- end
214+ options [ :raw_get_params ] = OneLogin ::RubySaml ::Utils . prepare_raw_get_params ( options [ :raw_get_params ] , options [ :get_params ] )
237215
238- # If we only received the raw version of SigAlg,
239- # then parse it back into the decoded params hash for convenience.
240216 if options [ :get_params ] [ 'SigAlg' ] . nil? && !options [ :raw_get_params ] [ 'SigAlg' ] . nil?
241217 options [ :get_params ] [ 'SigAlg' ] = CGI . unescape ( options [ :raw_get_params ] [ 'SigAlg' ] )
242218 end
0 commit comments