Skip to content

Commit 5b99b9b

Browse files
committed
Merge remote-tracking branch 'remotes/johnnyshields/signed-doc-refactor-final' into v2.x-nokogiri-parrtial-upgrade-phase-3
2 parents 4c6475c + 8ffdd04 commit 5b99b9b

16 files changed

+616
-491
lines changed

lib/ruby_saml/idp_metadata_parser.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,10 @@ def single_signon_service_url(binding_priority = nil)
306306
binding = single_signon_service_binding(binding_priority)
307307
return if binding.nil?
308308

309-
node = @idpsso_descriptor.at_xpath(
309+
@idpsso_descriptor.at_xpath(
310310
"md:SingleSignOnService[@Binding=\"#{binding}\"]/@Location",
311311
SamlMetadata::NAMESPACE
312-
)
313-
node&.value
312+
)&.value
314313
end
315314

316315
# @param binding_priority [String|Array<String>] The prioritized list of Binding values to select. Will select first value if nil.
@@ -320,11 +319,10 @@ def single_logout_service_url(binding_priority = nil)
320319
binding = single_logout_service_binding(binding_priority)
321320
return if binding.nil?
322321

323-
node = @idpsso_descriptor.at_xpath(
322+
@idpsso_descriptor.at_xpath(
324323
"md:SingleLogoutService[@Binding=\"#{binding}\"]/@Location",
325324
SamlMetadata::NAMESPACE
326-
)
327-
node&.value
325+
)&.value
328326
end
329327

330328
# @param binding_priority [String|Array<String>] The prioritized list of Binding values to select. Will select first value if nil.

lib/ruby_saml/logoutresponse.rb

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
require "ruby_saml/saml_message"
55
require "time"
66

7+
# Only supports SAML 2.0
78
module RubySaml
9+
810
# SAML2 Logout Response (SLO IdP initiated, Parser)
11+
#
912
class Logoutresponse < SamlMessage
1013
include ErrorHandling
1114

@@ -41,7 +44,7 @@ def initialize(response, settings = nil, options = {})
4144

4245
@options = options
4346
@response = decode_raw_saml(response, settings)
44-
@document = RubySaml::XML::SignedDocument.new(@response)
47+
@document = Nokogiri::XML(@response)
4548
super()
4649
end
4750

@@ -61,45 +64,41 @@ def success?
6164
#
6265
def in_response_to
6366
@in_response_to ||= begin
64-
node = REXML::XPath.first(
65-
document,
67+
node = document.at_xpath(
6668
"/p:LogoutResponse",
6769
{ "p" => PROTOCOL }
6870
)
69-
node.nil? ? nil : node.attributes['InResponseTo']
71+
node.nil? ? nil : node['InResponseTo']
7072
end
7173
end
7274

7375
# @return [String] Gets the Issuer from the Logout Response.
7476
#
7577
def issuer
7678
@issuer ||= begin
77-
node = REXML::XPath.first(
78-
document,
79+
document.at_xpath(
7980
"/p:LogoutResponse/a:Issuer",
8081
{ "p" => PROTOCOL, "a" => ASSERTION }
81-
)
82-
Utils.element_text(node)
82+
)&.content
8383
end
8484
end
8585

8686
# @return [String] Gets the StatusCode from a Logout Response.
8787
#
8888
def status_code
8989
@status_code ||= begin
90-
node = REXML::XPath.first(document, "/p:LogoutResponse/p:Status/p:StatusCode", { "p" => PROTOCOL })
91-
node.nil? ? nil : node.attributes["Value"]
90+
node = document.at_xpath("/p:LogoutResponse/p:Status/p:StatusCode", { "p" => PROTOCOL })
91+
node.nil? ? nil : node['Value']
9292
end
9393
end
9494

9595
def status_message
9696
@status_message ||= begin
97-
node = REXML::XPath.first(
98-
document,
97+
node = document.at_xpath(
9998
"/p:LogoutResponse/p:Status/p:StatusMessage",
10099
{ "p" => PROTOCOL }
101100
)
102-
Utils.element_text(node)
101+
node&.content
103102
end
104103
end
105104

@@ -148,8 +147,7 @@ def validate_success_status
148147
# @raise [ValidationError] if soft == false and validation fails
149148
#
150149
def validate_structure
151-
check_malformed_doc = check_malformed_doc?(settings)
152-
unless valid_saml?(document, soft, check_malformed_doc: check_malformed_doc)
150+
unless valid_saml?(document, soft)
153151
return append_error("Invalid SAML Logout Response. Not match the saml-schema-protocol-2.0.xsd")
154152
end
155153

@@ -271,4 +269,4 @@ def validate_signature
271269
true
272270
end
273271
end
274-
end
272+
end

0 commit comments

Comments
 (0)