Sha256: efd1785f57c462c15c41b142276a1c66510a96f43baf193ffa4ce9b6ceee4224

Contents?: true

Size: 1.02 KB

Versions: 21

Compression:

Stored size: 1.02 KB

Contents

module Saml
  module Kit
    module Respondable
      extend ActiveSupport::Concern
      attr_reader :request_id

      included do
        validates_inclusion_of :status_code, in: [Namespaces::SUCCESS]
        validate :must_match_request_id
      end

      # @!visibility private
      def query_string_parameter
        'SAMLResponse'
      end

      # Returns the /Status/StatusCode@Value
      def status_code
        to_h.fetch(name, {}).fetch('Status', {}).fetch('StatusCode', {}).fetch('Value', nil)
      end

      # Returns the /InResponseTo attribute.
      def in_response_to
        to_h.fetch(name, {}).fetch('InResponseTo', nil)
      end

      # Returns true if the Status code is #{Saml::Kit::Namespaces::SUCCESS}
      def success?
        Namespaces::SUCCESS == status_code
      end

      private

      def must_match_request_id
        return if request_id.nil?

        if in_response_to != request_id
          errors[:in_response_to] << error_message(:invalid_response_to)
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
saml-kit-1.0.6 lib/saml/kit/respondable.rb
saml-kit-1.0.5 lib/saml/kit/respondable.rb
saml-kit-1.0.4 lib/saml/kit/respondable.rb
saml-kit-1.0.3 lib/saml/kit/respondable.rb
saml-kit-1.0.2 lib/saml/kit/respondable.rb
saml-kit-1.0.1 lib/saml/kit/respondable.rb
saml-kit-1.0.0 lib/saml/kit/respondable.rb
saml-kit-0.3.6 lib/saml/kit/respondable.rb
saml-kit-0.3.5 lib/saml/kit/respondable.rb
saml-kit-0.3.4 lib/saml/kit/respondable.rb
saml-kit-0.3.3 lib/saml/kit/respondable.rb
saml-kit-0.3.2 lib/saml/kit/respondable.rb
saml-kit-0.3.1 lib/saml/kit/respondable.rb
saml-kit-0.3.0 lib/saml/kit/respondable.rb
saml-kit-0.2.18 lib/saml/kit/respondable.rb
saml-kit-0.2.17 lib/saml/kit/respondable.rb
saml-kit-0.2.16 lib/saml/kit/respondable.rb
saml-kit-0.2.15 lib/saml/kit/respondable.rb
saml-kit-0.2.14 lib/saml/kit/respondable.rb
saml-kit-0.2.13 lib/saml/kit/respondable.rb