gds-sso 14.1.1 → 15.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +23 -56
  3. data/Rakefile +11 -6
  4. data/app/controllers/api/user_controller.rb +30 -28
  5. data/app/controllers/authentications_controller.rb +3 -5
  6. data/app/views/layouts/unauthorised.html.erb +1 -1
  7. data/config/routes.rb +7 -6
  8. data/lib/gds-sso.rb +27 -18
  9. data/lib/gds-sso/api_access.rb +1 -1
  10. data/lib/gds-sso/bearer_token.rb +24 -24
  11. data/lib/gds-sso/config.rb +17 -9
  12. data/lib/gds-sso/controller_methods.rb +7 -8
  13. data/lib/gds-sso/failure_app.rb +8 -8
  14. data/lib/gds-sso/lint/user_spec.rb +27 -28
  15. data/lib/gds-sso/lint/user_test.rb +28 -28
  16. data/lib/gds-sso/railtie.rb +12 -0
  17. data/lib/gds-sso/user.rb +13 -13
  18. data/lib/gds-sso/version.rb +1 -1
  19. data/lib/gds-sso/warden_config.rb +21 -31
  20. data/spec/controller/api_user_controller_spec.rb +40 -37
  21. data/spec/controller/controller_methods_spec.rb +28 -28
  22. data/spec/internal/app/assets/config/manifest.js +0 -0
  23. data/spec/internal/app/controllers/application_controller.rb +1 -1
  24. data/spec/internal/app/controllers/example_controller.rb +1 -2
  25. data/spec/internal/config/initializers/gds-sso.rb +2 -2
  26. data/spec/internal/config/routes.rb +5 -2
  27. data/spec/internal/config/storage.yml +3 -0
  28. data/spec/internal/db/combustion_test.sqlite +0 -0
  29. data/spec/internal/db/schema.rb +9 -5
  30. data/spec/internal/log/test.log +1100 -1166
  31. data/spec/requests/end_to_end_spec.rb +45 -46
  32. data/spec/spec_helper.rb +12 -13
  33. data/spec/support/signon_integration_helpers.rb +9 -7
  34. data/spec/support/timecop.rb +1 -1
  35. data/spec/unit/api_access_spec.rb +7 -7
  36. data/spec/unit/bearer_token_spec.rb +14 -15
  37. data/spec/unit/config_spec.rb +5 -5
  38. data/spec/unit/mock_bearer_token_spec.rb +4 -4
  39. data/spec/unit/railtie_spec.rb +14 -0
  40. data/spec/unit/session_serialisation_spec.rb +5 -5
  41. data/spec/unit/user_spec.rb +23 -24
  42. metadata +88 -54
@@ -0,0 +1,14 @@
1
+ require "rails"
2
+ require "spec_helper"
3
+
4
+ RSpec.describe GDS::SSO::Railtie do
5
+ let(:cache) { double(:cache) }
6
+
7
+ it "re-uses the Rails cache" do
8
+ expect(GDS::SSO::Config.cache).to eq Rails.cache
9
+ end
10
+
11
+ it "honours API only setting" do
12
+ expect(GDS::SSO::Config.api_only).to eq false
13
+ end
14
+ end
@@ -1,5 +1,5 @@
1
- require 'spec_helper'
2
- require 'active_record'
1
+ require "spec_helper"
2
+ require "active_record"
3
3
 
4
4
  describe Warden::SessionSerializer do
5
5
  class SerializableUser
@@ -35,7 +35,7 @@ describe Warden::SessionSerializer do
35
35
 
36
36
  describe "deserialize a user" do
37
37
  it "should return the user if the timestamp is current and a Time" do
38
- expect(SerializableUser).to receive(:where).with(:uid => 1234, :remotely_signed_out => false).and_return(double(:first => :a_user))
38
+ expect(SerializableUser).to receive(:where).with(uid: 1234, remotely_signed_out: false).and_return(double(first: :a_user))
39
39
 
