saml-kit 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '029d3a033d81aac8add1be06a783516f239b7b38cec4bb6e701e010c80b82e98'
4
- data.tar.gz: a29f4fd46aa450d8392376cdb38fe2510575b7a51e1217987719f1828c1defbc
3
+ metadata.gz: c496796275792465ee1906c67364da02c7633058aa58ba06cd8f3471f24aadf7
4
+ data.tar.gz: '090aef04081e81bad6805fecbc73daeaa88fdeaf2d88dbcaeb42c8e204416e0f'
5
5
  SHA512:
6
- metadata.gz: 694fe63f05d9b011d998f4c144faf75f9b852e63ad01badf522b23e654038c5d6655334a24b9c366d5920df0f01772fbfdf0190c5946cbca79a007b1a74eb64c
7
- data.tar.gz: 4b497ec560bbd279cc957ee2765bd1e6f1ea48a591e54a58f434522984bcf0ebcf210e343b8a02ecc0e268d6d95221cd21138fb2b655b008203f0520cc8cebb4
6
+ metadata.gz: f1c3064dfb1e0ae83c665d6e43da37ad639b384491b1100d5c3cdf4b52a6f18e3cf169cb81e4b93516dffc4b73b3f3318c99d6e43b4fb5684c51503917437ff4
7
+ data.tar.gz: '020684ed30855042cf53c804ec1e12355ffe1ac032365abc94de85b757c8e330418435cde36cc8e081d231a7cccbf8777012adfff44e4003d02d26b14eaecf23'
@@ -48,10 +48,14 @@ module Saml
48
48
  protected
49
49
 
50
50
  def saml_param_from(params)
51
- if params['SAMLRequest'].present?
52
- params['SAMLRequest']
53
- elsif params['SAMLResponse'].present?
54
- params['SAMLResponse']
51
+ parameters = {
52
+ SAMLRequest: params[:SAMLRequest] || params['SAMLRequest'],
53
+ SAMLResponse: params[:SAMLResponse] || params['SAMLResponse'],
54
+ }
55
+ if parameters[:SAMLRequest].present?
56
+ parameters[:SAMLRequest]
57
+ elsif parameters[:SAMLResponse].present?
58
+ parameters[:SAMLResponse]
55
59
  else
56
60
  raise ArgumentError.new("SAMLRequest or SAMLResponse parameter is required.")
57
61
  end
@@ -10,10 +10,14 @@ module Saml
10
10
  end
11
11
 
12
12
  def build(saml_document, relay_state: nil)
13
- payload = canonicalize(saml_document, relay_state)
14
13
  if configuration.sign?
14
+ payload = canonicalize(saml_document, relay_state)
15
15
  "#{saml_document.destination}?#{payload}&Signature=#{signature_for(payload)}"
16
16
  else
17
+ payload = to_query_string(
18
+ saml_document.query_string_parameter => serialize(saml_document.to_xml),
19
+ 'RelayState' => relay_state,
20
+ )
17
21
  "#{saml_document.destination}?#{payload}"
18
22
  end
19
23
  end
@@ -26,11 +30,15 @@ module Saml
26
30
  end
27
31
 
28
32
  def canonicalize(saml_document, relay_state)
29
- {
33
+ to_query_string(
30
34
  saml_document.query_string_parameter => serialize(saml_document.to_xml),
31
35
  'RelayState' => relay_state,
32
36
  'SigAlg' => Saml::Kit::Namespaces::SHA256,
33
- }.map do |(key, value)|
37
+ )
38
+ end
39
+
40
+ def to_query_string(query_params)
41
+ query_params.map do |(key, value)|
34
42
  value.present? ? "#{key}=#{escape(value)}" : nil
35
43
  end.compact.join('&')
36
44
  end
@@ -17,7 +17,7 @@ module Saml
17
17
  end
18
18
 
19
19
  def add_key_pair(certificate, private_key, password:, use: :signing)
20
- @key_pairs.push(KeyPair.new(certificate, private_key, password, use))
20
+ @key_pairs.push(KeyPair.new(certificate, private_key, password, use.to_sym))
21
21
  end
22
22
 
23
23
  def generate_key_pair_for(use:, password: SecureRandom.uuid)
@@ -29,8 +29,8 @@ module Saml
29
29
  end
30
30
  end
31
31
 
32
- def login_request_for(binding:, relay_state: nil)
33
- builder = Saml::Kit::AuthenticationRequest.builder do |x|
32
+ def login_request_for(binding:, relay_state: nil, configuration: Saml::Kit.configuration)
33
+ builder = Saml::Kit::AuthenticationRequest.builder(configuration: configuration) do |x|
34
34
  x.embed_signature = want_authn_requests_signed
35
35
  yield x if block_given?
36
36
  end
@@ -1,7 +1,7 @@
1
1
  module Saml
2
2
  module Kit
3
3
  class KeyPair
4
- attr_reader :certificate, :private_key
4
+ attr_reader :certificate, :private_key, :use
5
5
 
6
6
  def initialize(certificate, private_key, password, use)
7
7
  @use = use
@@ -1,5 +1,5 @@
1
1
  module Saml
2
2
  module Kit
3
- VERSION = "0.2.7"
3
+ VERSION = "0.2.8"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saml-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - mo khan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-16 00:00:00.000000000 Z
11
+ date: 2017-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel