ruby-saml 0.8.17 → 0.8.18

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ec15a6a64795cd0b10b796d6aef230a7d7d439c
4
- data.tar.gz: a07ddee9fb7bfe9ca2f20cde2c9cadfd5bbac121
3
+ metadata.gz: f7f02b4fb1490e44140c1e24ea61bf0ef061f0da
4
+ data.tar.gz: 3b2fec942140bb2fd2e49a17fc29dd0d0327d814
5
5
  SHA512:
6
- metadata.gz: 013b1a3b9b2eb015253dcc4992a1d8be73a3dce996271d701375914e3e7f3e64f6eff3094af1ade43fc807ce452093d05c071cf79b5b2cc8b63d3041688f9344
7
- data.tar.gz: ed258b192c0cbd0b5c589183ecacd9591dad637783430130a9dfd97b6c68c1062520cf91255ed997adf693f1c7f344d84cf0184a821202c8c8ea85509c069864
6
+ metadata.gz: a2dade6d6d672b213a3f8d3af088edfa208f3af4482aae033a40ff8ac9c500ca48fded7eee073e67dd6f37daa27786a6303777e0381a3338f987f87a63f460a2
7
+ data.tar.gz: 0cc6bb2264de5c688545bcb24794313758a97cca3c9bfa5c69b07331ffbc719acb1a69039ec39aa2e5e6817e8917e7495da7c07a41eff120d57f30e9708962bc
@@ -9,7 +9,7 @@ module OneLogin
9
9
 
10
10
  class Authrequest
11
11
  # AuthNRequest ID
12
- attr_reader :uuid
12
+ attr_accessor :uuid
13
13
 
14
14
  # Initializes the AuthNRequest. An Authrequest Object.
15
15
  # Asigns an ID, a random uuid.
@@ -18,6 +18,10 @@ module OneLogin
18
18
  @uuid = OneLogin::RubySaml::Utils.uuid
19
19
  end
20
20
 
21
+ def request_id
22
+ @uuid
23
+ end
24
+
21
25
  def create(settings, params = {})
22
26
  params = create_params(settings, params)
23
27
  params_prefix = (settings.idp_sso_target_url =~ /\?/) ? '&' : '?'
@@ -10,12 +10,16 @@ module OneLogin
10
10
 
11
11
  class Logoutrequest
12
12
 
13
- attr_reader :uuid # Can be obtained if neccessary
13
+ attr_accessor :uuid
14
14
 
15
15
  def initialize
16
16
  @uuid = OneLogin::RubySaml::Utils.uuid
17
17
  end
18
18
 
19
+ def request_id
20
+ @uuid
21
+ end
22
+
19
23
  def create(settings, params={})
20
24
  params = create_params(settings, params)
21
25
  params_prefix = (settings.idp_slo_target_url =~ /\?/) ? '&' : '?'
@@ -32,6 +32,17 @@ module OneLogin
32
32
  @document = XMLSecurity::SignedDocument.new(@response)
33
33
  end
34
34
 
35
+ def response_id
36
+ @response_id ||= begin
37
+ node = REXML::XPath.first(
38
+ document,
39
+ "/p:LogoutResponse",
40
+ { "p" => PROTOCOL }
41
+ )
42
+ node.nil? ? nil : node.attributes['ID']
43
+ end
44
+ end
45
+
35
46
  def validate!
36
47
  validate(false)
37
48
  end
@@ -27,6 +27,24 @@ module OneLogin
27
27
  @document = XMLSecurity::SignedDocument.new(@response)
28
28
  end
29
29
 
30
+ def response_id
31
+ @response_id ||= begin
32
+ node = REXML::XPath.first(
33
+ document,
34
+ "/p:Response",
35
+ { "p" => PROTOCOL }
36
+ )
37
+ node.nil? ? nil : node.attributes['ID']
38
+ end
39
+ end
40
+
41
+ def assertion_id
42
+ @assertion_id ||= begin
43
+ node = xpath_first_from_signed_assertion("")
44
+ node.nil? ? nil : node.attributes['ID']
45
+ end
46
+ end
47
+
30
48
  def is_valid?
31
49
  validate
32
50
  end
@@ -26,6 +26,17 @@ module OneLogin
26
26
  @document = XMLSecurity::SignedDocument.new(@request)
27
27
  end
28
28
 
29
+ def request_id
30
+ @request_id ||= begin
31
+ node = REXML::XPath.first(
32
+ document,
33
+ "/p:LogoutRequest",
34
+ { "p" => PROTOCOL }
35
+ )
36
+ node.nil? ? nil : node.attributes['ID']
37
+ end
38
+ end
39
+
29
40
  def validate!
30
41
  validate(false)
31
42
  end
