ruby-saml 0.8.16 → 0.8.17

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
- SHA256:
3
- metadata.gz: 68cb87ca6e3a580cea96b7784b71f60afe0f0982fc9b3c7b2de4fdda0ea1af31
4
- data.tar.gz: 216f43c0d0a179f3a9c506f198c31e2a01a08a8661bfaafbe3cb50811b1acf88
2
+ SHA1:
3
+ metadata.gz: 1ec15a6a64795cd0b10b796d6aef230a7d7d439c
4
+ data.tar.gz: a07ddee9fb7bfe9ca2f20cde2c9cadfd5bbac121
5
5
  SHA512:
6
- metadata.gz: 35ba610649dbff55acae0612782ab7e81947907212b9c454494f9baa5c3926a126430eed919356049261a9cb40767d7079874f56f1b4cb1bd7efb637f4f6ba4f
7
- data.tar.gz: a3e9ce681547c0e648f477198a134749c9febb1f86e042d2bb3266e01a740767672a667d0c85a162d0f11489e87ee4c1a53cbd15d45e6aeefeb31fc30a2fe99f
6
+ metadata.gz: 013b1a3b9b2eb015253dcc4992a1d8be73a3dce996271d701375914e3e7f3e64f6eff3094af1ade43fc807ce452093d05c071cf79b5b2cc8b63d3041688f9344
7
+ data.tar.gz: ed258b192c0cbd0b5c589183ecacd9591dad637783430130a9dfd97b6c68c1062520cf91255ed997adf693f1c7f344d84cf0184a821202c8c8ea85509c069864
@@ -114,7 +114,8 @@ module OneLogin
114
114
 
115
115
  if settings.name_identifier_value
116
116
  name_id = root.add_element "saml:NameID", { "xmlns:saml" => "urn:oasis:names:tc:SAML:2.0:assertion" }
117
- name_id.attributes['NameQualifier'] = settings.sp_name_qualifier if settings.sp_name_qualifier
117
+ nameid.attributes['NameQualifier'] = settings.idp_name_qualifier if settings.idp_name_qualifier
118
+ nameid.attributes['SPNameQualifier'] = settings.sp_name_qualifier if settings.sp_name_qualifier
118
119
  name_id.attributes['Format'] = settings.name_identifier_format if settings.name_identifier_format
119
120
  name_id.text = settings.name_identifier_value
120
121
  end
@@ -35,16 +35,48 @@ module OneLogin
35
35
  validate(false)
36
36
  end
37
37
 
38
- # The value of the user identifier as designated by the initialization request response
39
- def name_id
38
+ def name_id_node
40
39
  @name_id ||= begin
41
- node = xpath_first_from_signed_assertion('/a:Subject/a:NameID')
42
- Utils.element_text(node)
40
+ xpath_first_from_signed_assertion('/a:Subject/a:NameID')
43
41
  end
44
42
  end
45
43
 
44
+ # The value of the user identifier as designated by the initialization request response
45
+ def name_id
46
+ @name_id ||= Utils.element_text(name_id_node)
47
+ end
48
+
46
49
  alias nameid name_id
47
50
 
51
+ # @return [String] the NameID Format provided by the SAML response from the IdP.
52
+ #
53
+ def name_id_format
54
+ @name_id_format ||=
55
+ if name_id_node && name_id_node.attribute("Format")
56
+ name_id_node.attribute("Format").value
57
+ end
58
+ end
59
+
60
+ alias_method :nameid_format, :name_id_format
61
+
62
+ # @return [String] the NameID SPNameQualifier provided by the SAML response from the IdP.
63
+ #
64
+ def name_id_spnamequalifier
65
+ @name_id_spnamequalifier ||=
66
+ if name_id_node && name_id_node.attribute("SPNameQualifier")
67
+ name_id_node.attribute("SPNameQualifier").value
68
+ end
69
+ end
70
+
71
+ # @return [String] the NameID NameQualifier provided by the SAML response from the IdP.
72
+ #
73
+ def name_id_namequalifier
74
+ @name_id_namequalifier ||=
75
+ if name_id_node && name_id_node.attribute("NameQualifier")
76
+ name_id_node.attribute("NameQualifier").value
77
+ end
78
+ end
79
+
48
80
  def sessionindex