40
40
  result = @serializer.deserialize [1234, Time.now.utc - GDS::SSO::Config.auth_valid_for + 3600]
41
41
 
@@ -43,7 +43,7 @@ describe Warden::SessionSerializer do
43
43
  end
44
44
 
45
45
  it "should return the user if the timestamp is current and is an ISO 8601 string" do
46
- expect(SerializableUser).to receive(:where).with(:uid => 1234, :remotely_signed_out => false).and_return(double(:first => :a_user))
46
+ expect(SerializableUser).to receive(:where).with(uid: 1234, remotely_signed_out: false).and_return(double(first: :a_user))
47
47
 
48
48
  result = @serializer.deserialize [1234, (Time.now.utc - GDS::SSO::Config.auth_valid_for + 3600).iso8601]
49
49
 
@@ -69,7 +69,7 @@ describe Warden::SessionSerializer do
69
69
  it "should return nil for a user with a badly formatted timestamp" do
70
70
  expect(SerializableUser).not_to receive(:where)
71
71
 
72
- result = @serializer.deserialize [1234, 'this is not a timestamp']
72
+ result = @serializer.deserialize [1234, "this is not a timestamp"]
73
73
 
74
74
  expect(result).to be_nil
75
75
  end
@@ -1,33 +1,32 @@
1
- require 'spec_helper'
2
- require 'gds-sso/user'
3
- require 'gds-sso/lint/user_spec'
1
+ require "spec_helper"
2
+ require "gds-sso/user"
3
+ require "gds-sso/lint/user_spec"
4
4
 
5
- require 'ostruct'
5
+ require "ostruct"
6
6
 
7
7
  describe GDS::SSO::User do
8
8
  before :each do
9
9
  @auth_hash = {
10
- 'provider' => 'gds',
11
- 'uid' => 'abcde',
12
- 'credentials' => {'token' => 'abcdefg', 'secret' => 'abcdefg'},
13
- 'info' => {'name' => 'Matt Patterson', 'email' => 'matt@alphagov.co.uk'},
14
- 'extra' => {
15
- 'user' => {
16
- 'permissions' => [], 'organisation_slug' => nil, "organisation_content_id" => nil, 'disabled' => false
17
- }
18
- }
10
+ "provider" => "gds",
11
+ "uid" => "abcde",
12
+ "credentials" => { "token" => "abcdefg", "secret" => "abcdefg" },
13
+ "info" => { "name" => "Matt Patterson", "email" => "matt@alphagov.co.uk" },
14
+ "extra" => {
15
+ "user" => {
16
+ "permissions" => [], "organisation_slug" => nil, "organisation_content_id" => nil, "disabled" => false
17
+ },
18
+ },
19
19
  }
20
20
  end
21
21
 
22
22
  it "should extract the user params from the oauth hash" do
23
- expected = {'uid' => 'abcde',
24
- 'name' => 'Matt Patterson',
25
- 'email' => 'matt@alphagov.co.uk',
26
- "permissions" => [],
27
- "organisation_slug" => nil,
28
- "organisation_content_id" => nil,
29
- 'disabled' => false,
30
- }
23
+ expected = { "uid" => "abcde",
24
+ "name" => "Matt Patterson",
25
+ "email" => "matt@alphagov.co.uk",
26
+ "permissions" => [],
27
+ "organisation_slug" => nil,
28
+ "organisation_content_id" => nil,
29
+ "disabled" => false }
31
30
  expect(GDS::SSO::User.user_params_from_auth_hash(@auth_hash)).to eq(expected)
32
31
  end
33
32
 
@@ -35,11 +34,11 @@ describe GDS::SSO::User do
35
34
  class TestUser < OpenStruct
36
35
  include GDS::SSO::User
37
36
 
38
- def self.where(opts)
37
+ def self.where(_opts)
39
38
  []
40
39
  end
41
40
 
42
- def self.create!(options, scope = {})
41
+ def self.create!(options, _scope = {})
43
42
  new(options)
44
43
  end
45
44
 
