Skip to content

Commit

Permalink
Merge pull request #567 from withshubh/master
Browse files Browse the repository at this point in the history
Fix: issues affecting the code quality
  • Loading branch information
pitbulk committed Jan 2, 2023
2 parents 9da1ad4 + 7c153b6 commit 82f08a3
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/onelogin/ruby-saml/authrequest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def create(settings, params = {})
saml_request = CGI.escape(params.delete("SAMLRequest"))
request_params = "#{params_prefix}SAMLRequest=#{saml_request}"
params.each_pair do |key, value|
request_params << "&#{key.to_s}=#{CGI.escape(value.to_s)}"
request_params << "&#{key}=#{CGI.escape(value.to_s)}"
end
raise SettingError.new "Invalid settings, idp_sso_service_url is not set!" if settings.idp_sso_service_url.nil? or settings.idp_sso_service_url.empty?
@login_url = settings.idp_sso_service_url + request_params
Expand Down
2 changes: 1 addition & 1 deletion lib/onelogin/ruby-saml/logoutrequest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def create(settings, params={})
saml_request = CGI.escape(params.delete("SAMLRequest"))
request_params = "#{params_prefix}SAMLRequest=#{saml_request}"
params.each_pair do |key, value|
request_params << "&#{key.to_s}=#{CGI.escape(value.to_s)}"
request_params << "&#{key}=#{CGI.escape(value.to_s)}"
end
raise SettingError.new "Invalid settings, idp_slo_service_url is not set!" if settings.idp_slo_service_url.nil? or settings.idp_slo_service_url.empty?
@logout_url = settings.idp_slo_service_url + request_params
Expand Down
2 changes: 1 addition & 1 deletion lib/onelogin/ruby-saml/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ def validate_issuer
# @return [Boolean] True if the SessionNotOnOrAfter of the AuthnStatement is valid, otherwise (when expired) False if soft=True
# @raise [ValidationError] if soft == false and validation fails
#
def validate_session_expiration(soft = true)
def validate_session_expiration
return true if session_expires_at.nil?

now = Time.now.utc
Expand Down
5 changes: 2 additions & 3 deletions lib/onelogin/ruby-saml/saml_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
require 'nokogiri'
require 'rexml/document'
require 'rexml/xpath'
require 'thread'
require "onelogin/ruby-saml/error_handling"

# Only supports SAML 2.0
Expand Down Expand Up @@ -69,14 +68,14 @@ def valid_saml?(document, soft = true)
xml = Nokogiri::XML(document.to_s) do |config|
config.options = XMLSecurity::BaseDocument::NOKOGIRI_OPTIONS
end
rescue Exception => error
rescue StandardError => error
return false if soft
raise ValidationError.new("XML load failed: #{error.message}")
end

SamlMessage.schema.validate(xml).map do |schema_error|
return false if soft
raise ValidationError.new("#{schema_error.message}\n\n#{xml.to_s}")
raise ValidationError.new("#{schema_error.message}\n\n#{xml}")
end
end

Expand Down
3 changes: 1 addition & 2 deletions lib/onelogin/ruby-saml/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def initialize(overrides = {}, keep_security_attributes = false)
end

config.each do |k,v|
acc = "#{k.to_s}=".to_sym
acc = "#{k}=".to_sym
if respond_to? acc
value = v.is_a?(Hash) ? v.dup : v
send(acc, value)
Expand Down Expand Up @@ -243,7 +243,6 @@ def get_sp_key
OpenSSL::PKey::RSA.new(formatted_private_key)
end

private

def idp_binding_from_embed_sign
security[:embed_sign] ? Utils::BINDINGS[:post] : Utils::BINDINGS[:redirect]
Expand Down
2 changes: 1 addition & 1 deletion lib/onelogin/ruby-saml/slo_logoutresponse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def create(settings, request_id = nil, logout_message = nil, params = {}, logout
saml_response = CGI.escape(params.delete("SAMLResponse"))
response_params = "#{params_prefix}SAMLResponse=#{saml_response}"
params.each_pair do |key, value|
response_params << "&#{key.to_s}=#{CGI.escape(value.to_s)}"
response_params << "&#{key}=#{CGI.escape(value.to_s)}"
end

raise SettingError.new "Invalid settings, idp_slo_service_url is not set!" if url.nil? or url.empty?
Expand Down
2 changes: 1 addition & 1 deletion lib/xml_security.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def validate_document(idp_cert_fingerprint, soft = true, options = {})
if options[:fingerprint_alg]
fingerprint_alg = XMLSecurity::BaseDocument.new.algorithm(options[:fingerprint_alg]).new
else
fingerprint_alg = OpenSSL::Digest::SHA1.new
fingerprint_alg = OpenSSL::Digest.new('SHA1')
end
fingerprint = fingerprint_alg.hexdigest(cert.to_der)

Expand Down

0 comments on commit 82f08a3

Please sign in to comment.