Class: Saml::Kit::Bindings::HttpPost

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

Overview

This class is responsible for serializing/deserializing SAML documents using the HTTP Post binding specification. docs.oasis-open.org/security/saml/v2.0/saml-bindings-2.0-os.pdf

Instance Attribute Summary

Attributes inherited from Binding

#binding, #location

Instance Method Summary collapse

Methods included from Serializable

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

Methods inherited from Binding

#==, #binding?, #eql?, #hash, #inspect, #to_h, #to_s

Constructor Details

#initialize(location:) ⇒ HttpPost

Returns a new instance of HttpPost


15
16
17
# File 'lib/saml/kit/bindings/http_post.rb', line 15

def initialize(location:)
  super(binding: Saml::Kit::Bindings::HTTP_POST, location: location)
end

Instance Method Details

#deserialize(params, configuration: Saml::Kit.configuration) ⇒ Object


30
31
32
33
34
35
36
# File 'lib/saml/kit/bindings/http_post.rb', line 30

def deserialize(params, configuration: Saml::Kit.configuration)
  xml = decode(saml_param_from(params))
  Saml::Kit::Document.to_saml_document(
    xml,
    configuration: configuration
  )
end

#serialize(builder, relay_state: nil) ⇒ Object


19
20
21
22
23
24
25
26
27
28
# File 'lib/saml/kit/bindings/http_post.rb', line 19

def serialize(builder, relay_state: nil)
  builder.destination = location
  document = builder.build
  xml = document.to_xml
  saml_params = {
    document.query_string_parameter => Base64.strict_encode64(xml),
  }
  saml_params['RelayState'] = relay_state if relay_state.present?
  [location, saml_params]
end