omniauth-seznam-cz 0.0.1 → 0.0.2

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: f009f7470aef979d8104389d3beb5e477bd09fa974da325913c22dbaafa84959
4
- data.tar.gz: 495f8ce948f74219cda3be1df8eb6465a3bd3b5be36b72405f712242c73cc8ca
3
+ metadata.gz: 9271faeba9c9cea0f61c4e121255521bde0b3852c8170e807071793d550710ed
4
+ data.tar.gz: 89eb3f23cc24cef52e775f029e0532354c77be40fc3da4da7deb5ad66af03997
5
5
  SHA512:
6
- metadata.gz: '09c096615acd0f366d707812bc2e1faf78277b57636db68dd2f31e1b9fe3dc1a06931e32c6a40f59fc2f0f6a32a769365ccc0fc58075482ae911b69c5516fed4'
7
- data.tar.gz: ab3cb2cb209b02e19f7e7d39aa8a9cc3e283f1de54b446f5f6ef2bd4acbd06ee67025fa96aa2156519b90eeaf20d6f5be2e73f20f5c299fd86c5658ab54961ae
6
+ metadata.gz: '03235926e68fbb8016ba3f0511b77458befedd8a6f61c32c51f9e8784707ac9b60db4a6685982faf8ca5548e5deb24d223bff4a0cca38baa7b2aec7bd795ce84'
7
+ data.tar.gz: 960ca9ced83c30fc181f8846054f0c7e428059eae600641abe743759f7e41a6af9c10dde81e3c0573a4d2367e869b04213a23494b664e7ff54d1e443deab2f57
data/.gitignore CHANGED
@@ -1,22 +1,12 @@
1
1
  *.gem
2
- *.rbc
3
2
  .bundle
4
3
  .config
5
- .yardoc
6
4
  .ruby-gemset
7
5
  .ruby-version
8
6
  .rvmrc
9
- Gemfile.lock
10
- InstalledFiles
11
- _yardoc
12
- coverage
13
- doc/
14
- lib/bundler/man
15
- pkg
16
7
  rdoc
17
8
  spec/reports
18
9
  test/tmp
19
10
  test/version_tmp
20
11
  tmp
21
- .powenv
22
12
  .idea/
data/.travis.yml CHANGED
@@ -1,6 +1,5 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - '2.7.2'
5
- - '2.7.6'
4
+ - '2.7.4'
6
5
  - '3.0.0'
