Skip to content

Commit

Permalink
Fix rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyshields committed Jul 10, 2024
1 parent dc46b9e commit d163dfd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/ruby_saml/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ def get_sp_signature_method
when OpenSSL::PKey::RSA then 'RSA'
when OpenSSL::PKey::DSA then 'DSA'
when OpenSSL::PKey::EC then 'ECDSA'
else
'RSA'
else # rubocop:disable Lint/DuplicateBranch
# raise ArgumentError.new("Unsupported signing key type: #{get_sp_signing_key.class}")
'RSA'
end

begin
Expand Down
5 changes: 3 additions & 2 deletions lib/ruby_saml/xml/crypto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

module RubySaml
module XML
# XML Signature and Canonicalization algorithms
module Crypto
extend self

Expand Down Expand Up @@ -55,7 +56,7 @@ def signature_algorithm(element)
when 'rsa' then OpenSSL::PKey::RSA
when 'dsa' then OpenSSL::PKey::DSA
when 'ecdsa' then OpenSSL::PKey::EC
else
else # rubocop:disable Lint/DuplicateBranch
# TODO: raise ArgumentError.new("Invalid key algorithm: #{alg}")
OpenSSL::PKey::RSA
end
Expand All @@ -73,7 +74,7 @@ def hash_algorithm(element)
when 'sha256' then OpenSSL::Digest::SHA256
when 'sha384' then OpenSSL::Digest::SHA384
when 'sha512' then OpenSSL::Digest::SHA512
else
else # rubocop:disable Lint/DuplicateBranch
# TODO: raise ArgumentError.new("Invalid hash algorithm: #{alg}")
OpenSSL::Digest::SHA256
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_saml/xml/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def sign_document(private_key, certificate, signature_method = RSA_SHA256, diges
issuer_element = elements['//saml:Issuer']
if issuer_element
root.insert_after(issuer_element, signature_element)
elsif first_child = root.children[0]
elsif (first_child = root.children[0])
root.insert_before(first_child, signature_element)
else
root.add_element(signature_element)
Expand Down
5 changes: 3 additions & 2 deletions lib/ruby_saml/xml/signed_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def validate_signature(base64_cert, soft = true)
'./ds:SignedInfo/ds:SignatureMethod',
{ 'ds' => RubySaml::XML::Crypto::DSIG }
)
signature_key_algorithm, signature_hash_algorithm = RubySaml::XML::Crypto.signature_algorithm(sig_alg_value)
signature_hash_algorithm = RubySaml::XML::Crypto.hash_algorithm(sig_alg_value)

# get signature
base64_signature = REXML::XPath.first(
Expand Down Expand Up @@ -186,7 +186,8 @@ def process_transforms(ref, canon_algorithm)
)

transforms.each do |transform_element|
next unless transform_element.attributes && transform_element.attributes['Algorithm']
next unless transform_element.attributes&.[]('Algorithm')

canon_algorithm = RubySaml::XML::Crypto.canon_algorithm(transform_element, default: false)
end

Expand Down

0 comments on commit d163dfd

Please sign in to comment.