Commit e5f29fb

mo <mo@mokhan.ca>
2017-11-16 18:33:09
ignore other bindings.
1 parent 527a2bc
Changed files (2)
lib
saml
spec
lib/saml/kit/binding.rb
@@ -18,7 +18,7 @@ module Saml
           builder.destination = location
           document = builder.build
           [UrlBuilder.new.build(document, relay_state: relay_state), {}]
-        else
+        elsif post?
           builder = document_type::Builder.new(sign: true)
           builder.destination = location
           document = builder.build
@@ -27,6 +27,8 @@ module Saml
             'RelayState' => relay_state,
           }
           [location, saml_params]
+        else
+          []
         end
       end
 
@@ -34,6 +36,10 @@ module Saml
         binding == Namespaces::HTTP_REDIRECT
       end
 
+      def post?
+        binding == Namespaces::POST
+      end
+
       def to_h
         { binding: binding, location: location }
       end
spec/saml/binding_spec.rb
@@ -32,5 +32,10 @@ RSpec.describe Saml::Kit::Binding do
         expect(xml['AuthnRequest']['Signature']).to be_present
       end
     end
+
+    it 'ignores other bindings' do
+      subject = Saml::Kit::Binding.new(binding: 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact', location: location)
+      expect(subject.serialize(Saml::Kit::AuthenticationRequest)).to be_empty
+    end
   end
 end