Sha256: dbae3399156821f30e3c5e83f24c6b51441efb3703fa3bb89bffbec90028c2e2

Contents?: true

Size: 848 Bytes

Versions: 12

Compression:

Stored size: 848 Bytes

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

      def query_string_parameter
        'SAMLResponse'
      end

      def status_code
        to_h.fetch(name, {}).fetch('Status', {}).fetch('StatusCode', {}).fetch('Value', nil)
      end

      def in_response_to
        to_h.fetch(name, {}).fetch('InResponseTo', nil)
      end

      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

12 entries across 12 versions & 1 rubygems

Version Path
saml-kit-0.2.11 lib/saml/kit/respondable.rb
saml-kit-0.2.10 lib/saml/kit/respondable.rb
saml-kit-0.2.9 lib/saml/kit/respondable.rb
saml-kit-0.2.8 lib/saml/kit/respondable.rb
saml-kit-0.2.7 lib/saml/kit/respondable.rb
saml-kit-0.2.6 lib/saml/kit/respondable.rb
saml-kit-0.2.5 lib/saml/kit/respondable.rb
saml-kit-0.2.4 lib/saml/kit/respondable.rb
saml-kit-0.2.3 lib/saml/kit/respondable.rb
saml-kit-0.2.2 lib/saml/kit/respondable.rb
saml-kit-0.2.1 lib/saml/kit/respondable.rb
saml-kit-0.2.0 lib/saml/kit/respondable.rb