gds-sso 14.1.0 → 15.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +11 -6
- data/app/controllers/api/user_controller.rb +30 -28
- data/app/controllers/authentications_controller.rb +3 -5
- data/app/views/layouts/unauthorised.html.erb +1 -1
- data/config/routes.rb +6 -5
- data/lib/gds-sso.rb +24 -17
- data/lib/gds-sso/api_access.rb +1 -1
- data/lib/gds-sso/bearer_token.rb +24 -23
- data/lib/gds-sso/config.rb +13 -2
- data/lib/gds-sso/controller_methods.rb +5 -6
- data/lib/gds-sso/failure_app.rb +7 -7
- data/lib/gds-sso/lint/user_spec.rb +27 -28
- data/lib/gds-sso/lint/user_test.rb +28 -28
- data/lib/gds-sso/user.rb +13 -13
- data/lib/gds-sso/version.rb +1 -1
- data/lib/gds-sso/warden_config.rb +21 -31
- data/spec/controller/api_user_controller_spec.rb +40 -37
- data/spec/controller/controller_methods_spec.rb +28 -28
- data/spec/internal/app/assets/config/manifest.js +0 -0
- data/spec/internal/app/controllers/application_controller.rb +1 -1
- data/spec/internal/app/controllers/example_controller.rb +1 -2
- data/spec/internal/config/initializers/gds-sso.rb +2 -2
- data/spec/internal/config/routes.rb +5 -2
- data/spec/internal/config/storage.yml +3 -0
- data/spec/internal/db/combustion_test.sqlite +0 -0
- data/spec/internal/db/schema.rb +9 -5
- data/spec/internal/log/test.log +1048 -1114
- data/spec/requests/end_to_end_spec.rb +45 -46
- data/spec/spec_helper.rb +12 -13
- data/spec/support/signon_integration_helpers.rb +9 -7
- data/spec/support/timecop.rb +1 -1
- data/spec/unit/api_access_spec.rb +7 -7
- data/spec/unit/bearer_token_spec.rb +14 -15
- data/spec/unit/config_spec.rb +5 -5
- data/spec/unit/mock_bearer_token_spec.rb +4 -4
- data/spec/unit/session_serialisation_spec.rb +5 -5
- data/spec/unit/user_spec.rb +23 -24
- metadata +80 -63
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
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(:
|
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(:
|
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,
|
72
|
+
result = @serializer.deserialize [1234, "this is not a timestamp"]
|
73
73
|
|
74
74
|
expect(result).to be_nil
|
75
75
|
end
|
data/spec/unit/user_spec.rb
CHANGED
@@ -1,33 +1,32 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "spec_helper"
|
2
|
+
require "gds-sso/user"
|
3
|
+
require "gds-sso/lint/user_spec"
|
4
4
|
|
5
|
-
require
|
5
|
+
require "ostruct"
|
6
6
|
|
7
7
|
describe GDS::SSO::User do
|
8
8
|
before :each do
|
9
9
|
@auth_hash = {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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 = {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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(
|
37
|
+
def self.where(_opts)
|
39
38
|
[]
|
40
39
|
end
|
41
40
|
|
42
|
-
def self.create!(options,
|
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
|
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:
|
4
|
+
version: 15.0.1
|
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:
|
11
|
+
date: 2020-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
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.
|
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.
|
26
|
+
version: '1.0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: oauth2
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,47 +67,47 @@ dependencies:
|
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '3.2'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
70
|
+
name: rails
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
|
-
- - "
|
73
|
+
- - ">="
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
75
|
+
version: '5'
|
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:
|
82
|
+
version: '5'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
84
|
+
name: warden
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
87
|
- - "~>"
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version: '1.
|
89
|
+
version: '1.2'
|
104
90
|
type: :runtime
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
94
|
- - "~>"
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version: '1.
|
96
|
+
version: '1.2'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
98
|
+
name: warden-oauth2
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
|
-
- - "
|
101
|
+
- - "~>"
|
116
102
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
118
|
-
type: :
|
103
|
+
version: 0.0.1
|
104
|
+
type: :runtime
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
107
|
requirements:
|
122
|
-
- - "
|
108
|
+
- - "~>"
|
123
109
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
110
|
+
version: 0.0.1
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
112
|
name: capybara
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,35 +123,35 @@ dependencies:
|
|
137
123
|
- !ruby/object:Gem::Version
|
138
124
|
version: '2'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
126
|
+
name: capybara-mechanize
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
142
128
|
requirements:
|
143
129
|
- - ">="
|
144
130
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
131
|
+
version: '1'
|
146
132
|
type: :development
|
147
133
|
prerelease: false
|
148
134
|
version_requirements: !ruby/object:Gem::Requirement
|
149
135
|
requirements:
|
150
136
|
- - ">="
|
151
137
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
138
|
+
version: '1'
|
153
139
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
140
|
+
name: combustion
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|
156
142
|
requirements:
|
157
143
|
- - ">="
|
158
144
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
145
|
+
version: '0.9'
|
160
146
|
type: :development
|
161
147
|
prerelease: false
|
162
148
|
version_requirements: !ruby/object:Gem::Requirement
|
163
149
|
requirements:
|
164
150
|
- - ">="
|
165
151
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
152
|
+
version: '0.9'
|
167
153
|
- !ruby/object:Gem::Dependency
|
168
|
-
name:
|
154
|
+
name: rake
|
169
155
|
requirement: !ruby/object:Gem::Requirement
|
170
156
|
requirements:
|
171
157
|
- - ">="
|
@@ -178,20 +164,48 @@ dependencies:
|
|
178
164
|
- - ">="
|
179
165
|
- !ruby/object:Gem::Version
|
180
166
|
version: '0.9'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rspec-rails
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '3'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '3'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: rubocop-govuk
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
196
|
name: sqlite3
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
184
198
|
requirements:
|
185
199
|
- - "~>"
|
186
200
|
- !ruby/object:Gem::Version
|
187
|
-
version: 1.
|
201
|
+
version: '1.4'
|
188
202
|
type: :development
|
189
203
|
prerelease: false
|
190
204
|
version_requirements: !ruby/object:Gem::Requirement
|
191
205
|
requirements:
|
192
206
|
- - "~>"
|
193
207
|
- !ruby/object:Gem::Version
|
194
|
-
version: 1.
|
208
|
+
version: '1.4'
|
195
209
|
- !ruby/object:Gem::Dependency
|
196
210
|
name: timecop
|
197
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -238,12 +252,14 @@ files:
|
|
238
252
|
- spec/controller/controller_methods_spec.rb
|
239
253
|
- spec/fixtures/integration/authorize_api_users.sql
|
240
254
|
- spec/fixtures/integration/signon.sql
|
255
|
+
- spec/internal/app/assets/config/manifest.js
|
241
256
|
- spec/internal/app/controllers/application_controller.rb
|
242
257
|
- spec/internal/app/controllers/example_controller.rb
|
243
258
|
- spec/internal/app/models/user.rb
|
244
259
|
- spec/internal/config/database.yml
|
245
260
|
- spec/internal/config/initializers/gds-sso.rb
|
246
261
|
- spec/internal/config/routes.rb
|
262
|
+
- spec/internal/config/storage.yml
|
247
263
|
- spec/internal/db/combustion_test.sqlite
|
248
264
|
- spec/internal/db/schema.rb
|
249
265
|
- spec/internal/log/test.log
|
@@ -271,41 +287,42 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
271
287
|
requirements:
|
272
288
|
- - ">="
|
273
289
|
- !ruby/object:Gem::Version
|
274
|
-
version: 2.
|
290
|
+
version: '2.6'
|
275
291
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
276
292
|
requirements:
|
277
293
|
- - ">="
|
278
294
|
- !ruby/object:Gem::Version
|
279
295
|
version: '0'
|
280
296
|
requirements: []
|
281
|
-
|
282
|
-
rubygems_version: 2.7.6
|
297
|
+
rubygems_version: 3.1.2
|
283
298
|
signing_key:
|
284
299
|
specification_version: 4
|
285
300
|
summary: Client for GDS' OAuth 2-based SSO
|
286
301
|
test_files:
|
287
|
-
- spec/
|
288
|
-
- spec/
|
289
|
-
- spec/support/signon_integration_helpers.rb
|
290
|
-
- spec/unit/user_spec.rb
|
302
|
+
- spec/requests/end_to_end_spec.rb
|
303
|
+
- spec/spec_helper.rb
|
291
304
|
- spec/unit/api_access_spec.rb
|
305
|
+
- spec/unit/bearer_token_spec.rb
|
306
|
+
- spec/unit/config_spec.rb
|
292
307
|
- spec/unit/mock_bearer_token_spec.rb
|
293
308
|
- spec/unit/session_serialisation_spec.rb
|
294
|
-
- spec/unit/
|
295
|
-
- spec/
|
296
|
-
- spec/
|
297
|
-
- spec/
|
298
|
-
- spec/
|
299
|
-
- spec/
|
300
|
-
- spec/
|
301
|
-
- spec/controller/api_user_controller_spec.rb
|
302
|
-
- spec/internal/log/test.log
|
303
|
-
- spec/internal/public/favicon.ico
|
309
|
+
- spec/unit/user_spec.rb
|
310
|
+
- spec/internal/app/assets/config/manifest.js
|
311
|
+
- spec/internal/app/controllers/application_controller.rb
|
312
|
+
- spec/internal/app/controllers/example_controller.rb
|
313
|
+
- spec/internal/app/models/user.rb
|
314
|
+
- spec/internal/config/routes.rb
|
315
|
+
- spec/internal/config/storage.yml
|
304
316
|
- spec/internal/config/database.yml
|
305
317
|
- spec/internal/config/initializers/gds-sso.rb
|
306
|
-
- spec/internal/
|
307
|
-
- spec/internal/
|
308
|
-
- spec/internal/app/controllers/example_controller.rb
|
309
|
-
- spec/internal/app/controllers/application_controller.rb
|
318
|
+
- spec/internal/log/test.log
|
319
|
+
- spec/internal/public/favicon.ico
|
310
320
|
- spec/internal/db/schema.rb
|
311
321
|
- spec/internal/db/combustion_test.sqlite
|
322
|
+
- spec/support/timecop.rb
|
323
|
+
- spec/support/backport_controller_test_params.rb
|
324
|
+
- spec/support/signon_integration_helpers.rb
|
325
|
+
- spec/fixtures/integration/signon.sql
|
326
|
+
- spec/fixtures/integration/authorize_api_users.sql
|
327
|
+
- spec/controller/api_user_controller_spec.rb
|
328
|
+
- spec/controller/controller_methods_spec.rb
|