@@ -47,7 +46,7 @@ describe GDS::SSO::User do
47
46
  send("#{key}=".to_sym, value)
48
47
  end
49
48
 
50
- def update_attributes(options)
49
+ def update!(options)
51
50
  options.each do |key, value|
52
51
  update_attribute(key, value)
53
52
  end
metadata CHANGED
@@ -1,43 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gds-sso
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.1.1
4
+ version: 15.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-19 00:00:00.000000000 Z
11
+ date: 2020-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '4'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '4'
27
- - !ruby/object:Gem::Dependency
28
- name: warden
14
+ name: multi_json
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - "~>"
32
18
  - !ruby/object:Gem::Version
33
- version: '1.2'
19
+ version: '1.0'
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: '1.2'
26
+ version: '1.0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: oauth2
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -81,47 +67,61 @@ dependencies:
81
67
  - !ruby/object:Gem::Version
82
68
  version: '3.2'
83
69
  - !ruby/object:Gem::Dependency
84
- name: warden-oauth2
70
+ name: plek
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: 0.0.1
75
+ version: '4.0'
90
76
  type: :runtime
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: 0.0.1
82
+ version: '4.0'
97
83
  - !ruby/object:Gem::Dependency
98
- name: multi_json
84
+ name: rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '5'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '5'
97
+ - !ruby/object:Gem::Dependency
98
+ name: warden
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '1.0'
103
+ version: '1.2'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '1.0'
110
+ version: '1.2'
111
111
  - !ruby/object:Gem::Dependency
112
- name: rake
112
+ name: warden-oauth2
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0.9'
118
- type: :development
117
+ version: 0.0.1
118
+ type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0.9'
124
+ version: 0.0.1
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: capybara
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -137,35 +137,35 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '2'
139
139
  - !ruby/object:Gem::Dependency
140
- name: rspec-rails
140
+ name: capybara-mechanize
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: '3'
145
+ version: '1'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
- version: '3'
152
+ version: '1'
153
153
  - !ruby/object:Gem::Dependency
154
- name: capybara-mechanize
154
+ name: combustion
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
158
158
  - !ruby/object:Gem::Version
159
- version: '1'
159
+ version: '0.9'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
- version: '1'
166
+ version: '0.9'
167
167
  - !ruby/object:Gem::Dependency
168
- name: combustion
168
+ name: rake
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ">="
@@ -178,20 +178,48 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0.9'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rspec-rails
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '3'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '3'
195
+ - !ruby/object:Gem::Dependency
196
+ name: rubocop-govuk
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
181
209
  - !ruby/object:Gem::Dependency
182
210
  name: sqlite3
183
211
  requirement: !ruby/object:Gem::Requirement
184
212
  requirements:
185
213
  - - "~>"
186
214
  - !ruby/object:Gem::Version
187
- version: 1.3.13
215
+ version: '1.4'
188
216
  type: :development
189
217
  prerelease: false
190
218
  version_requirements: !ruby/object:Gem::Requirement
191
219
  requirements:
192
220
  - - "~>"
193
221
  - !ruby/object:Gem::Version
194
- version: 1.3.13
222
+ version: '1.4'
195
223
  - !ruby/object:Gem::Dependency
196
224
  name: timecop
197
225
  requirement: !ruby/object:Gem::Requirement
@@ -231,6 +259,7 @@ files:
231
259
  - lib/gds-sso/failure_app.rb
232
260
  - lib/gds-sso/lint/user_spec.rb
233
261
  - lib/gds-sso/lint/user_test.rb
262
+ - lib/gds-sso/railtie.rb
234
263
  - lib/gds-sso/user.rb
235
264
  - lib/gds-sso/version.rb
236
265
  - lib/gds-sso/warden_config.rb
@@ -238,12 +267,14 @@ files:
238
267
  - spec/controller/controller_methods_spec.rb
239
268
  - spec/fixtures/integration/authorize_api_users.sql
240
269
  - spec/fixtures/integration/signon.sql
