Skip to content

Commit

Permalink
Improve endpoints parser
Browse files Browse the repository at this point in the history
  • Loading branch information
pitbulk committed Apr 21, 2017
1 parent 67a1b14 commit af856f6
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions lib/onelogin/ruby-saml/idp_metadata_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,15 @@ def single_signon_service_binding(binding_priority = nil)
# @return [String|nil] SingleSignOnService endpoint if exists
#
def single_signon_service_url(options = {})
binding = options[:sso_binding] || single_signon_service_binding || "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
node = REXML::XPath.first(
document,
"/md:EntityDescriptor/md:IDPSSODescriptor/md:SingleSignOnService[@Binding=\"#{binding}\"]/@Location",
{ "md" => METADATA }
)
node.value if node
binding = single_signon_service_binding(options[:sso_binding])
unless binding.nil?
node = REXML::XPath.first(
document,
"/md:EntityDescriptor/md:IDPSSODescriptor/md:SingleSignOnService[@Binding=\"#{binding}\"]/@Location",
{ "md" => METADATA }
)
return node.value if node
end
end

# @param binding_priority [Array]
Expand All @@ -172,13 +174,15 @@ def single_logout_service_binding(binding_priority = nil)
# @return [String|nil] SingleLogoutService endpoint if exists
#
def single_logout_service_url(options = {})
binding = options[:slo_binding] || single_logout_service_binding || "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
node = REXML::XPath.first(
document,
"/md:EntityDescriptor/md:IDPSSODescriptor/md:SingleLogoutService[@Binding=\"#{binding}\"]/@Location",
{ "md" => METADATA }
)
node.value if node
binding = single_logout_service_binding(options[:slo_binding])
unless binding.nil?
node = REXML::XPath.first(
document,
"/md:EntityDescriptor/md:IDPSSODescriptor/md:SingleLogoutService[@Binding=\"#{binding}\"]/@Location",
{ "md" => METADATA }
)
return node.value if node
end
end

# @return [String|nil] Unformatted Certificate if exists
Expand Down

0 comments on commit af856f6

Please sign in to comment.