@@ -12,7 +12,7 @@ module OneLogin
12
12
  class SloLogoutresponse
13
13
 
14
14
  # Logout Response ID
15
- attr_reader :uuid
15
+ attr_accessor :uuid
16
16
 
17
17
  # Initializes the Logout Response. A SloLogoutresponse Object.
18
18
  # Asigns an ID, a random uuid.
@@ -21,6 +21,10 @@ module OneLogin
21
21
  @uuid = OneLogin::RubySaml::Utils.uuid
22
22
  end
23
23
 
24
+ def response_id
25
+ @uuid
26
+ end
27
+
24
28
  # Creates the Logout Response string.
25
29
  # @param settings [OneLogin::RubySaml::Settings|nil] Toolkit settings
26
30
  # @param request_id [String] The ID of the LogoutRequest sent by this SP to the IdP. That ID will be placed as the InResponseTo in the logout response
@@ -104,6 +108,7 @@ module OneLogin
104
108
  # @param settings [OneLogin::RubySaml::Settings|nil] Toolkit settings
105
109
  # @param request_id [String] The ID of the LogoutRequest sent by this SP to the IdP. That ID will be placed as the InResponseTo in the logout response
106
110
  # @param logout_message [String] The Message to be placed as StatusMessage in the logout response
111
+ # @param logout_status_code [String] The StatusCode to be placed as StatusMessage in the logout response
107
112
  # @return [String] The SAMLResponse String.
108
113
  #
109
114
  def create_logout_response_xml_doc(settings, request_id = nil, logout_message = nil, logout_status_code = nil)
@@ -129,15 +134,15 @@ module OneLogin
129
134
  issuer.text = settings.sp_entity_id
130
135
  end
131
136
 
132
- # add success message
137
+ # add status
133
138
  status = root.add_element 'samlp:Status'
134
139
 
135
- # success status code
140
+ # status code
136
141
  status_code ||= 'urn:oasis:names:tc:SAML:2.0:status:Success'
137
142
  status_code_elem = status.add_element 'samlp:StatusCode'
138
143
  status_code_elem.attributes['Value'] = status_code
139
144
 
140
- # success status message
145
+ # status message
141
146
  logout_message ||= 'Successfully Signed Out'
142
147
  status_message = status.add_element 'samlp:StatusMessage'
143
148
  status_message.text = logout_message
@@ -1,5 +1,5 @@
1
1
  module OneLogin
2
2
  module RubySaml
3
- VERSION = '0.8.17'
3
+ VERSION = '0.8.18'
4
4
  end
5
5
  end
@@ -240,5 +240,16 @@ class LogoutRequestTest < Minitest::Test
240
240
  assert cert.public_key.verify(signature_algorithm.new, Base64.decode64(params['Signature']), query_string)
241
241
  end
242
242
  end
243
+
244
+ describe "#manipulate request_id" do
245
+ it "be able to modify the request id" do
246
+ logoutrequest = OneLogin::RubySaml::Logoutrequest.new
247
+ request_id = logoutrequest.request_id
248
+ assert_equal request_id, logoutrequest.uuid
249
+ logoutrequest.uuid = "new_uuid"
250
+ assert_equal logoutrequest.request_id, logoutrequest.uuid
251
+ assert_equal "new_uuid", logoutrequest.request_id
252
+ end
253
+ end
243
254
  end
244
255
  end
@@ -33,7 +33,7 @@ class LogoutResponseTest < Minitest::Test
33
33
  it "validate the response" do
34
34
  in_relation_to_request_id = random_id
35
35
  settings.idp_entity_id = "https://example.com/idp"
36
- logoutresponse = OneLogin::RubySaml::Logoutresponse.new(valid_response({:uuid => in_relation_to_request_id}), settings)
36
+ logoutresponse = OneLogin::RubySaml::Logoutresponse.new(valid_response({:uuid2 => in_relation_to_request_id}), settings)
37
37
 
38
38
  assert logoutresponse.validate
39
39
 
@@ -94,5 +94,12 @@ class LogoutResponseTest < Minitest::Test
94
94
  end
95
95
  end
96
96
 
97
+ describe "#response_id" do
98
+ it "extract the value of the Response ID" do
99
+ logoutresponse = OneLogin::RubySaml::Logoutresponse.new(valid_response, settings)
100
+ assert_equal "_28024690-000e-0130-b6d2-38f6b112be8b", logoutresponse.response_id
101
+ end
102
+ end
103
+
97
104
  end
98
105
  end
data/test/request_test.rb CHANGED
@@ -224,6 +224,16 @@ class RequestTest < Minitest::Test
224
224
  end
225
225
  end
226
226
 
