Skip to content

Commit

Permalink
No explicit handling for the none algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
anakinj committed Jul 25, 2023
1 parent 756dfc0 commit ffa9b4a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/jwt/decode_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ def payload
end

def valid_signature?
return valid_signature_for?(nil) if verification_keys.empty?

verification_keys.any? { |key| valid_signature_for?(key) }
end

def verification_keys
@verification_keys ||= Array(resolve_verification_keys).compact
@verification_keys ||= Array(resolve_verification_keys)
end

def algorithm_match?
Expand Down
4 changes: 1 addition & 3 deletions lib/jwt/default_decoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ def decode_segments
private

def verify_signature
return if none_algorithm?

return if decode_context.valid_signature?

raise JWT::VerificationError, 'Signature verification failed'
Expand Down Expand Up @@ -113,7 +111,7 @@ def validate_segment_count!
end

def none_algorithm?
decode_context.token.alg_in_header == 'none'
alg_in_header == 'none'
end

def alg_in_header
Expand Down

0 comments on commit ffa9b4a

Please sign in to comment.