ruby-saml 0.4.0 → 0.4.1

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.

data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
@@ -5,13 +5,15 @@ module Onelogin::Saml
5
5
  class Response
6
6
  ASSERTION = "urn:oasis:names:tc:SAML:2.0:assertion"
7
7
  PROTOCOL = "urn:oasis:names:tc:SAML:2.0:protocol"
8
+ DSIG = "http://www.w3.org/2000/09/xmldsig#"
8
9
 
9
- attr_accessor :response, :document, :logger, :settings
10
+ attr_accessor :response, :document, :logger, :settings, :original
10
11
 
11
12
  def initialize(response)
12
13
  raise ArgumentError.new("Response cannot be nil") if response.nil?
13
14
  self.response = response
14
15
  self.document = XMLSecurity::SignedDocument.new(Base64.decode64(response))
16
+ self.original = XMLSecurity::SignedDocument.new(Base64.decode64(response))
15
17
  end
16
18
 
17
19
  def is_valid?
@@ -25,7 +27,8 @@ module Onelogin::Saml
25
27
  # The value of the user identifier as designated by the initialization request response
26
28
  def name_id
27
29
  @name_id ||= begin
28
- node = REXML::XPath.first(document, "/p:Response/a:Assertion/a:Subject/a:NameID", { "p" => PROTOCOL, "a" => ASSERTION })
30
+ uri = REXML::XPath.first(original, "//ds:Signature/ds:SignedInfo/ds:Reference", {"ds"=>DSIG}).attribute("URI").value
31
+ node = REXML::XPath.first(document, "/p:Response/a:Assertion[@ID='#{uri[1,uri.size]}']/a:Subject/a:NameID", { "p" => PROTOCOL, "a" => ASSERTION })
29
32
  node.text
30
33
  end
31
34
  end
data/ruby-saml.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruby-saml}
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["OneLogin LLC"]
12
- s.date = %q{2011-05-03}
12
+ s.date = %q{2011-06-03}
13
13
  s.description = %q{SAML toolkit for Ruby on Rails}
14
14
  s.email = %q{support@onelogin.com}
