Merge pull request #119 from jurriaan/jwt-2-0

Support ruby-jwt 2.0
This commit is contained in:
Heng Xiong 2017-09-18 10:32:49 -07:00 committed by GitHub
commit a83d39b158
5 changed files with 8 additions and 6 deletions

View File

@ -8,7 +8,7 @@ rvm:
- 2.1 - 2.1
- 1.9.3 - 1.9.3
- rbx-2 - rbx-2
- jruby - jruby-9.1.9.0
matrix: matrix:
allow_failures: allow_failures:
- rvm: rbx-2 # See rubinius/rubinius#3485 - rubocop segfaults - rvm: rbx-2 # See rubinius/rubinius#3485 - rubocop segfaults

View File

@ -12,7 +12,7 @@ group :development do
gem 'rake', '~> 10.0' gem 'rake', '~> 10.0'
gem 'redis', '~> 3.2' gem 'redis', '~> 3.2'
gem 'rspec', '~> 3.0' gem 'rspec', '~> 3.0'
gem 'rubocop', '~> 0.49.0' gem 'rubocop', '>= 0.41', '< 0.50'
gem 'simplecov', '~> 0.9' gem 'simplecov', '~> 0.9'
gem 'sinatra' gem 'sinatra'
gem 'webmock', '~> 1.21' gem 'webmock', '~> 1.21'

View File

@ -28,7 +28,7 @@ Gem::Specification.new do |s|
s.add_dependency 'faraday', '~> 0.12' s.add_dependency 'faraday', '~> 0.12'
s.add_dependency 'logging', '~> 2.0' s.add_dependency 'logging', '~> 2.0'
s.add_dependency 'jwt', '~> 1.4' s.add_dependency 'jwt', '>= 1.4', '< 3.0'
s.add_dependency 'memoist', '~> 0.12' s.add_dependency 'memoist', '~> 0.12'
s.add_dependency 'multi_json', '~> 1.11' s.add_dependency 'multi_json', '~> 1.11'
s.add_dependency 'os', '~> 0.9' s.add_dependency 'os', '~> 0.9'

View File

@ -54,7 +54,7 @@ shared_examples 'jwt header auth' do
expect(hdr).to_not be_nil expect(hdr).to_not be_nil
expect(hdr.start_with?(auth_prefix)).to be true expect(hdr.start_with?(auth_prefix)).to be true
authorization = hdr[auth_prefix.length..-1] authorization = hdr[auth_prefix.length..-1]
payload, = JWT.decode(authorization, @key.public_key) payload, = JWT.decode(authorization, @key.public_key, true, algorithm: 'RS256')
expect(payload['aud']).to eq(test_uri) expect(payload['aud']).to eq(test_uri)
expect(payload['iss']).to eq(client_email) expect(payload['iss']).to eq(client_email)
end end
@ -135,7 +135,8 @@ describe Google::Auth::ServiceAccountCredentials do
blk = proc do |request| blk = proc do |request|
params = Addressable::URI.form_unencode(request.body) params = Addressable::URI.form_unencode(request.body)
_claim, _header = JWT.decode(params.assoc('assertion').last, _claim, _header = JWT.decode(params.assoc('assertion').last,
@key.public_key) @key.public_key, true,
algorithm: 'RS256')
end end
stub_request(:post, 'https://www.googleapis.com/oauth2/v4/token') stub_request(:post, 'https://www.googleapis.com/oauth2/v4/token')
.with(body: hash_including( .with(body: hash_including(

View File

@ -57,7 +57,8 @@ describe Signet::OAuth2::Client do
blk = proc do |request| blk = proc do |request|
params = Addressable::URI.form_unencode(request.body) params = Addressable::URI.form_unencode(request.body)
_claim, _header = JWT.decode(params.assoc('assertion').last, _claim, _header = JWT.decode(params.assoc('assertion').last,
@key.public_key) @key.public_key, true,
algorithm: 'RS256')
end end
stub_request(:post, 'https://accounts.google.com/o/oauth2/token') stub_request(:post, 'https://accounts.google.com/o/oauth2/token')
.with(body: hash_including( .with(body: hash_including(