Skip to content

Commit

Permalink
Use jwt v2.9.2's public claims verification API
Browse files Browse the repository at this point in the history
This is a continuation of zquestz#464, which fixed backward compatibility with
jwt v2.9.0 and v2.9.1.  v2.9.2 brought back the removed APIs, for
backward compatibility, but marked them as internal only and/or
deprecated.

For context, see the discussion here:
* jwt/ruby-jwt#623
* jwt/ruby-jwt#626
  • Loading branch information
nevans committed Oct 3, 2024
1 parent 11af078 commit bab6f69
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
16 changes: 5 additions & 11 deletions lib/omniauth/strategies/google_oauth2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,11 @@ def authorize_params

# We have to manually verify the claims because the third parameter to
# JWT.decode is false since no verification key is provided.
::JWT::Claims.verify!(decoded,
verify_iss: true,
iss: ALLOWED_ISSUERS,
verify_aud: true,
aud: options.client_id,
verify_sub: false,
verify_expiration: true,
verify_not_before: true,
verify_iat: false,
verify_jti: false,
leeway: options[:jwt_leeway])
::JWT::Claims.verify_payload!(decoded,
iss: ALLOWED_ISSUERS,
aud: options.client_id,
exp: { leeway: options.jwt_leeway },
nbf: { leeway: options.jwt_leeway })

hash[:id_info] = decoded
end
Expand Down
2 changes: 1 addition & 1 deletion omniauth-google-oauth2.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |gem|

gem.required_ruby_version = '>= 2.5'

gem.add_runtime_dependency 'jwt', '>= 2.9'
gem.add_runtime_dependency 'jwt', '>= 2.9.2'
gem.add_runtime_dependency 'oauth2', '~> 2.0'
gem.add_runtime_dependency 'omniauth', '~> 2.0'
gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.8'
Expand Down

0 comments on commit bab6f69

Please sign in to comment.