ruby-saml 0.3.2 → 0.3.3

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.3.2
1
+ 0.3.3
@@ -3,12 +3,17 @@ require "time"
3
3
 
4
4
  module Onelogin::Saml
5
5
  class Response
6
- attr_accessor :response, :document, :logger, :settings
6
+ attr_accessor :response, :document, :logger, :settings, :namespace
7
7
 
8
8
  def initialize(response)
9
9
  raise ArgumentError.new("Response cannot be nil") if response.nil?
10
- self.response = response
11
- self.document = XMLSecurity::SignedDocument.new(Base64.decode64(response))
10
+ self.response = response
11
+ self.document = XMLSecurity::SignedDocument.new(Base64.decode64(response))
12
+ self.namespace = "saml"
13
+
14
+ if document.elements["/#{namespace}p:Response/"].nil?
15
+ self.namespace = "saml2"
16
+ end
12
17
  end
13
18
 
14
19
  def is_valid?
@@ -21,12 +26,12 @@ module Onelogin::Saml
21
26
 
22
27
  # The value of the user identifier as designated by the initialization request response
23
28
  def name_id
24
- @name_id ||= document.elements["/samlp:Response/saml:Assertion/saml:Subject/saml:NameID"].text
29
+ @name_id ||= document.elements["/#{namespace}p:Response/#{namespace}:Assertion/#{namespace}:Subject/#{namespace}:NameID"].text
25
30
  end
26
31
 
27
32
  # A hash of alle the attributes with the response. Assuming there is onlye one value for each key
28
33
  def attributes
29
- saml_attribute_statements = document.elements["/samlp:Response/saml:Assertion/saml:AttributeStatement"].elements
34
+ saml_attribute_statements = document.elements["/#{namespace}p:Response/#{namespace}:Assertion/#{namespace}:AttributeStatement"].elements
30
35
  statements = saml_attribute_statements.map do |child|
31
36
  child.attributes.map do |key, attribute|
32
37
  [attribute, child.elements.first.text]
@@ -39,7 +44,7 @@ module Onelogin::Saml
39
44
 
40
45
  # When this user session should expire at latest
41
46
  def session_expires_at
42
- @expires_at ||= Time.parse(document.elements["/samlp:Response/saml:Assertion/saml:AuthnStatement"].attributes["SessionNotOnOrAfter"])
47
+ @expires_at ||= Time.parse(document.elements["/#{namespace}p:Response/#{namespace}:Assertion/#{namespace}:AuthnStatement"].attributes["SessionNotOnOrAfter"])
43
48
  end
44
49
 
45
50
  private
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruby-saml}
8
- s.version = "0.3.2"
8
+ s.version = "0.3.3"
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-03-08}
12
+ s.date = %q{2011-04-18}
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,7 +30,8 @@ Gem::Specification.new do |s|
30
30
  "lib/ruby-saml.rb",
31
31
  "lib/xml_security.rb",
32
32
  "ruby-saml.gemspec",
33
- "test/response.txt",
33
+ "test/responses/response1.xml.base64",
34
+ "test/responses/response2.xml.base64",
34
35
  "test/ruby-saml_test.rb",
35
36
  "test/test_helper.rb",
36
37
  "test/xml_security_test.rb"
@@ -0,0 +1,79 @@
1
+ PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHNhbWwy
2
+ cDpSZXNwb25zZSB4bWxuczpzYW1sMnA9InVybjpvYXNpczpuYW1lczp0YzpT
3
+ QU1MOjIuMDpwcm90b2NvbCIgRGVzdGluYXRpb249Imh0dHBzOi8vd2liYmxl
4
+ MTI5OTY5MzIwOC5leGFtcGxlLmNvbS9hY2Nlc3Mvc2FtbCIgSUQ9ImlkMTMw
5
+ MzEzOTUyNjA0ODY2MjAwMDE1OTIzNzMwNDciIElzc3VlSW5zdGFudD0iMjAx
6
+ MS0wNC0xOFQxNToxMjowNS45OTRaIiBWZXJzaW9uPSIyLjAiPgogIDxzYW1s
7
+ MjpJc3N1ZXIgeG1sbnM6c2FtbDI9InVybjpvYXNpczpuYW1lczp0YzpTQU1M
8
+ OjIuMDphc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kF1dGhuQ29udGV4dD4KICAgICAgICA8c2FtbDI6QXV0aG5Db250ZXh0
75
+ Q2xhc3NSZWY+dXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOmFjOmNsYXNz
76
+ ZXM6UGFzc3dvcmRQcm90ZWN0ZWRUcmFuc3BvcnQ8L3NhbWwyOkF1dGhuQ29u
77
+ dGV4dENsYXNzUmVmPgogICAgICA8L3NhbWwyOkF1dGhuQ29udGV4dD4KICAg
78
+ IDwvc2FtbDI6QXV0aG5TdGF0ZW1lbnQ+CiAgPC9zYW1sMjpBc3NlcnRpb24+
79
+ Cjwvc2FtbDJwOlJlc3BvbnNlPgo=
@@ -30,6 +30,13 @@ class RubySamlTest < Test::Unit::TestCase
30
30
  assert_raises(ArgumentError) { Onelogin::Saml::Response.new(nil) }
31
31
  end
32
32
 
33
+ should "adapt namespace" do
34
+ response = Onelogin::Saml::Response.new(response_document)
35
+ assert !response.name_id.nil?
36
+ response = Onelogin::Saml::Response.new(response_document_2)
37
+ assert !response.name_id.nil?
38
+ end
39
+
33
40
  context "#is_valid?" do
34
41
  should "return false when response is initialized with blank data" do
35
42
  response = Onelogin::Saml::Response.new('')
@@ -9,6 +9,10 @@ require 'ruby-saml'
9
9
 
10
10
  class Test::Unit::TestCase
11
11
  def response_document
12
- @response_document ||= File.read(File.join(File.dirname(__FILE__), 'response.txt'))
12
+ @response_document ||= File.read(File.join(File.dirname(__FILE__), 'responses', 'response1.xml.base64'))
13
+ end
14
+
15
+ def response_document_2
16
+ @response_document2 ||= File.read(File.join(File.dirname(__FILE__), 'responses', 'response2.xml.base64'))
13
17
  end
14
18
  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: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 2
10
- version: 0.3.2
9
+ - 3
10
+ version: 0.3.3
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-03-08 00:00:00 +01:00
18
+ date: 2011-04-18 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -101,7 +101,8 @@ files:
101
101
  - lib/ruby-saml.rb
102
102
  - lib/xml_security.rb
103
103
  - ruby-saml.gemspec
104
- - test/response.txt
104
+ - test/responses/response1.xml.base64
105
+ - test/responses/response2.xml.base64
105
106
  - test/ruby-saml_test.rb
106
107
  - test/test_helper.rb
107
108
  - test/xml_security_test.rb