270
+ - spec/internal/app/assets/config/manifest.js
241
271
  - spec/internal/app/controllers/application_controller.rb
242
272
  - spec/internal/app/controllers/example_controller.rb
243
273
  - spec/internal/app/models/user.rb
244
274
  - spec/internal/config/database.yml
245
275
  - spec/internal/config/initializers/gds-sso.rb
246
276
  - spec/internal/config/routes.rb
277
+ - spec/internal/config/storage.yml
247
278
  - spec/internal/db/combustion_test.sqlite
248
279
  - spec/internal/db/schema.rb
249
280
  - spec/internal/log/test.log
@@ -257,6 +288,7 @@ files:
257
288
  - spec/unit/bearer_token_spec.rb
258
289
  - spec/unit/config_spec.rb
259
290
  - spec/unit/mock_bearer_token_spec.rb
291
+ - spec/unit/railtie_spec.rb
260
292
  - spec/unit/session_serialisation_spec.rb
261
293
  - spec/unit/user_spec.rb
262
294
  homepage: https://github.com/alphagov/gds-sso
@@ -271,41 +303,43 @@ required_ruby_version: !ruby/object:Gem::Requirement
271
303
  requirements:
272
304
  - - ">="
273
305
  - !ruby/object:Gem::Version
274
- version: 2.2.2
306
+ version: '2.6'
275
307
  required_rubygems_version: !ruby/object:Gem::Requirement
276
308
  requirements:
277
309
  - - ">="
278
310
  - !ruby/object:Gem::Version
279
311
  version: '0'
280
312
  requirements: []
281
- rubyforge_project:
282
- rubygems_version: 2.7.6
313
+ rubygems_version: 3.1.4
283
314
  signing_key:
284
315
  specification_version: 4
285
316
  summary: Client for GDS' OAuth 2-based SSO
286
317
  test_files:
318
+ - spec/controller/controller_methods_spec.rb
319
+ - spec/controller/api_user_controller_spec.rb
320
+ - spec/internal/config/storage.yml
321
+ - spec/internal/config/routes.rb
287
322
  - spec/internal/config/database.yml
288
323
  - spec/internal/config/initializers/gds-sso.rb
289
- - spec/internal/config/routes.rb
290
324
  - spec/internal/public/favicon.ico
325
+ - spec/internal/app/assets/config/manifest.js
291
326
  - spec/internal/app/controllers/application_controller.rb
292
327
  - spec/internal/app/controllers/example_controller.rb
293
328
  - spec/internal/app/models/user.rb
294
329
  - spec/internal/log/test.log
295
- - spec/internal/db/combustion_test.sqlite
296
330
  - spec/internal/db/schema.rb
297
- - spec/controller/api_user_controller_spec.rb
298
- - spec/controller/controller_methods_spec.rb
299
- - spec/support/timecop.rb
331
+ - spec/internal/db/combustion_test.sqlite
300
332
  - spec/support/backport_controller_test_params.rb
301
333
  - spec/support/signon_integration_helpers.rb
302
- - spec/fixtures/integration/signon.sql
303
- - spec/fixtures/integration/authorize_api_users.sql
304
- - spec/unit/api_access_spec.rb
334
+ - spec/support/timecop.rb
335
+ - spec/spec_helper.rb
305
336
  - spec/unit/config_spec.rb
306
- - spec/unit/session_serialisation_spec.rb
307
- - spec/unit/user_spec.rb
308
337
  - spec/unit/bearer_token_spec.rb
309
338
  - spec/unit/mock_bearer_token_spec.rb
310
- - spec/spec_helper.rb
339
+ - spec/unit/api_access_spec.rb
340
+ - spec/unit/railtie_spec.rb
341
+ - spec/unit/session_serialisation_spec.rb
342
+ - spec/unit/user_spec.rb
343
+ - spec/fixtures/integration/authorize_api_users.sql
344
+ - spec/fixtures/integration/signon.sql
311
345
  - spec/requests/end_to_end_spec.rb