ruby-saml 0.8.14 → 0.8.15

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ruby-saml might be problematic. Click here for more details.

@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3039afb4b2668c3859e51ae9eff0c1b423d7dda319a7d646b26702de315047af
4
+ data.tar.gz: 2ef188024bd8030c659b499db22b3b28f2ae24930954f8c45cc69c175b8fc4e3
5
+ SHA512:
6
+ metadata.gz: 0ab896476c0de2ebcd71b060dc305d091e3b6c3be7abd81ce702389cb8e8409cbd5730a4a73a71dfdfedbeb7a0081f448ed4aec60737a8ce6c1b6fb966ce9c4f
7
+ data.tar.gz: 203b1fd9b1fa4d23ab66cac8a034d3154a48e243bff21040ae2e873d191e90c0d8b8ccdfee368ca542c306fd58ddcdbeec700047893ae6044b82b406af43de18
@@ -373,15 +373,6 @@ module OneLogin
373
373
  ))
374
374
  end
375
375
 
376
- def get_fingerprint
377
- if settings.idp_cert
378
- cert = OpenSSL::X509::Certificate.new(settings.idp_cert)
379
- Digest::SHA1.hexdigest(cert.to_der).upcase.scan(/../).join(":")
380
- else
381
- settings.idp_cert_fingerprint
382
- end
383
- end
384
-
385
376
  def validate_conditions(soft = true)
386
377
  return true if conditions.nil?
387
378
  return true if options[:skip_conditions]
@@ -430,8 +421,8 @@ module OneLogin
430
421
 
431
422
  opts = {}
432
423
  opts[:fingerprint_alg] = OpenSSL::Digest::SHA1.new
433
- opts[:cert] = settings.idp_cert
434
- fingerprint = get_fingerprint
424
+ opts[:cert] = settings.get_idp_cert
425
+ fingerprint = settings.get_fingerprint
435
426
 
436
427
  unless fingerprint
437
428
  return soft ? false : validation_error("No fingerprint or certificate on settings")
@@ -117,6 +117,32 @@ module OneLogin
117
117
  @single_logout_service_binding = url
118
118
  end
119
119
 
120
+ # Calculates the fingerprint of the IdP x509 certificate.
121
+ # @return [String] The fingerprint
122
+ #
123
+ def get_fingerprint
124
+ idp_cert_fingerprint || begin
125
+ idp_cert = get_idp_cert
126
+ if idp_cert
127
+ Digest::SHA1.hexdigest(idp_cert.to_der).upcase.scan(/../).join(":")
128
+ end
129
+ end
130
+ end
131
+
132
+ # @return [OpenSSL::X509::Certificate|nil] Build the IdP certificate from the settings (previously format it)
133
+ #
134
+ def get_idp_cert
135
+ return nil if idp_cert.nil?
136
+
137
+ if idp_cert.respond_to?(:to_pem)
138
+ idp_cert
139
+ else
140
+ return nil if idp_cert.empty?
141
+ formatted_cert = OneLogin::RubySaml::Utils.format_cert(idp_cert)
142
+ OpenSSL::X509::Certificate.new(formatted_cert)
143
+ end
144
+ end
145
+
120
146
  # @return [OpenSSL::X509::Certificate|nil] Build the SP certificate from the settings (previously format it)
121
147
  #
122
148
  def get_sp_cert
@@ -1,5 +1,5 @@
1
1
  module OneLogin
2
2
  module RubySaml
3
- VERSION = '0.8.14'
3
+ VERSION = '0.8.15'
4
4
  end
5
5
  end
@@ -222,7 +222,11 @@ module XMLSecurity
222
222
  end
223
223
  else
224
224
  if options[:cert]
225
- base64_cert = Base64.encode64(options[:cert].to_pem)
225
+ cert = options[:cert]
226
+ if cert.is_a? String
227
+ cert = OpenSSL::X509::Certificate.new(cert)
228
+ end
229
+ base64_cert = Base64.encode64(cert.to_pem)
226
230
  else
227
231
  return soft ? false : (raise OneLogin::RubySaml::ValidationError.new("Certificate element missing in response (ds:X509Certificate) and not cert provided at settings"))
228
232
  end
@@ -229,6 +229,17 @@ class ResponseTest < Minitest::Test
229
229
  assert response.validate!
230
230
  end
231
231
 
232
+ it "support signature elements with no KeyInfo if cert provided as text" do
233
+ response = OneLogin::RubySaml::Response.new(response_document_valid_signed_without_x509certificate)
234
+ response.stubs(:conditions).returns(nil)
235
+ settings = OneLogin::RubySaml::Settings.new
236
+ response.settings = settings
237
+ settings.idp_cert = ruby_saml_cert_text
238
+ settings.idp_cert_fingerprint = nil
239
+ XMLSecurity::SignedDocument.any_instance.expects(:validate_signature).returns(true)
240
+ assert response.validate!
241
+ end
242
+
232
243
  it "returns an error if the signature contains no KeyInfo, cert is not provided and soft" do
233
244
  response = OneLogin::RubySaml::Response.new(response_document_valid_signed_without_x509certificate)
234
245
  response.stubs(:conditions).returns(nil)
@@ -383,6 +383,11 @@ class XmlSecurityTest < Minitest::Test
383
383
  options[:cert] = idp_cert
384
384
  assert document.document.validate_document(idp_cert, true, options), 'Document should be valid'
385
385
  end
386
+
387
+ it 'is valid if cert text instead x509cert provided' do
388
+ options[:cert] = ruby_saml_cert_text
389
+ assert document.document.validate_document(idp_cert, true, options), 'Document should be valid'
390
+ end
386
391
  end
387
392
 
388
393
  describe 'when response has no cert and you dont provide cert' do
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-saml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.14
5
- prerelease:
4
+ version: 0.8.15
6
5
  platform: ruby
7
6
  authors:
8
7
  - OneLogin LLC
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2020-10-19 00:00:00.000000000 Z
11
+ date: 2020-10-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: uuid
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '2.3'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '2.3'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: nokogiri
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: 1.5.0
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: 1.5.0
46
41
  description: SAML toolkit for Ruby on Rails
@@ -51,9 +46,9 @@ extra_rdoc_files:
51
46
  - LICENSE
52
47
  - README.md
53
48
  files:
54
- - .document
55
- - .gitignore
56
- - .travis.yml
49
+ - ".document"
50
+ - ".gitignore"
51
+ - ".travis.yml"
57
52
  - Gemfile
58
53
  - LICENSE
59
54
  - README.md
@@ -132,28 +127,26 @@ files:
132
127
  - test/xml_security_test.rb
133
128
  homepage: http://github.com/onelogin/ruby-saml
134
129
  licenses: []
130
+ metadata: {}
135
131
  post_install_message:
136
132
  rdoc_options:
137
- - --charset=UTF-8
133
+ - "--charset=UTF-8"
138
134
  require_paths:
139
135
  - lib
140
136
  required_ruby_version: !ruby/object:Gem::Requirement
141
- none: false
142
137
  requirements:
143
- - - ! '>='
138
+ - - ">="
144
139
  - !ruby/object:Gem::Version
145
140
  version: '0'
146
141
  required_rubygems_version: !ruby/object:Gem::Requirement
147
- none: false
148
142
  requirements:
149
- - - ! '>='
143
+ - - ">="
150
144
  - !ruby/object:Gem::Version
151
145
  version: '0'
152
146
  requirements: []
153
- rubyforge_project: http://www.rubygems.org/gems/ruby-saml
154
- rubygems_version: 1.8.23.2
147
+ rubygems_version: 3.0.4
155
148
  signing_key:
156
- specification_version: 3
149
+ specification_version: 4
157
150
  summary: SAML Ruby Tookit
158
151
  test_files:
159
152
  - test/certificates/certificate1