15
15
  s.extra_rdoc_files = [
@@ -30,9 +30,11 @@ Gem::Specification.new do |s|
30
30
  "lib/ruby-saml.rb",
31
31
  "lib/xml_security.rb",
32
32
  "ruby-saml.gemspec",
33
+ "test/responses/certificate1",
33
34
  "test/responses/response1.xml.base64",
34
35
  "test/responses/response2.xml.base64",
35
36
  "test/responses/response3.xml.base64",
37
+ "test/responses/response4.xml.base64",
36
38
  "test/ruby-saml_test.rb",
37
39
  "test/test_helper.rb",
38
40
  "test/xml_security_test.rb"
@@ -0,0 +1,12 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIBrTCCAaGgAwIBAgIBATADBgEAMGcxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApD
3
+ YWxpZm9ybmlhMRUwEwYDVQQHDAxTYW50YSBNb25pY2ExETAPBgNVBAoMCE9uZUxv
4
+ Z2luMRkwFwYDVQQDDBBhcHAub25lbG9naW4uY29tMB4XDTEwMDMwOTA5NTgzNFoX
5
+ DTE1MDMwOTA5NTgzNFowZzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3Ju
6
+ aWExFTATBgNVBAcMDFNhbnRhIE1vbmljYTERMA8GA1UECgwIT25lTG9naW4xGTAX
7
+ BgNVBAMMEGFwcC5vbmVsb2dpbi5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJ
8
+ AoGBANtmwriqGBbZy5Dwy2CmJEtHEENVPoATCZP3UDESRDQmXy9Q0Kq1lBt+KyV4
9
+ kJNHYAAQ9egLGWQ8/1atkPBye5s9fxROtf8VO3uk/x/X5VSRODIrhFISGmKUnVXa
10
+ UhLFIXkGSCAIVfoR5S2ggdfpINKUWGsWS/lEzLNYMBkURXuVAgMBAAEwAwYBAAMB
11
+ AA==
12
+ -----END CERTIFICATE-----
@@ -0,0 +1,93 @@
1
+ PHNhbWxwOlJlc3BvbnNlIH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Tc6MDJaIiBOb3RPbk9yQWZ0ZXI9IjIwMTEt
83
+ MDYtMDRUMDI6Mjc6MDJaIj48c2FtbDpBdWRpZW5jZVJlc3RyaWN0aW9uPjxz
84
+ YW1sOkF1ZGllbmNlPmF1ZGllbmNlPC9zYW1sOkF1ZGllbmNlPjwvc2FtbDpB
85
+ dWRpZW5jZVJlc3RyaWN0aW9uPjwvc2FtbDpDb25kaXRpb25zPjxzYW1sOkF1
86
+ dGhuU3RhdGVtZW50IEF1dGhuSW5zdGFudD0iMjAxMS0wNi0wNFQwMjoyMjow
87
+ MloiIFNlc3Npb25Ob3RPbk9yQWZ0ZXI9IjIwMTEtMDYtMDVUMDI6MjI6MDJa
88
+ IiBTZXNzaW9uSW5kZXg9Il8xNmY1NzBmYmMwMzE1MDA3YTAzNTVkZmVhNmIz
89
+ YzQ2YyI+PHNhbWw6QXV0aG5Db250ZXh0PjxzYW1sOkF1dGhuQ29udGV4dENs
90
+ YXNzUmVmPnVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDphYzpjbGFzc2Vz
91
+ OlBhc3N3b3JkUHJvdGVjdGVkVHJhbnNwb3J0PC9zYW1sOkF1dGhuQ29udGV4
92
+ dENsYXNzUmVmPjwvc2FtbDpBdXRobkNvbnRleHQ+PC9zYW1sOkF1dGhuU3Rh
93
+ dGVtZW50Pjwvc2FtbDpBc3NlcnRpb24+PC9zYW1scDpSZXNwb25zZT4=
@@ -38,6 +38,15 @@ class RubySamlTest < Test::Unit::TestCase
38
38
  response = Onelogin::Saml::Response.new(response_document_3)
39
39
  assert !response.name_id.nil?
40
40
  end
41
+
42
+ should "not allow signature wrapping attack" do
43
+ response = Onelogin::Saml::Response.new(response_document_4)
44
+ settings = Onelogin::Saml::Settings.new
45
+ response.settings = settings
46
+ settings.idp_cert_fingerprint = signature_fingerprint_1
47
+ assert response.is_valid?
48
+ assert response.name_id == "test@onelogin.com"
49
+ end
41
50
 
42
51
  context "#is_valid?" do
43
52
  should "return false when response is initialized with blank data" do
data/test/test_helper.rb CHANGED
@@ -20,4 +20,12 @@ class Test::Unit::TestCase
20
20
  @response_document3 ||= File.read(File.join(File.dirname(__FILE__), 'responses', 'response3.xml.base64'))
21
21
  end
22
22
 
23
+ def response_document_4
24
+ @response_document4 ||= File.read(File.join(File.dirname(__FILE__), 'responses', 'response4.xml.base64'))
25
+ end
26
+
27
+ def signature_fingerprint_1
28
+ @signature_fingerprint1 ||= "C5:19:85:D9:47:F1:BE:57:08:20:25:05:08:46:EB:27:F6:CA:B7:83"
29
+ end
30
+
23
31
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-saml
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 0
10
- version: 0.4.0
9
+ - 1
10
+ version: 0.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - OneLogin LLC
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-03 00:00:00 +02:00
18
+ date: 2011-06-03 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -99,9 +99,11 @@ files:
99
99
  - lib/ruby-saml.rb
100
100
  - lib/xml_security.rb
101
101
  - ruby-saml.gemspec
102
+ - test/responses/certificate1
102
103
  - test/responses/response1.xml.base64
103
104
  - test/responses/response2.xml.base64
104
105
  - test/responses/response3.xml.base64
106
+ - test/responses/response4.xml.base64
105
107
  - test/ruby-saml_test.rb
106
108
  - test/test_helper.rb
107
109
  - test/xml_security_test.rb