Class: Saml::Kit::Bindings::UrlBuilder

Inherits:
Object
  • Object
show all
Includes:
Serializable
Defined in:
lib/saml/kit/bindings/url_builder.rb

Overview

This class is responsible for generating a url as per the rules for the HTTP redirect binding specification. docs.oasis-open.org/security/saml/v2.0/saml-bindings-2.0-os.pdf

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Serializable

#decode, #deflate, #encode, #escape, #inflate, #unescape

Constructor Details

#initialize(configuration: Saml::Kit.configuration) ⇒ UrlBuilder

Returns a new instance of UrlBuilder


16
17
18
# File 'lib/saml/kit/bindings/url_builder.rb', line 16

def initialize(configuration: Saml::Kit.configuration)
  @configuration = configuration
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration


14
15
16
# File 'lib/saml/kit/bindings/url_builder.rb', line 14

def configuration
  @configuration
end

Instance Method Details

#build(document, relay_state: nil) ⇒ Object


20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/saml/kit/bindings/url_builder.rb', line 20

def build(document, relay_state: nil)
  destination = document.destination
  if configuration.sign?
    payload = canonicalize(document, relay_state)
    "#{destination}?#{payload}&Signature=#{signature_for(payload)}"
  else
    "#{destination}?" + to_query_string(
      document.query_string_parameter => serialize(document.to_xml),
      'RelayState' => relay_state
    )
  end
end