49
81
  @sessionindex ||= begin
50
82
  node = xpath_first_from_signed_assertion('/a:AuthnStatement')
@@ -33,6 +33,7 @@ module OneLogin
33
33
  attr_accessor :assertion_consumer_service_url
34
34
  attr_accessor :authn_context
35
35
  attr_accessor :sp_name_qualifier
36
+ attr_accessor :idp_name_qualifier
36
37
  attr_accessor :name_identifier_format
37
38
  attr_accessor :name_identifier_value
38
39
  attr_accessor :name_identifier_value_requested
@@ -26,10 +26,11 @@ module OneLogin
26
26
  # @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
27
27
  # @param logout_message [String] The Message to be placed as StatusMessage in the logout response
28
28
  # @param params [Hash] Some extra parameters to be added in the GET for example the RelayState
29
+ # @param logout_status_code [String] The StatusCode to be placed as StatusMessage in the logout response
29
30
  # @return [String] Logout Request string that includes the SAMLRequest
30
31
  #
31
- def create(settings, request_id = nil, logout_message = nil, params = {})
32
- params = create_params(settings, request_id, logout_message, params)
32
+ def create(settings, request_id = nil, logout_message = nil, params = {}, logout_status_code = nil)
33
+ params = create_params(settings, request_id, logout_message, params, logout_status_code)
33
34
  params_prefix = (settings.idp_slo_target_url =~ /\?/) ? '&' : '?'
34
35
  saml_response = CGI.escape(params.delete("SAMLResponse"))
35
36
  response_params = "#{params_prefix}SAMLResponse=#{saml_response}"
@@ -45,9 +46,10 @@ module OneLogin
45
46
  # @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
46
47
  # @param logout_message [String] The Message to be placed as StatusMessage in the logout response
47
48
  # @param params [Hash] Some extra parameters to be added in the GET for example the RelayState
49
+ # @param logout_status_code [String] The StatusCode to be placed as StatusMessage in the logout response
48
50
  # @return [Hash] Parameters
49
51
  #
50
- def create_params(settings, request_id = nil, logout_message = nil, params = {})
52
+ def create_params(settings, request_id = nil, logout_message = nil, params = {}, logout_status_code = nil)
51
53
  # The method expects :RelayState but sometimes we get 'RelayState' instead.
52
54
  # Based on the HashWithIndifferentAccess value in Rails we could experience
53
55
  # conflicts so this line will solve them.
@@ -58,7 +60,7 @@ module OneLogin
58
60
  params.delete('RelayState')
59
61
  end
60
62
 
61
- response_doc = create_logout_response_xml_doc(settings, request_id, logout_message)
63
+ response_doc = create_logout_response_xml_doc(settings, request_id, logout_message, logout_status_code)
62
64
  response_doc.context[:attribute_quote] = :quote if settings.double_quote_xml_attribute_values
63
65
 
64
66
  response = ""
@@ -104,12 +106,12 @@ module OneLogin
104
106
  # @param logout_message [String] The Message to be placed as StatusMessage in the logout response
105
107
  # @return [String] The SAMLResponse String.
106
108
  #
107
- def create_logout_response_xml_doc(settings, request_id = nil, logout_message = nil)
108
- document = create_xml_document(settings, request_id, logout_message)
109
+ def create_logout_response_xml_doc(settings, request_id = nil, logout_message = nil, logout_status_code = nil)
110
+ document = create_xml_document(settings, request_id, logout_message, logout_status_code)
109
111
  sign_document(document, settings)
110
112
  end
111
113
 
112
- def create_xml_document(settings, request_id = nil, logout_message = nil)
114
+ def create_xml_document(settings, request_id = nil, logout_message = nil, status_code = nil)
113
115
  time = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
