Class: Saml::Kit::LogoutRequest

Inherits:
Document
  • Object
show all
Includes:
Requestable
Defined in:
lib/saml/kit/logout_request.rb

Overview

This class can be used to parse a LogoutRequest SAML document.

document = Saml::Kit::LogoutRequest.new(raw_xml)

It can also be used to generate a new LogoutRequest.

document = Saml::Kit::LogoutRequest.build do |builder|
  builder.issuer = "issuer"
end

puts document.to_xml(pretty: true)

See Builders::LogoutRequest for a list of available settings.

This class can also be used to generate the correspondong LogoutResponse for a LogoutRequest.

document = Saml::Kit::LogoutRequest.new(raw_xml)
url, saml_params = document.response_for(binding: :http_post)

See #response_for for more information.

Constant Summary

Constants inherited from Document

Document::NAMESPACES, Document::PROTOCOL_XSD, Document::XPATH

Instance Method Summary collapse

Methods inherited from Document

#destination, #id, #issue_instant, #issuer, #to_h, #to_s, to_saml_document, #to_xhtml, #to_xml, #version

Methods included from Trustable

#signed?, #trusted?

Constructor Details

#initialize(xml, configuration: Saml::Kit.configuration) ⇒ LogoutRequest

A new instance of LogoutRequest

Parameters:

  • The raw xml string.

  • (defaults to: Saml::Kit.configuration)

    the configuration to use.



33
34
35
# File 'lib/saml/kit/logout_request.rb', line 33

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

Instance Method Details

#name_idObject

Returns the NameID value.



38
39
40
# File 'lib/saml/kit/logout_request.rb', line 38

def name_id
  to_h[name]['NameID']
end

#response_for(binding:, relay_state: nil) ⇒ Array

Generates a Serialized LogoutResponse using the encoding rules for the specified binding.

Parameters:

  • The binding to use :http_redirect or :http_post.

  • (defaults to: nil)

    The RelayState to include in the RelayState param.

Returns:

  • Returns an array with a url and Hash of parameters to return to the requestor.



47
48
49
50
51
52
53
# File 'lib/saml/kit/logout_request.rb', line 47

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