devise_masquerade 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +26 -23
- data/README.md +1 -1
- data/app/controllers/devise/masquerades_controller.rb +3 -3
- data/lib/devise_masquerade/controllers/helpers.rb +1 -1
- data/lib/devise_masquerade/version.rb +1 -1
- data/spec/controllers/devise/masquerades_controller_spec.rb +7 -7
- data/spec/controllers/masquerades_tests_controller_spec.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d75ba6f4e3241b021e9ef1c838e9baf1322ec0c7731573dc1008dc8931d59e7
|
4
|
+
data.tar.gz: 3bb9c12ca5dbddd8b61f64f0394f659998e6cae2be67790df2224b91c1558862
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8683eca8761589df6e6349a19cddf6de9b6a7c2f90390a6d46701f6c2dd55acc964196406f35a8ad9ba67fa486787284ed62460768fe9feea85dacb612981197
|
7
|
+
data.tar.gz: 87ba78777ff2f926f247776bf14e21114f361711a3df95b42dc76c3352ff32c08822fdb82024179ed8d614fa54b30a6f82e38bc2d1cab6eea3a62db1d206f9ff
|
data/Gemfile.lock
CHANGED
@@ -52,7 +52,7 @@ GIT
|
|
52
52
|
PATH
|
53
53
|
remote: .
|
54
54
|
specs:
|
55
|
-
devise_masquerade (2.0
|
55
|
+
devise_masquerade (2.1.0)
|
56
56
|
devise (>= 4.7.0)
|
57
57
|
globalid (>= 0.3.6)
|
58
58
|
railties (>= 5.2.0)
|
@@ -104,22 +104,23 @@ GEM
|
|
104
104
|
bson (~> 1.12.5)
|
105
105
|
builder (3.2.3)
|
106
106
|
byebug (11.0.1)
|
107
|
-
capybara (3.
|
107
|
+
capybara (3.37.1)
|
108
108
|
addressable
|
109
|
+
matrix
|
109
110
|
mini_mime (>= 0.1.3)
|
110
111
|
nokogiri (~> 1.8)
|
111
112
|
rack (>= 1.6.0)
|
112
113
|
rack-test (>= 0.6.3)
|
113
|
-
regexp_parser (
|
114
|
+
regexp_parser (>= 1.5, < 3.0)
|
114
115
|
xpath (~> 3.2)
|
115
116
|
childprocess (3.0.0)
|
116
117
|
chromedriver-helper (2.1.1)
|
117
118
|
archive-zip (~> 0.10)
|
118
119
|
nokogiri (~> 1.8)
|
119
|
-
coderay (1.1.
|
120
|
+
coderay (1.1.3)
|
120
121
|
concurrent-ruby (1.1.5)
|
121
122
|
crass (1.0.6)
|
122
|
-
cucumber (3.
|
123
|
+
cucumber (3.2.0)
|
123
124
|
builder (>= 2.1.2)
|
124
125
|
cucumber-core (~> 3.2.0)
|
125
126
|
cucumber-expressions (~> 6.0.1)
|
@@ -148,7 +149,7 @@ GEM
|
|
148
149
|
railties (>= 4.1.0)
|
149
150
|
responders
|
150
151
|
warden (~> 1.2.3)
|
151
|
-
diff-lcs (1.
|
152
|
+
diff-lcs (1.5.0)
|
152
153
|
erubi (1.9.0)
|
153
154
|
factory_bot (5.1.1)
|
154
155
|
activesupport (>= 4.2.0)
|
@@ -160,7 +161,7 @@ GEM
|
|
160
161
|
gherkin (5.1.0)
|
161
162
|
globalid (0.4.2)
|
162
163
|
activesupport (>= 4.2.0)
|
163
|
-
guard (2.
|
164
|
+
guard (2.17.0)
|
164
165
|
formatador (>= 0.2.4)
|
165
166
|
listen (>= 2.7, < 4.0)
|
166
167
|
lumberjack (>= 1.0.12, < 2.0)
|
@@ -169,8 +170,8 @@ GEM
|
|
169
170
|
pry (>= 0.9.12)
|
170
171
|
shellany (~> 0.0)
|
171
172
|
thor (>= 0.18.1)
|
172
|
-
guard-bundler (
|
173
|
-
bundler (>= 1
|
173
|
+
guard-bundler (3.0.0)
|
174
|
+
bundler (>= 2.1, < 3)
|
174
175
|
guard (~> 2.2)
|
175
176
|
guard-compat (~> 1.1)
|
176
177
|
guard-compat (1.2.1)
|
@@ -184,29 +185,30 @@ GEM
|
|
184
185
|
rspec (>= 2.99.0, < 4.0)
|
185
186
|
i18n (1.7.0)
|
186
187
|
concurrent-ruby (~> 1.0)
|
187
|
-
io-like (0.3.
|
188
|
+
io-like (0.3.1)
|
188
189
|
launchy (2.4.3)
|
189
190
|
addressable (~> 2.3)
|
190
|
-
listen (3.
|
191
|
+
listen (3.7.1)
|
191
192
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
192
193
|
rb-inotify (~> 0.9, >= 0.9.10)
|
193
|
-
loofah (2.
|
194
|
+
loofah (2.19.1)
|
194
195
|
crass (~> 1.0.2)
|
195
196
|
nokogiri (>= 1.5.9)
|
196
197
|
lumberjack (1.0.13)
|
197
198
|
mail (2.7.1)
|
198
199
|
mini_mime (>= 0.1.1)
|
200
|
+
matrix (0.4.2)
|
199
201
|
method_source (0.9.2)
|
200
202
|
mime-types (3.3)
|
201
203
|
mime-types-data (~> 3.2015)
|
202
204
|
mime-types-data (3.2019.1009)
|
203
205
|
mini_mime (1.0.2)
|
204
206
|
mini_portile2 (2.8.0)
|
205
|
-
minitest (5.
|
207
|
+
minitest (5.16.3)
|
206
208
|
multi_json (1.14.1)
|
207
209
|
multi_test (0.1.2)
|
208
210
|
nenv (0.3.0)
|
209
|
-
nokogiri (1.13.
|
211
|
+
nokogiri (1.13.10)
|
210
212
|
mini_portile2 (~> 2.8.0)
|
211
213
|
racc (~> 1.4)
|
212
214
|
notiffany (0.1.3)
|
@@ -217,19 +219,19 @@ GEM
|
|
217
219
|
pry (0.12.2)
|
218
220
|
coderay (~> 1.1.0)
|
219
221
|
method_source (~> 0.9.0)
|
220
|
-
pry-byebug (3.
|
222
|
+
pry-byebug (3.8.0)
|
221
223
|
byebug (~> 11.0)
|
222
224
|
pry (~> 0.10)
|
223
225
|
public_suffix (4.0.6)
|
224
|
-
racc (1.6.
|
226
|
+
racc (1.6.1)
|
225
227
|
rack (2.2.3.1)
|
226
|
-
rack-test (
|
227
|
-
rack (>= 1.
|
228
|
+
rack-test (2.0.2)
|
229
|
+
rack (>= 1.3)
|
228
230
|
rails-dom-testing (2.0.3)
|
229
231
|
activesupport (>= 4.2.0)
|
230
232
|
nokogiri (>= 1.6)
|
231
|
-
rails-html-sanitizer (1.4.
|
232
|
-
loofah (~> 2.
|
233
|
+
rails-html-sanitizer (1.4.4)
|
234
|
+
loofah (~> 2.19, >= 2.19.1)
|
233
235
|
railties (6.0.0)
|
234
236
|
actionpack (= 6.0.0)
|
235
237
|
activesupport (= 6.0.0)
|
@@ -240,7 +242,7 @@ GEM
|
|
240
242
|
rb-fsevent (0.10.3)
|
241
243
|
rb-inotify (0.10.0)
|
242
244
|
ffi (~> 1.0)
|
243
|
-
regexp_parser (
|
245
|
+
regexp_parser (2.6.0)
|
244
246
|
responders (3.0.1)
|
245
247
|
actionpack (>= 5.0)
|
246
248
|
railties (>= 5.0)
|
@@ -255,7 +257,8 @@ GEM
|
|
255
257
|
shoulda-context (1.2.2)
|
256
258
|
shoulda-matchers (3.1.3)
|
257
259
|
activesupport (>= 4.0.0)
|
258
|
-
sqlite3 (1.
|
260
|
+
sqlite3 (1.5.3)
|
261
|
+
mini_portile2 (~> 2.8.0)
|
259
262
|
test-unit (3.3.4)
|
260
263
|
power_assert
|
261
264
|
thor (0.20.3)
|
@@ -266,7 +269,7 @@ GEM
|
|
266
269
|
rack (>= 2.0.9)
|
267
270
|
xpath (3.2.0)
|
268
271
|
nokogiri (~> 1.8)
|
269
|
-
zeitwerk (2.
|
272
|
+
zeitwerk (2.6.1)
|
270
273
|
|
271
274
|
PLATFORMS
|
272
275
|
ruby
|
data/README.md
CHANGED
@@ -145,7 +145,7 @@ For example, if you use FriendlyId:
|
|
145
145
|
class Admin::MasqueradesController < Devise::MasqueradesController
|
146
146
|
protected
|
147
147
|
|
148
|
-
def
|
148
|
+
def find_masqueradable_resource
|
149
149
|
masqueraded_resource_class.friendly.find(params[:id])
|
150
150
|
end
|
151
151
|
end
|
@@ -80,7 +80,7 @@ class Devise::MasqueradesController < DeviseController
|
|
80
80
|
if Devise.masquerade_storage_method_session?
|
81
81
|
resource_id = session[skey]
|
82
82
|
|
83
|
-
|
83
|
+
masquerading_resource_class.find(resource_id)
|
84
84
|
else
|
85
85
|
data = Rails.cache.read(skey)
|
86
86
|
|
@@ -148,7 +148,7 @@ class Devise::MasqueradesController < DeviseController
|
|
148
148
|
resource_obj = send("current_#{masquerading_resource_name}")
|
149
149
|
|
150
150
|
if Devise.masquerade_storage_method_session?
|
151
|
-
session[skey] = resource_obj.
|
151
|
+
session[skey] = resource_obj.id
|
152
152
|
else
|
153
153
|
# skip sharing owner id via session
|
154
154
|
Rails.cache.write(skey, resource_obj.to_sgid(for: 'masquerade'))
|
@@ -172,7 +172,7 @@ class Devise::MasqueradesController < DeviseController
|
|
172
172
|
end
|
173
173
|
|
174
174
|
def session_key(masqueradable_resource, guid)
|
175
|
-
"devise_masquerade_#{masqueraded_resource_name}_#{masqueradable_resource.
|
175
|
+
"devise_masquerade_#{masqueraded_resource_name}_#{masqueradable_resource.id}_#{guid}".to_sym
|
176
176
|
end
|
177
177
|
|
178
178
|
def masquerading_current_user
|
@@ -67,7 +67,7 @@ module DeviseMasquerade
|
|
67
67
|
private
|
68
68
|
|
69
69
|
def #{name}_helper_session_key
|
70
|
-
["devise_masquerade_#{name}", current_#{name}.
|
70
|
+
["devise_masquerade_#{name}", current_#{name}.id, #{name}_helper_masquerading_resource_guid].join("_")
|
71
71
|
end
|
72
72
|
|
73
73
|
def #{name}_helper_masquerading_resource_guid
|
@@ -14,7 +14,7 @@ describe Devise::MasqueradesController, type: :controller do
|
|
14
14
|
let(:mask) { create(:student) }
|
15
15
|
|
16
16
|
before do
|
17
|
-
get :show, params: { id: mask.
|
17
|
+
get :show, params: { id: mask.id, masqueraded_resource_class: mask.class.name, masquerade: mask.masquerade_key }
|
18
18
|
end
|
19
19
|
|
20
20
|
it { expect(cache_read(mask)).to be }
|
@@ -33,7 +33,7 @@ describe Devise::MasqueradesController, type: :controller do
|
|
33
33
|
let(:mask) { create(:user) }
|
34
34
|
|
35
35
|
before do
|
36
|
-
get :show, params: { id: mask.
|
36
|
+
get :show, params: { id: mask.id, masquerade: mask.masquerade_key }
|
37
37
|
end
|
38
38
|
|
39
39
|
it { expect(cache_read(mask)).to be }
|
@@ -61,7 +61,7 @@ describe Devise::MasqueradesController, type: :controller do
|
|
61
61
|
context 'with http referrer' do
|
62
62
|
before do
|
63
63
|
@request.env['HTTP_REFERER'] = 'previous_location'
|
64
|
-
get :show, params: { id: mask.
|
64
|
+
get :show, params: { id: mask.id, masquerade: mask.masquerade_key }
|
65
65
|
end # before
|
66
66
|
|
67
67
|
it { should redirect_to('previous_location') }
|
@@ -73,7 +73,7 @@ describe Devise::MasqueradesController, type: :controller do
|
|
73
73
|
receive(:after_masquerade_path_for).and_return("/dashboard?color=red"))
|
74
74
|
end
|
75
75
|
|
76
|
-
before { get :show, params: { id: mask.
|
76
|
+
before { get :show, params: { id: mask.id, masquerade: mask.masquerade_key } }
|
77
77
|
|
78
78
|
it { should redirect_to("/dashboard?color=red") }
|
79
79
|
end # context
|
@@ -81,7 +81,7 @@ describe Devise::MasqueradesController, type: :controller do
|
|
81
81
|
|
82
82
|
context 'and back' do
|
83
83
|
before do
|
84
|
-
get :show, params: { id: mask.
|
84
|
+
get :show, params: { id: mask.id, masquerade: mask.masquerade_key }
|
85
85
|
|
86
86
|
get :back
|
87
87
|
end
|
@@ -91,7 +91,7 @@ describe Devise::MasqueradesController, type: :controller do
|
|
91
91
|
|
92
92
|
context 'and back fallback if http_referer not present' do
|
93
93
|
before do
|
94
|
-
get :show, params: { id: mask.
|
94
|
+
get :show, params: { id: mask.id, masquerade: mask.masquerade_key }
|
95
95
|
|
96
96
|
@request.env['HTTP_REFERER'] = 'previous_location'
|
97
97
|
get :back
|
@@ -123,6 +123,6 @@ describe Devise::MasqueradesController, type: :controller do
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def cache_key(user)
|
126
|
-
"devise_masquerade_#{mask.class.name.downcase}_#{mask.
|
126
|
+
"devise_masquerade_#{mask.class.name.downcase}_#{mask.id}_#{guid}"
|
127
127
|
end
|
128
128
|
end
|
@@ -16,7 +16,7 @@ describe MasqueradesTestsController, type: :controller do
|
|
16
16
|
|
17
17
|
let(:mask) { create(:user) }
|
18
18
|
|
19
|
-
before { get :show, params: { id: mask.
|
19
|
+
before { get :show, params: { id: mask.id, masquerade: mask.masquerade_key } }
|
20
20
|
|
21
21
|
it { expect(response.status).to eq(403) }
|
22
22
|
it { expect(cache_read(mask)).not_to be }
|
@@ -34,7 +34,7 @@ describe MasqueradesTestsController, type: :controller do
|
|
34
34
|
let(:mask) { create(:user) }
|
35
35
|
|
36
36
|
before do
|
37
|
-
get :show, params: { id: mask.
|
37
|
+
get :show, params: { id: mask.id, masquerade: mask.masquerade_key }
|
38
38
|
end
|
39
39
|
|
40
40
|
it { expect(response.status).to eq(302) }
|
@@ -52,6 +52,6 @@ describe MasqueradesTestsController, type: :controller do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def cache_key(user)
|
55
|
-
"devise_masquerade_#{mask.class.name.downcase}_#{mask.
|
55
|
+
"devise_masquerade_#{mask.class.name.downcase}_#{mask.id}_#{guid}"
|
56
56
|
end
|
57
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_masquerade
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandr Korsak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|