omniauth-google-id-token 1.0.1 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2aa2b59a31980084c88b9763e1b35e9565fc2f5f7044a69f861bcccdd0d3c0a
4
- data.tar.gz: 7888b2347ab53535c57a0db496117901c758f7da25db48170eea2b1885af4483
3
+ metadata.gz: c02ed8f51100b53f1a10ffd42db64294c227301291cd80560b03bed96e1c6e23
4
+ data.tar.gz: e79e6c4ce22a9f3b7a7eb7ab83df37f337208e2e76675c37b23089a90c81e1fe
5
5
  SHA512:
6
- metadata.gz: d4134c38ef5de2525a362b0e7de15649cad1a233ea5e1c122355492e9798ce4f7d3e6342054a9b2a63961abd4a72a8f6618b868319f169c4c81031056b06f37e
7
- data.tar.gz: 699c484111f7f4e985e5653c0a2c569d95ee3bbe16cb33868bc222529ae52822d688895b883a40971ee03d3395f6d73e23b670eaca8fa8ee2790e405897a4ead
6
+ metadata.gz: 2f429d86224146727b18ea4b462c81eadfefe070e971e92c099572030a8bacd4d73be63d296b8730e9628e6b075709a3cea6ea3c093fb31abf4b3721b8ab94ee
7
+ data.tar.gz: 43672c465cf5ed00ac25ca7f94e3fc0d555d22dca99a97af5a19b043fd89863d5e4ac63d0189a300df38a7e94ce6c1bd764556ab0da89b2a10babf43feac8fdf
data/Gemfile CHANGED
@@ -4,7 +4,6 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  group :test, :development do
7
- gem 'googleauth'
8
7
  gem 'jwt' # For testing
9
8
  gem 'multi_json' # For testing
10
9
  gem 'omniauth'
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module GoogleIdToken
3
- VERSION = '1.0.1'.freeze
3
+ VERSION = '1.1.1'.freeze
4
4
  end
5
5
  end
@@ -11,15 +11,13 @@ module OmniAuth
11
11
  OmniAuth::Strategy.included(subclass)
12
12
  end
13
13
 
14
- BASE_SCOPES = %w[profile email openid].freeze
15
14
  RESPONSE_TYPES = %w[token id_token].freeze
16
15
 
17
16
  option :name, 'google_id_token'
18
- option :uid_claim, 'sub'
19
17
  option :client_id, nil # Required for request_phase e.g. redirect to auth page
20
- option :aud_claim, nil
21
- option :azp_claim, nil
18
+ option :uid_claim, 'sub'
22
19
  option :required_claims, %w[email]
20
+ option :scope, %w[profile email openid].freeze
23
21
  option :info_map, { 'name' => 'name', 'email' => 'email' }
24
22
 
25
23
  def request_phase
@@ -30,7 +28,7 @@ module OmniAuth
30
28
 
31
29
  def authorize_params # rubocop:disable Metrics/AbcSize
32
30
  params = {}
33
- params[:scope] = BASE_SCOPES.join(' ')
31
+ params[:scope] = options.scope.join(' ')
34
32
  params[:access_type] = 'offline'
35
33
  params[:include_granted_scopes] = true
36
34
  params[:state] = SecureRandom.hex(24)
@@ -41,10 +39,10 @@ module OmniAuth
41
39
  params
42
40
  end
43
41
 
44
- def decoded # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
42
+ def decoded # rubocop:disable Metrics/MethodLength
45
43
  unless @decoded
46
44
  begin
47
- @decoded = validator.verify_oidc(request.params['id_token'], aud: options.aud_claim, azp: options.azp_claim)
45
+ @decoded = validator.verify_oidc(request.params['id_token'], aud: options.client_id)
48
46
  rescue StandardError => e
49
47
  raise ClaimInvalid, e.message
50
48
  end
@@ -79,7 +77,7 @@ module OmniAuth
79
77
  private
80
78
 
81
79
  def validator