227
+ describe "#manipulate request_id" do
228
+ it "be able to modify the request id" do
229
+ authnrequest = OneLogin::RubySaml::Authrequest.new
230
+ request_id = authnrequest.request_id
231
+ assert_equal request_id, authnrequest.uuid
232
+ authnrequest.uuid = "new_uuid"
233
+ assert_equal authnrequest.request_id, authnrequest.uuid
234
+ assert_equal "new_uuid", authnrequest.request_id
235
+ end
236
+ end
227
237
  end
228
238
 
229
239
  end
@@ -16,7 +16,7 @@ def valid_request(opts = {})
16
16
  "<samlp:LogoutRequest
17
17
  xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\"
18
18
  xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\"
19
- ID=\"#{random_id}\" Version=\"2.0\"
19
+ ID=\"#{opts[:uuid]}\" Version=\"2.0\"
20
20
  IssueInstant=\"#{opts[:issue_instant]}\"
21
21
  Destination=\"#{opts[:settings].idp_slo_target_url}\">
22
22
  <saml:Issuer>#{opts[:settings].idp_entity_id}</saml:Issuer>
@@ -384,6 +384,13 @@ class ResponseTest < Minitest::Test
384
384
  end
385
385
  end
386
386
 
387
+ describe "#response_id and assertion_id" do
388
+ it "extract the value of the Response and Assertion IDs" do
389
+ response = OneLogin::RubySaml::Response.new(response_document)
390
+ assert_equal "GOSAMLR12901174571794", response.response_id
391
+ assert_equal "pfxa46574df-b3b0-a06a-23c8-636413198772", response.assertion_id
392
+ end
393
+ end
387
394
 
388
395
  describe "#check_conditions" do
389
396
  it "check time conditions" do
@@ -3,6 +3,7 @@
3
3
  def default_response_opts
4
4
  {
5
5
  :uuid => "_28024690-000e-0130-b6d2-38f6b112be8b",
6
+ :uuid2 => "_48024690-100e-1130-e6d2-28f6b112be71",
6
7
  :issue_instant => Time.now.strftime('%Y-%m-%dT%H:%M:%SZ'),
7
8
  :settings => settings
8
9
  }
@@ -13,10 +14,10 @@ def valid_response(opts = {})
13
14
 
14
15
  "<samlp:LogoutResponse
15
16
  xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\"
16
- ID=\"#{random_id}\" Version=\"2.0\"
17
+ ID=\"#{opts[:uuid]}\" Version=\"2.0\"
17
18
  IssueInstant=\"#{opts[:issue_instant]}\"
18
19
  Destination=\"#{opts[:settings].idp_slo_target_url}\"
19
- InResponseTo=\"#{opts[:uuid]}\">
20
+ InResponseTo=\"#{opts[:uuid2]}\">
20
21
  <saml:Issuer xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\">#{opts[:settings].idp_entity_id}</saml:Issuer>
21
22
  <samlp:Status xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\">
22
23
  <samlp:StatusCode xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\"
@@ -62,5 +62,12 @@ class SloLogoutrequestTest < Minitest::Test
62
62
  end
63
63
  end
64
64
 
65
+ describe "#request_id" do
66
+ it "extract the value of the Response ID" do
67
+ logoutrequest = OneLogin::RubySaml::SloLogoutrequest.new(valid_request, settings)
68
+ assert_equal "_28024690-000e-0130-b6d2-38f6b112be8b", logoutrequest.request_id
69
+ end
70
+ end
71
+
65
72
  end
66
73
  end
@@ -230,5 +230,16 @@ class SloLogoutresponseTest < Minitest::Test
230
230
  assert cert.public_key.verify(signature_algorithm.new, Base64.decode64(params['Signature']), query_string)
231
231
  end
232
232
  end
233
+
234
+ describe "#manipulate response_id" do
235
+ it "be able to modify the response id" do
236
+ logoutresponse = OneLogin::RubySaml::SloLogoutresponse.new
237
+ response_id = logoutresponse.response_id
238
+ assert_equal response_id, logoutresponse.uuid
239
+ logoutresponse.uuid = "new_uuid"
240
+ assert_equal logoutresponse.response_id, logoutresponse.uuid
241
+ assert_equal "new_uuid", logoutresponse.response_id
242
+ end
243
+ end
233
244
  end
234
245
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-saml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.17
4
+ version: 0.8.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - OneLogin LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-03 00:00:00.000000000 Z
11
+ date: 2021-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uuid
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  version: '0'
166
166
  requirements: []
167
167
  rubyforge_project: http://www.rubygems.org/gems/ruby-saml
168
- rubygems_version: 2.6.8
168
+ rubygems_version: 2.4.8
169
169
  signing_key:
170
170
  specification_version: 4
171
171
  summary: SAML Ruby Tookit