114
116
 
115
117
  response_doc = XMLSecurity::Document.new
@@ -131,8 +133,9 @@ module OneLogin
131
133
  status = root.add_element 'samlp:Status'
132
134
 
133
135
  # success status code
134
- status_code = status.add_element 'samlp:StatusCode'
135
- status_code.attributes['Value'] = 'urn:oasis:names:tc:SAML:2.0:status:Success'
136
+ status_code ||= 'urn:oasis:names:tc:SAML:2.0:status:Success'
137
+ status_code_elem = status.add_element 'samlp:StatusCode'
138
+ status_code_elem.attributes['Value'] = status_code
136
139
 
137
140
  # success status message
138
141
  logout_message ||= 'Successfully Signed Out'
@@ -1,5 +1,5 @@
1
1
  module OneLogin
2
2
  module RubySaml
3
- VERSION = '0.8.16'
3
+ VERSION = '0.8.17'
4
4
  end
5
5
  end
@@ -368,6 +368,23 @@ class ResponseTest < Minitest::Test
368
368
  end
369
369
  end
370
370
 
371
+ describe "#name_id_format" do
372
+ it "extract the value of the name id element" do
373
+ response = OneLogin::RubySaml::Response.new(response_document)
374
+ response_signed = OneLogin::RubySaml::Response.new(response_document_valid_signed)
375
+ assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", response.name_id_format
376
+ assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", response_signed.name_id_format
377
+ end
378
+ end
379
+
380
+ describe "#sessionindex" do
381
+ it "extract the value of the sessionindex element" do
382
+ response = OneLogin::RubySaml::Response.new(fixture(:simple_saml_php))
383
+ assert_equal "_51be37965feb5579d803141076936dc2e9d1d98ebf", response.sessionindex
384
+ end
385
+ end
386
+
387
+
371
388
  describe "#check_conditions" do
372
389
  it "check time conditions" do
373
390
  response = OneLogin::RubySaml::Response.new(response_document)
@@ -61,6 +61,14 @@ class SloLogoutresponseTest < Minitest::Test
61
61
  assert_match /<samlp:StatusMessage>Custom Logout Message<\/samlp:StatusMessage>/, inflated
62
62
  end
63
63
 
64
+ it "set a custom logout message and an status on the response" do
65
+ unauth_url = OneLogin::RubySaml::SloLogoutresponse.new.create(settings, nil, "Custom Logout Message", {}, "urn:oasis:names:tc:SAML:2.0:status:PartialLogout")
66
+
67
+ inflated = decode_saml_response_payload(unauth_url)
68
+ assert_match /<samlp:StatusMessage>Custom Logout Message<\/samlp:StatusMessage>/, inflated
69
+ assert_match /<samlp:StatusCode Value='urn:oasis:names:tc:SAML:2.0:status:PartialLogout/, inflated
70
+ end
71
+
64
72
  describe "when the settings indicate to sign (embedded) logout response" do
65
73
 
66
74
  before do
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.16
4
+ version: 0.8.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - OneLogin LLC
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-19 00:00:00.000000000 Z
11
+ date: 2021-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uuid
@@ -148,7 +148,7 @@ files:
148
148
  homepage: http://github.com/onelogin/ruby-saml
149
149
  licenses: []
150
150
  metadata: {}
151
- post_install_message:
151
+ post_install_message:
152
152
  rdoc_options:
153
153
  - "--charset=UTF-8"
154
154
  require_paths:
@@ -164,8 +164,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  - !ruby/object:Gem::Version
165
165
  version: '0'
166
166
  requirements: []
167
- rubygems_version: 3.0.4
168
- signing_key:
167
+ rubyforge_project: http://www.rubygems.org/gems/ruby-saml
168
+ rubygems_version: 2.6.8
169
+ signing_key:
169
170
  specification_version: 4
170
171
  summary: SAML Ruby Tookit
171
172
  test_files: