Commit 7c80ae8

mo <mo@mokhan.ca>
2017-11-18 01:36:52
push up version.
1 parent aaa19d1
lib/saml/kit/authentication_request.rb
@@ -77,12 +77,14 @@ module Saml
 
       class Builder
         attr_accessor :id, :now, :issuer, :acs_url, :name_id_format, :sign, :destination
+        attr_accessor :version
 
         def initialize(configuration: Saml::Kit.configuration, sign: true)
           @id = SecureRandom.uuid
           @issuer = configuration.issuer
           @name_id_format = Namespaces::PERSISTENT
           @now = Time.now.utc
+          @version = "2.0"
           @sign = sign
         end
 
@@ -107,7 +109,7 @@ module Saml
             "xmlns:samlp" => Namespaces::PROTOCOL,
             "xmlns:saml" => Namespaces::ASSERTION,
             ID: "_#{id}",
-            Version: "2.0",
+            Version: version,
             IssueInstant: now.utc.iso8601,
             Destination: destination,
           }
lib/saml/kit/document.rb
@@ -23,6 +23,10 @@ module Saml
         to_h.fetch(name, {}).fetch('Issuer', nil)
       end
 
+      def version
+        to_h.fetch(name, {}).fetch('Version', {})
+      end
+
       def to_h
         @xml_hash
       end
lib/saml/kit/logout_request.rb
@@ -16,10 +16,6 @@ module Saml
         to_h[name]['IssueInstant']
       end
 
-      def version
-        to_h[name]['Version']
-      end
-
       def destination
         to_h[name]['Destination']
       end
@@ -77,7 +73,7 @@ module Saml
 
       class Builder
         attr_accessor :id, :destination, :issuer, :name_id_format, :now
-        attr_accessor :sign
+        attr_accessor :sign, :version
         attr_reader :user
 
         def initialize(user, configuration: Saml::Kit.configuration, sign: true)
@@ -86,6 +82,7 @@ module Saml
           @issuer = configuration.issuer
           @name_id_format = Saml::Kit::Namespaces::PERSISTENT
           @now = Time.now.utc
+          @version = "2.0"
           @sign = sign
         end
 
@@ -109,7 +106,7 @@ module Saml
         def logout_request_options
           {
             ID: "_#{id}",
-            Version: "2.0",
+            Version: version,
             IssueInstant: now.utc.iso8601,
             Destination: destination,
             xmlns: Namespaces::PROTOCOL,
lib/saml/kit/logout_response.rb
@@ -9,10 +9,6 @@ module Saml
         to_h[name]['IssueInstant']
       end
 
-      def version
-        to_h[name]['Version']
-      end
-
       def status_code
         to_h[name]['Status']['StatusCode']['Value']
       end
lib/saml/kit/response.rb
@@ -46,10 +46,6 @@ module Saml
         to_h.fetch(name, {}).fetch('Destination', nil)
       end
 
-      def version
-        to_h.fetch(name, {}).fetch('Version', {})
-      end
-
       def started_at
         parse_date(to_h.fetch(name, {}).fetch('Assertion', {}).fetch('Conditions', {}).fetch('NotBefore', nil))
       end