Module: SAML2::Bindings::HTTP_POST
- Defined in:
- lib/saml2/bindings/http_post.rb
Overview
rubocop:disable Naming/ClassAndModuleCamelCase
Constant Summary collapse
- URN =
"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
Class Method Summary collapse
-
.decode(post_params) ⇒ [Message, String]
Decode and parse a Base64 encoded SAML message.
-
.encode(message, relay_state: nil) ⇒ Hash<String => String>
Encode a SAML message into Base64 POST params.
Class Method Details
.decode(post_params) ⇒ [Message, String]
Decode and parse a Base64 encoded SAML message.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/saml2/bindings/http_post.rb', line 18 def decode(post_params) base64 = post_params["SAMLRequest"] || post_params["SAMLResponse"] raise MissingMessage unless base64 raise MessageTooLarge if base64.bytesize > SAML2.config[:max_message_size] xml = begin Base64.decode64(base64) rescue ArgumentError raise CorruptMessage end = Message.parse(xml) [, post_params["RelayState"]] end |
.encode(message, relay_state: nil) ⇒ Hash<String => String>
Encode a SAML message into Base64 POST params.
41 42 43 44 45 46 47 |
# File 'lib/saml2/bindings/http_post.rb', line 41 def encode(, relay_state: nil) xml = .to_s(pretty: false) key = .is_a?(Request) ? "SAMLRequest" : "SAMLResponse" post_params = { key => Base64.encode64(xml) } post_params["RelayState"] = relay_state if relay_state post_params end |