Sha256: 0b3360e1ec971eb757d644cd9ec3860e2fbe63383d940b4fb87db842bfd7b671

Contents?: true

Size: 1.52 KB

Versions: 3

Compression:

Stored size: 1.52 KB

Contents

module Saml
  module Kit
    # This class parses a LogoutRequest SAML document.
    class LogoutRequest < Document
      include Requestable
      validates_presence_of :single_logout_service, if: :expected_type?

      def initialize(xml, configuration: Saml::Kit.configuration)
        super(xml, name: "LogoutRequest", configuration: configuration)
      end

      # Returns the NameID value.
      def name_id
        to_h[name]['NameID']
      end

      # Generates a Serialized LogoutResponse using the encoding rules for the specified binding.
      #
      # @param binding [Symbol] The binding to use `:http_redirect` or `:http_post`.
      # @param relay_state [Object] The RelayState to include in the RelayState param.
      # @return [Array] Returns an array with a url and Hash of parameters to return to the requestor.
      def response_for(binding:, relay_state: nil)
        builder = Saml::Kit::LogoutResponse.builder(self) do |x|
          yield x if block_given?
        end
        response_binding = provider.single_logout_service_for(binding: binding)
        response_binding.serialize(builder, relay_state: relay_state)
      end

      # @deprecated Use {#Saml::Kit::Builders::LogoutRequest} instead of this.
      Builder = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('Saml::Kit::LogoutRequest::Builder', 'Saml::Kit::Builders::LogoutRequest')

      private

      def single_logout_service
        return if provider.nil?
        urls = provider.single_logout_services
        urls.first
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
saml-kit-0.2.14 lib/saml/kit/logout_request.rb
saml-kit-0.2.13 lib/saml/kit/logout_request.rb
saml-kit-0.2.12 lib/saml/kit/logout_request.rb