data/Gemfile.lock ADDED
@@ -0,0 +1,99 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-seznam-cz (0.0.1)
5
+ oauth2 (~> 1.1)
6
+ omniauth (~> 2.0)
7
+ omniauth-oauth2 (~> 1.7.1)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ ast (2.4.2)
13
+ diff-lcs (1.5.0)
14
+ faraday (1.8.0)
15
+ faraday-em_http (~> 1.0)
16
+ faraday-em_synchrony (~> 1.0)
17
+ faraday-excon (~> 1.1)
18
+ faraday-httpclient (~> 1.0.1)
19
+ faraday-net_http (~> 1.0)
20
+ faraday-net_http_persistent (~> 1.1)
21
+ faraday-patron (~> 1.0)
22
+ faraday-rack (~> 1.0)
23
+ multipart-post (>= 1.2, < 3)
24
+ ruby2_keywords (>= 0.0.4)
25
+ faraday-em_http (1.0.0)
26
+ faraday-em_synchrony (1.0.0)
27
+ faraday-excon (1.1.0)
28
+ faraday-httpclient (1.0.1)
29
+ faraday-net_http (1.0.1)
30
+ faraday-net_http_persistent (1.2.0)
31
+ faraday-patron (1.0.0)
32
+ faraday-rack (1.0.0)
33
+ hashie (5.0.0)
34
+ jwt (2.3.0)
35
+ multi_json (1.15.0)
36
+ multi_xml (0.6.0)
37
+ multipart-post (2.1.1)
38
+ oauth2 (1.4.7)
39
+ faraday (>= 0.8, < 2.0)
40
+ jwt (>= 1.0, < 3.0)
41
+ multi_json (~> 1.3)
42
+ multi_xml (~> 0.5)
43
+ rack (>= 1.2, < 3)
44
+ omniauth (2.0.4)
45
+ hashie (>= 3.4.6)
46
+ rack (>= 1.6.2, < 3)
47
+ rack-protection
48
+ omniauth-oauth2 (1.7.2)
49
+ oauth2 (~> 1.4)
50
+ omniauth (>= 1.9, < 3)
51
+ parallel (1.21.0)
52
+ parser (3.0.3.2)
53
+ ast (~> 2.4.1)
54
+ rack (2.2.3)
55
+ rack-protection (2.1.0)
56
+ rack
57
+ rainbow (3.0.0)
58
+ rake (12.3.3)
59
+ regexp_parser (2.2.0)
60
+ rexml (3.2.5)
61
+ rspec (3.10.0)
62
+ rspec-core (~> 3.10.0)
63
+ rspec-expectations (~> 3.10.0)
64
+ rspec-mocks (~> 3.10.0)
65
+ rspec-core (3.10.1)
66
+ rspec-support (~> 3.10.0)
67
+ rspec-expectations (3.10.1)
68
+ diff-lcs (>= 1.2.0, < 2.0)
69
+ rspec-support (~> 3.10.0)
70
+ rspec-mocks (3.10.2)
71
+ diff-lcs (>= 1.2.0, < 2.0)
72
+ rspec-support (~> 3.10.0)
73
+ rspec-support (3.10.3)
74
+ rubocop (0.93.1)
75
+ parallel (~> 1.10)
76
+ parser (>= 2.7.1.5)
77
+ rainbow (>= 2.2.2, < 4.0)
78
+ regexp_parser (>= 1.8)
79
+ rexml
80
+ rubocop-ast (>= 0.6.0)
81
+ ruby-progressbar (~> 1.7)
82
+ unicode-display_width (>= 1.4.0, < 2.0)
83
+ rubocop-ast (1.15.1)
84
+ parser (>= 3.0.1.1)
85
+ ruby-progressbar (1.11.0)
86
+ ruby2_keywords (0.0.5)
87
+ unicode-display_width (1.8.0)
88
+
89
+ PLATFORMS
90
+ arm64-darwin-20
91
+
92
+ DEPENDENCIES
93
+ omniauth-seznam-cz!
94
+ rake (~> 12.0)
95
+ rspec (~> 3.6)
96
+ rubocop (~> 0.49)
97
+
98
+ BUNDLED WITH
99
+ 2.2.16
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/omniauth-seznam-cz.svg)](https://badge.fury.io/rb/omniauth-seznam-cz)
2
- [![Build Status](https://travis-ci.com/zquestz/omniauth-seznam-cz.svg)](https://travis-ci.com/zquestz/omniauth-seznam-cz)
2
+ [![Build Status](https://app.travis-ci.com/honzasterba/omniauth-seznam-cz.svg?branch=main)](https://app.travis-ci.com/honzasterba/omniauth-seznam-cz)
3
3
 
4
4
  # OmniAuth Seznam.cz Strategy
5
5
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module SeznamCz
5
- VERSION = '0.0.1'
5
+ VERSION = '0.0.2'
6
6
  end
7
7
  end
@@ -16,13 +16,13 @@ module OmniAuth
16
16
 
17
17
  option :name, 'seznam_cz'
18
18
  option :skip_image_info, true
19
- option :authorize_options, %i[redirect_uri]
19
+ option :authorize_options, %i[scope state redirect_uri]
20
20
  option :authorized_client_ids, []
21
21
 
22
22
  option :client_options,
23
23
  site: 'https://login.szn.cz/api/v1/oauth',
24
24
  authorize_url: 'https://login.szn.cz/api/v1/oauth/auth',
25
- token_url: '/token'
25
+ token_url: 'https://login.szn.cz/api/v1/oauth/token'
26
26
 
27
27
  def authorize_params
28
28
  super.tap do |params|
@@ -31,15 +31,15 @@ describe OmniAuth::Strategies::SeznamCz do
31
31
 
32
32
  describe '#client_options' do
33
33
  it 'has correct site' do
34
- expect(subject.client.site).to eq('https://oauth2.googleapis.com')
34
+ expect(subject.client.site).to eq('https://login.szn.cz/api/v1/oauth')
35
35
  end
36
36
 
37
37
  it 'has correct authorize_url' do
38
- expect(subject.client.options[:authorize_url]).to eq('https://accounts.google.com/o/oauth2/auth')
38
+ expect(subject.client.options[:authorize_url]).to eq('https://login.szn.cz/api/v1/oauth/auth')
39
39
  end
40
40
 
41
41
  it 'has correct token_url' do
42
- expect(subject.client.options[:token_url]).to eq('/token')
42
+ expect(subject.client.options[:token_url]).to eq('https://login.szn.cz/api/v1/oauth/token')
43
43
  end
44
44
 
45
45
  describe 'overrides' do
@@ -80,13 +80,6 @@ describe OmniAuth::Strategies::SeznamCz do
80
80
  end
81
81
 
82
82
  describe '#authorize_options' do
83
- %i[access_type hd login_hint prompt scope state device_id device_name].each do |k|
84
- it "should support #{k}" do
85
- @options = { k => 'http://someval' }
86
- expect(subject.authorize_params[k.to_s]).to eq('http://someval')
87
- end
88
- end
89
-
90
83
  describe 'redirect_uri' do
91
84
  it 'should default to nil' do
92
85
  @options = {}
@@ -99,116 +92,24 @@ describe OmniAuth::Strategies::SeznamCz do
99
92
  end
100
93
  end
101
94
 
102
- describe 'access_type' do
103
- it 'should default to "offline"' do
104
- @options = {}
105
- expect(subject.authorize_params['access_type']).to eq('offline')
106
- end
107
-
108
- it 'should set the access_type parameter if present' do
109
- @options = { access_type: 'online' }
110
- expect(subject.authorize_params['access_type']).to eq('online')
111
- end
112
- end
113
-
114
- describe 'hd' do
115
- it 'should default to nil' do
116
- expect(subject.authorize_params['hd']).to eq(nil)
117
- end
118
-
119
- it 'should set the hd (hosted domain) parameter if present' do
120
- @options = { hd: 'example.com' }
121
- expect(subject.authorize_params['hd']).to eq('example.com')
122
- end
123
-
124
- it 'should set the hd parameter and work with nil hd (gmail)' do
125
- @options = { hd: nil }
126
- expect(subject.authorize_params['hd']).to eq(nil)
127
- end
128
-
129
- it 'should set the hd parameter to * if set (only allows G Suite emails)' do
130
- @options = { hd: '*' }
131
- expect(subject.authorize_params['hd']).to eq('*')
132
- end
133
- end
134
-
135
- describe 'login_hint' do
136
- it 'should default to nil' do
137
- expect(subject.authorize_params['login_hint']).to eq(nil)
138
- end
139
-
140
- it 'should set the login_hint parameter if present' do
141
- @options = { login_hint: 'john@example.com' }
142
- expect(subject.authorize_params['login_hint']).to eq('john@example.com')
143
- end
144
- end
145
-
146
- describe 'prompt' do
147
- it 'should default to nil' do
148
- expect(subject.authorize_params['prompt']).to eq(nil)
149
- end
150
-
151
- it 'should set the prompt parameter if present' do
152
- @options = { prompt: 'consent select_account' }
153
- expect(subject.authorize_params['prompt']).to eq('consent select_account')
154
- end
155
- end
156
-
157
- describe 'request_visible_actions' do
158
- it 'should default to nil' do
159
- expect(subject.authorize_params['request_visible_actions']).to eq(nil)
160
- end
161
-
162
- it 'should set the request_visible_actions parameter if present' do
163
- @options = { request_visible_actions: 'something' }
164
- expect(subject.authorize_params['request_visible_actions']).to eq('something')
165
- end
166
- end
167
-
168
- describe 'include_granted_scopes' do
169
- it 'should default to nil' do
170
- expect(subject.authorize_params['include_granted_scopes']).to eq(nil)
171
- end
172
-
173
- it 'should set the include_granted_scopes parameter if present' do
174
- @options = { include_granted_scopes: 'true' }
175
- expect(subject.authorize_params['include_granted_scopes']).to eq('true')
176
- end
177
- end
178
-
179
95
  describe 'scope' do
180
- it 'should expand scope shortcuts' do
181
- @options = { scope: 'calendar' }
182
- expect(subject.authorize_params['scope']).to eq('https://www.googleapis.com/auth/calendar')
183
- end
184
-
185
- it 'should leave base scopes as is' do
186
- @options = { scope: 'profile' }
187
- expect(subject.authorize_params['scope']).to eq('profile')
188
- end
189
-
190
96
  it 'should join scopes' do
191
97
  @options = { scope: 'profile,email' }
192
- expect(subject.authorize_params['scope']).to eq('profile email')
98
+ expect(subject.authorize_params['scope']).to eq('profile,email')
193
99
  end
194
100
 
195
101
  it 'should deal with whitespace when joining scopes' do
196
102
  @options = { scope: 'profile, email' }
197
- expect(subject.authorize_params['scope']).to eq('profile email')
103
+ expect(subject.authorize_params['scope']).to eq('profile,email')
198
104
  end
199
105
 
200
- it 'should set default scope to email,profile' do
201
- expect(subject.authorize_params['scope']).to eq('email profile')
106
+ it 'should set default scope to identity' do
107
+ expect(subject.authorize_params['scope']).to eq('identity')
202
108
  end
203
109
 
204
110
  it 'should support space delimited scopes' do
205
111
  @options = { scope: 'profile email' }
206
- expect(subject.authorize_params['scope']).to eq('profile email')
207
- end
208
-
209
- it 'should support extremely badly formed scopes' do
210
- @options = { scope: 'profile email,foo,steve yeah http://example.com' }
211
- expect(subject.authorize_params['scope']).to eq('profile email https://www.googleapis.com/auth/foo https://www.googleapis.com/auth/steve https://www.googleapis.com/auth/yeah http://example.com')
112
+ expect(subject.authorize_params['scope']).to eq('profile,email')
212
113
  end
213
114
  end
214
115
 
@@ -238,7 +139,7 @@ describe OmniAuth::Strategies::SeznamCz do
238
139
  end
239
140
 
240
141
  describe 'request overrides' do
241
- %i[access_type hd login_hint prompt scope state].each do |k|
142
+ %i[scope state].each do |k|
242
143
  context "authorize option #{k}" do
243
144
  let(:request) { double('Request', params: { k.to_s => 'http://example.com' }, cookies: {}, env: {}) }
244
145
 
@@ -267,7 +168,6 @@ describe OmniAuth::Strategies::SeznamCz do
267
168
  expect(subject.authorize_params['request_visible_actions']).to eq('something')
268
169
  expect(subject.authorize_params['foo']).to eq('bar')
269
170
  expect(subject.authorize_params['baz']).to eq('zip')
270
- expect(subject.authorize_params['hd']).to eq('wow')
271
171
  expect(subject.authorize_params['bad']).to eq(nil)
272
172
  end
273
173
  end
@@ -289,137 +189,4 @@ describe OmniAuth::Strategies::SeznamCz do
289
189
  end
290
190
  end
291
191
 
292
- describe '#callback_url' do
293
- let(:base_url) { 'https://example.com' }
294
-
295
- it 'has the correct default callback path' do
296
- allow(subject).to receive(:full_host) { base_url }
297
- allow(subject).to receive(:script_name) { '' }
298
- expect(subject.send(:callback_url)).to eq(base_url + '/auth/google_oauth2/callback')
299
- end
300
-
301
- it 'should set the callback path with script_name if present' do
302
- allow(subject).to receive(:full_host) { base_url }
303
- allow(subject).to receive(:script_name) { '/v1' }
304
- expect(subject.send(:callback_url)).to eq(base_url + '/v1/auth/google_oauth2/callback')
305
- end
306
-
307
- it 'should set the callback_path parameter if present' do
308
- @options = { callback_path: '/auth/foo/callback' }
309
- allow(subject).to receive(:full_host) { base_url }
310
- allow(subject).to receive(:script_name) { '' }
311
- expect(subject.send(:callback_url)).to eq(base_url + '/auth/foo/callback')
312
- end
313
- end
314
-
315
- describe '#info' do
316
- let(:client) do
317
- OAuth2::Client.new('abc', 'def') do |builder|
318
- builder.request :url_encoded
319
- builder.adapter :test do |stub|
320
- stub.get('/oauth2/v3/userinfo') { [200, { 'content-type' => 'application/json' }, response_hash.to_json] }
321
- end
322
- end
323
- end
324
- let(:access_token) { OAuth2::AccessToken.from_hash(client, {}) }
325
- before { allow(subject).to receive(:access_token).and_return(access_token) }
326
-
327
- context 'with verified email' do
328
- let(:response_hash) do
329
- { email: 'something@domain.invalid', email_verified: true }
330
- end
331
-
332
- it 'should return equal email and unverified_email' do
333
- expect(subject.info[:email]).to eq('something@domain.invalid')
334
- expect(subject.info[:unverified_email]).to eq('something@domain.invalid')
335
- end
336
- end
337
-
338
- context 'with unverified email' do
339
- let(:response_hash) do
340
- { email: 'something@domain.invalid', email_verified: false }
341
- end
342
-
343
- it 'should return nil email, and correct unverified email' do
344
- expect(subject.info[:email]).to eq(nil)
345
- expect(subject.info[:unverified_email]).to eq('something@domain.invalid')
346
- end
347
- end
348
- end
349
-
350
- describe '#extra' do
351
- let(:client) do
352
- OAuth2::Client.new('abc', 'def') do |builder|
353
- builder.request :url_encoded
354
- builder.adapter :test do |stub|
355
- stub.get('/oauth2/v3/userinfo') { [200, { 'content-type' => 'application/json' }, '{"sub": "12345"}'] }
356
- end
357
- end
358
- end
359
- let(:access_token) { OAuth2::AccessToken.from_hash(client, {}) }
360
-
361
- before { allow(subject).to receive(:access_token).and_return(access_token) }
362
-
363
- describe 'id_token' do
364
- shared_examples 'id_token issued by valid issuer' do |issuer|
365
- context 'when the id_token is passed into the access token' do
366
- let(:token_info) do
367
- {
368
- 'abc' => 'xyz',
369
- 'exp' => Time.now.to_i + 3600,
370
- 'nbf' => Time.now.to_i - 60,
371
- 'iat' => Time.now.to_i,
372
- 'aud' => 'appid',
373
- 'iss' => issuer
374
- }
375
- end
376
- let(:id_token) { JWT.encode(token_info, 'secret') }
377
- let(:access_token) { OAuth2::AccessToken.from_hash(client, 'id_token' => id_token) }
378
-
379
- it 'should include id_token when set on the access_token' do
380
- expect(subject.extra).to include(id_token: id_token)
381
- end
382
-
383
-
384
-
385
- it 'should include id_info when id_token is set on the access_token by default' do
386
- expect(subject.extra).to include(id_info: token_info)
387
- end
388
- end
389
- end
390
-
391
- it_behaves_like 'id_token issued by valid issuer', 'accounts.google.com'
392
- it_behaves_like 'id_token issued by valid issuer', 'https://accounts.google.com'
393
-
394
- context 'when the id_token is missing' do
395
- it 'should not include id_token' do
396
- expect(subject.extra).not_to have_key(:id_token)
397
- end
398
-
399
- it 'should not include id_info' do
400
- expect(subject.extra).not_to have_key(:id_info)
401
- end
402
- end
403
- end
404
-
405
- describe 'raw_info' do
406
- context 'when skip_info is true' do
407
- before { subject.options[:skip_info] = true }
408
-
409
- it 'should not include raw_info' do
410
- expect(subject.extra).not_to have_key(:raw_info)
411
- end
412
- end
413
-
414
- context 'when skip_info is false' do
415
- before { subject.options[:skip_info] = false }
416
-
417
- it 'should include raw_info' do
418
- expect(subject.extra[:raw_info]).to eq('sub' => '12345')
419
- end
420
- end
421
- end
422
- end
423
-
424
-
425
192
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-seznam-cz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Sterba
@@ -107,6 +107,7 @@ files:
107
107
  - ".travis.yml"
108
108
  - CHANGELOG.md
109
109
  - Gemfile
110
+ - Gemfile.lock
110
111
  - README.md
111
112
  - Rakefile
112
113
  - lib/omniauth-seznam-cz.rb