Skip to content

Commit

Permalink
Fix algorithm picking from options
Browse files Browse the repository at this point in the history
Fixes #331.
  • Loading branch information
excpt committed Jul 8, 2020
1 parent d8dc68a commit 2492d58
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/jwt/decode.rb
Expand Up @@ -47,10 +47,17 @@ def options_includes_algo_in_header?
end

def allowed_algorithms
if @options.key?(:algorithm)
# Order is very important - first check for string keys, next for symbols
if @options.key?('algorithm')
[@options['algorithm']]
elsif @options.key?(:algorithm)
[@options[:algorithm]]
else
elsif @options.key?('algorithms')
@options['algorithms'] || []
elsif @options.key?(:algorithms)
@options[:algorithms] || []
else
[]
end
end

Expand Down

0 comments on commit 2492d58

Please sign in to comment.