82
- ::Google::Auth::IDTokens::Verifier
80
+ ::Google::Auth::IDTokens
83
81
  end
84
82
 
85
83
  def uid_lookup
@@ -11,7 +11,7 @@ describe OmniAuth::Strategies::GoogleIdToken do # rubocop:disable Metrics/BlockL
11
11
  let(:payload) do
12
12
  { 'iss' => 'https://accounts.google.com',
13
13
  'nbf' => 161_803_398_874,
14
- 'aud' => 'http://example.com',
14
+ 'aud' => 'test_client_id',
15
15
  'sub' => '3141592653589793238',
16
16
  'hd' => 'gmail.com',
17
17
  'email' => 'bob@example.com',
@@ -25,16 +25,16 @@ describe OmniAuth::Strategies::GoogleIdToken do # rubocop:disable Metrics/BlockL
25
25
  'exp' => 1_596_477_600,
26
26
  'jti' => 'abc161803398874def' }
27
27
  end
28
- let(:aud_claim) { payload[:aud] }
28
+ let(:client_id) { payload[:aud] }
29
29
  let(:azp_claim) { payload[:azp] }
30
30
 
31
- let(:client_id) { 'test_client_id' }
32
31
  let(:args) do
33
32
  [
34
33
  {
35
34
  aud_claim: payload[:aud],
36
35
  azp_claim: payload[:azp],
37
- client_id: client_id
36
+ client_id: client_id,
37
+ provider_ignores_state: true
38
38
  }
39
39
  ]
40
40
  end
@@ -59,6 +59,9 @@ describe OmniAuth::Strategies::GoogleIdToken do # rubocop:disable Metrics/BlockL
59
59
  end
60
60
 
61
61
  describe 'request phase' do
62
+ before do
63
+ OmniAuth::AuthenticityTokenProtection.default_options(key: 'csrf.token', authenticity_param: '_csrf')
64
+ end
62
65
  it 'should redirect to the configured login url' do
63
66
  post api_url
64
67
  expect(last_response.status).to eq(302)
@@ -70,8 +73,8 @@ describe OmniAuth::Strategies::GoogleIdToken do # rubocop:disable Metrics/BlockL
70
73
 
71
74
  context 'callback phase' do
72
75
  it 'should decode the response' do
73
- allow(::Google::Auth::IDTokens::Verifier).to receive(:verify_oidc)
74
- .with(id_token, aud: aud_claim, azp: azp_claim)
76
+ allow(::Google::Auth::IDTokens).to receive(:verify_oidc)
77
+ .with(id_token, aud: client_id)
75
78
  .and_return(payload)
76
79
 
77
80
  post "#{api_url}/callback", id_token: id_token
@@ -80,8 +83,8 @@ describe OmniAuth::Strategies::GoogleIdToken do # rubocop:disable Metrics/BlockL
80
83
 
81
84
  it 'should not work without required fields' do
82
85
  payload.delete('email')
83
- allow(::Google::Auth::IDTokens::Verifier).to receive(:verify_oidc)
84
- .with(id_token, aud: aud_claim, azp: azp_claim)
86
+ allow(::Google::Auth::IDTokens).to receive(:verify_oidc)
87
+ .with(id_token, aud: client_id)
85
88
  .and_return(payload)
86
89
 
87
90
  post "#{api_url}/callback", id_token: id_token
@@ -89,8 +92,8 @@ describe OmniAuth::Strategies::GoogleIdToken do # rubocop:disable Metrics/BlockL
89
92
  end
90
93
 
91
94
  it 'should assign the uid' do
92
- allow(::Google::Auth::IDTokens::Verifier).to receive(:verify_oidc)
93
- .with(id_token, aud: aud_claim, azp: azp_claim)
95
+ allow(::Google::Auth::IDTokens).to receive(:verify_oidc)
96
+ .with(id_token, aud: client_id)
94
97
  .and_return(payload)
95
98
  post "#{api_url}/callback", id_token: id_token
96
99
  expect(response_json['uid']).to eq('3141592653589793238')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-google-id-token
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Morris