warden-github-rails 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +5 -0
- data/VERSION +1 -1
- data/lib/warden/github/rails/routes.rb +2 -2
- data/spec/integration/membership_spec.rb +126 -6
- data/spec/rails_app/config/initializers/warden_github_rails.rb +1 -0
- data/spec/rails_app/config/routes.rb +4 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 317b12d425b52157230b92ca9d1725fde4810b52
|
4
|
+
data.tar.gz: 491cb0453238f1823d265ac03fa52c22480db28d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb6d79bc65a7e366a59dd6eedfe5ffdbb4cec3f19b3eb89efffcc44b28321d39b3555cae9b02ab3037255a899a78ff327fc98f0ad74ade20a23c8b8aca7af159
|
7
|
+
data.tar.gz: 222c43607372b2fb9a0eb282b1642cb33c20c7ad1237a498ef642fe3d1e515b9c88b2e51cabc310a9b4699b3780345339d4a3c1f30a5430cf0aa43e4790b9ece
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -157,6 +157,11 @@ github_authenticated(team: 'markting') do
|
|
157
157
|
get '/dashboard' => 'dashboard#show'
|
158
158
|
end
|
159
159
|
|
160
|
+
# Matches if a member of any of the teams given. Does not initiate login if not logged in.
|
161
|
+
github_authenticated(team: ['markting', 'graphic-design']) do
|
162
|
+
get '/dashboard' => 'dashboard#show'
|
163
|
+
end
|
164
|
+
|
160
165
|
# Using dynamic membership values:
|
161
166
|
github_authenticate(org: lambda { |req| req.params[:id] }) do
|
162
167
|
get '/orgs/:id' => 'orgs#show'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.1
|
@@ -57,8 +57,8 @@ module Warden
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def github_enforce_options(user, options)
|
60
|
-
if (
|
61
|
-
user.team_member?(Rails.team_id(team))
|
60
|
+
if (teams = options[:team])
|
61
|
+
Array(teams).any? { |team| user.team_member?(Rails.team_id(team)) }
|
62
62
|
elsif (org = options[:org] || options[:organization])
|
63
63
|
user.organization_member?(org)
|
64
64
|
else
|
@@ -21,12 +21,78 @@ describe 'request to a protected resource' do
|
|
21
21
|
|
22
22
|
context 'and not team member' do
|
23
23
|
before { github_login }
|
24
|
-
it { is_expected.to be_not_found}
|
24
|
+
it { is_expected.to be_not_found }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'which is specified by multiple numeric team ids' do
|
30
|
+
subject { get '/multi_team/protected' }
|
31
|
+
|
32
|
+
context 'when not logged in' do
|
33
|
+
it { is_expected.to be_github_oauth_redirect }
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when logged in' do
|
37
|
+
context 'and a first team member' do
|
38
|
+
before do
|
39
|
+
user = github_login
|
40
|
+
user.stub_membership(team: 123)
|
41
|
+
end
|
42
|
+
|
43
|
+
it { is_expected.to be_ok }
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'and another team member' do
|
47
|
+
before do
|
48
|
+
user = github_login
|
49
|
+
user.stub_membership(team: 345)
|
50
|
+
end
|
51
|
+
|
52
|
+
it { is_expected.to be_ok }
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'and not team member' do
|
56
|
+
before { github_login }
|
57
|
+
it { is_expected.to be_not_found }
|
25
58
|
end
|
26
59
|
end
|
27
60
|
end
|
28
61
|
|
29
62
|
context 'which is specified by a team alias' do
|
63
|
+
subject { get '/multi_team_alias/protected' }
|
64
|
+
|
65
|
+
context 'when not logged in' do
|
66
|
+
it { is_expected.to be_github_oauth_redirect }
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when logged in' do
|
70
|
+
context 'and a first team member' do
|
71
|
+
before do
|
72
|
+
user = github_login
|
73
|
+
user.stub_membership(team: 456)
|
74
|
+
end
|
75
|
+
|
76
|
+
it { is_expected.to be_ok }
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'and another team member' do
|
80
|
+
before do
|
81
|
+
user = github_login
|
82
|
+
user.stub_membership(team: 789)
|
83
|
+
end
|
84
|
+
|
85
|
+
it { is_expected.to be_ok }
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'and not team member' do
|
89
|
+
before { github_login }
|
90
|
+
it { is_expected.to be_not_found }
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'which is specified by multiple team aliases' do
|
30
96
|
subject { get '/team_alias/protected' }
|
31
97
|
|
32
98
|
context 'when not logged in' do
|
@@ -45,7 +111,7 @@ describe 'request to a protected resource' do
|
|
45
111
|
|
46
112
|
context 'and not team member' do
|
47
113
|
before { github_login }
|
48
|
-
it { is_expected.to be_not_found}
|
114
|
+
it { is_expected.to be_not_found }
|
49
115
|
end
|
50
116
|
end
|
51
117
|
end
|
@@ -65,7 +131,7 @@ describe 'request to a protected resource' do
|
|
65
131
|
|
66
132
|
context 'and not team member' do
|
67
133
|
before { github_login }
|
68
|
-
it { is_expected.to be_not_found}
|
134
|
+
it { is_expected.to be_not_found }
|
69
135
|
end
|
70
136
|
end
|
71
137
|
end
|
@@ -113,7 +179,7 @@ describe 'request to a protected resource' do
|
|
113
179
|
|
114
180
|
context 'and not organization member' do
|
115
181
|
before { github_login }
|
116
|
-
it { is_expected.to be_not_found}
|
182
|
+
it { is_expected.to be_not_found }
|
117
183
|
end
|
118
184
|
end
|
119
185
|
end
|
@@ -136,7 +202,34 @@ describe 'request to a resource that only exists when logged in' do
|
|
136
202
|
|
137
203
|
context 'when not team member' do
|
138
204
|
before { github_login }
|
139
|
-
it { is_expected.to be_not_found}
|
205
|
+
it { is_expected.to be_not_found }
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
context 'which is specified by multiple numeric team ids' do
|
210
|
+
subject { get '/multi_team/conditional' }
|
211
|
+
|
212
|
+
context 'when a first team member' do
|
213
|
+
before do
|
214
|
+
user = github_login
|
215
|
+
user.stub_membership(team: 123)
|
216
|
+
end
|
217
|
+
|
218
|
+
it { is_expected.to be_ok }
|
219
|
+
end
|
220
|
+
|
221
|
+
context 'when another team member' do
|
222
|
+
before do
|
223
|
+
user = github_login
|
224
|
+
user.stub_membership(team: 345)
|
225
|
+
end
|
226
|
+
|
227
|
+
it { is_expected.to be_ok }
|
228
|
+
end
|
229
|
+
|
230
|
+
context 'when not team member' do
|
231
|
+
before { github_login }
|
232
|
+
it { is_expected.to be_not_found }
|
140
233
|
end
|
141
234
|
end
|
142
235
|
|
@@ -154,7 +247,34 @@ describe 'request to a resource that only exists when logged in' do
|
|
154
247
|
|
155
248
|
context 'when not team member' do
|
156
249
|
before { github_login }
|
157
|
-
it { is_expected.to be_not_found}
|
250
|
+
it { is_expected.to be_not_found }
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
context 'which is specified by multiple team aliases' do
|
255
|
+
subject { get '/multi_team_alias/conditional' }
|
256
|
+
|
257
|
+
context 'when a member of the first team' do
|
258
|
+
before do
|
259
|
+
user = github_login
|
260
|
+
user.stub_membership(team: 456)
|
261
|
+
end
|
262
|
+
|
263
|
+
it { is_expected.to be_ok }
|
264
|
+
end
|
265
|
+
|
266
|
+
context 'when a member of another team' do
|
267
|
+
before do
|
268
|
+
user = github_login
|
269
|
+
user.stub_membership(team: 789)
|
270
|
+
end
|
271
|
+
|
272
|
+
it { is_expected.to be_ok }
|
273
|
+
end
|
274
|
+
|
275
|
+
context 'when not a team member' do
|
276
|
+
before { github_login }
|
277
|
+
it { is_expected.to be_not_found }
|
158
278
|
end
|
159
279
|
end
|
160
280
|
end
|
@@ -17,9 +17,13 @@ RailsApp::Application.routes.draw do
|
|
17
17
|
|
18
18
|
github_authenticate(team: 123) { get '/team/protected' => responses[200] }
|
19
19
|
github_authenticated(team: 123) { get '/team/conditional' => responses[200] }
|
20
|
+
github_authenticate(team: [123, 345]) { get '/multi_team/protected' => responses[200] }
|
21
|
+
github_authenticated(team: [123, 345]) { get '/multi_team/conditional' => responses[200] }
|
20
22
|
|
21
23
|
github_authenticate(team: :marketing) { get '/team_alias/protected' => responses[200] }
|
22
24
|
github_authenticated(team: :marketing) { get '/team_alias/conditional' => responses[200] }
|
25
|
+
github_authenticate(team: [:marketing, :interns]) { get '/multi_team_alias/protected' => responses[200] }
|
26
|
+
github_authenticated(team: [:marketing, :interns]) { get '/multi_team_alias/conditional' => responses[200] }
|
23
27
|
|
24
28
|
github_authenticate(org: :foobar_inc) { get '/org/protected' => responses[200] }
|
25
29
|
github_authenticated(org: :foobar_inc) { get '/org/conditional' => responses[200] }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: warden-github-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philipe Fatio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -187,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
187
|
version: '0'
|
188
188
|
requirements: []
|
189
189
|
rubyforge_project:
|
190
|
-
rubygems_version: 2.4.5
|
190
|
+
rubygems_version: 2.4.5.1
|
191
191
|
signing_key:
|
192
192
|
specification_version: 4
|
193
193
|
summary: An easy drop in solution for rails to use GitHub authentication.
|