Sha256: 2e70b5400056708e4e4622637074606e628c1508cd11ada07c371671772a5ebd

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

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
        at_xpath('./*/samlp:Status/samlp:StatusCode/@Value').try(:value)
      end

      # Returns the /InResponseTo attribute.
      def in_response_to
        at_xpath('./*/@InResponseTo').try(:value)
      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?
        return if in_response_to == request_id

        errors[:in_response_to] << error_message(:invalid_response_to)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
saml-kit-1.0.14 lib/saml/kit/respondable.rb
saml-kit-1.0.13 lib/saml/kit/respondable.rb
saml-kit-1.0.12 lib/saml/kit/respondable.rb
saml-kit-1.0.11 lib/saml/kit/respondable.rb
saml-kit-1.0.10 lib/saml/kit/respondable.rb