warden-github-rails 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -18
- data/CHANGELOG.md +5 -0
- data/Gemfile +4 -4
- data/README.md +41 -20
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/warden/github/rails/controller_helpers.rb +1 -1
- data/lib/warden/github/rails/railtie.rb +2 -2
- data/lib/warden/github/rails/routes.rb +5 -5
- data/lib/warden/github/rails/test_helpers/mock_user.rb +1 -1
- data/lib/warden/github/rails/test_helpers.rb +1 -1
- data/spec/integration/controller_helpers_spec.rb +3 -3
- data/spec/integration/membership_spec.rb +10 -10
- data/spec/integration/scope_spec.rb +6 -6
- data/spec/rails_app/app/controllers/scoped_controller.rb +5 -5
- data/spec/rails_app/app/controllers/unscoped_controller.rb +5 -5
- data/spec/rails_app/config/initializers/session_store.rb +1 -1
- data/spec/rails_app/config/initializers/warden_github_rails.rb +7 -7
- data/spec/rails_app/config/initializers/wrap_parameters.rb +1 -1
- data/spec/rails_app/config/routes.rb +10 -10
- data/spec/unit/mock_user_spec.rb +1 -1
- data/spec/unit/test_helpers_spec.rb +1 -1
- data/warden-github-rails.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94c4bcff3c0978874ae4233194457aa095b6ec98
|
4
|
+
data.tar.gz: 952a958502aef15b84ca89c4912d7577ea4ab0f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df68ab5d8e005762758a1c42ebf734a5dd477dc3b9e553658bdad6518af55b9d5ec924b9b205a924ec0f5e95b5f236bddbb2d8e4473a7db2623531a20fa58e02
|
7
|
+
data.tar.gz: a5ca3a4d19fb32f664b3ae819df6243a557f252b01b59382965507b49cb99d88be888b1c9cdf0eb8d931205a541f480c2b337441f8ba7303d16c4639eafc4c2e
|
data/.travis.yml
CHANGED
@@ -1,39 +1,23 @@
|
|
1
1
|
language: ruby
|
2
2
|
script: "bundle exec rspec"
|
3
3
|
rvm:
|
4
|
-
- 1.8.7
|
5
4
|
- 1.9.2
|
6
5
|
- 1.9.3
|
7
6
|
- 2.0.0
|
8
7
|
- ruby-head
|
9
|
-
- jruby-18mode # JRuby in 1.8 mode
|
10
8
|
- jruby-19mode # JRuby in 1.9 mode
|
11
|
-
- rbx-18mode
|
12
9
|
- rbx-19mode
|
13
10
|
env:
|
14
11
|
- "RAILS_VERSION=3.1.0"
|
15
12
|
- "RAILS_VERSION=3.2.0"
|
16
|
-
- "RAILS_VERSION=4.0.0
|
13
|
+
- "RAILS_VERSION=4.0.0"
|
17
14
|
- "RAILS_VERSION=master"
|
18
15
|
matrix:
|
19
16
|
allow_failures:
|
20
17
|
- env: "RAILS_VERSION=master"
|
21
18
|
- rvm: ruby-head
|
22
19
|
exclude:
|
23
|
-
- rvm: 1.8.7
|
24
|
-
env: "RAILS_VERSION=4.0.0.pre"
|
25
20
|
- rvm: 1.9.2
|
26
|
-
env: "RAILS_VERSION=4.0.0.pre"
|
27
|
-
- rvm: jruby-18mode
|
28
|
-
env: "RAILS_VERSION=4.0.0.pre"
|
29
|
-
- rvm: rbx-18mode
|
30
|
-
env: "RAILS_VERSION=4.0.0.pre"
|
31
|
-
- rvm: 1.8.7
|
32
21
|
env: "RAILS_VERSION=master"
|
33
22
|
- rvm: 1.9.2
|
34
|
-
env: "RAILS_VERSION=
|
35
|
-
- rvm: jruby-18mode
|
36
|
-
env: "RAILS_VERSION=master"
|
37
|
-
- rvm: rbx-18mode
|
38
|
-
env: "RAILS_VERSION=master"
|
39
|
-
|
23
|
+
env: "RAILS_VERSION=4.0.0"
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -3,14 +3,14 @@ source 'https://rubygems.org'
|
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
if ENV['EDGE']
|
6
|
-
gem 'warden-github', :
|
6
|
+
gem 'warden-github', github: 'atmos/warden-github'
|
7
7
|
end
|
8
8
|
|
9
9
|
rails_version = ENV['RAILS_VERSION']
|
10
10
|
|
11
11
|
rails_opts = case rails_version
|
12
12
|
when 'master'
|
13
|
-
{ :
|
13
|
+
{ github: 'rails/rails' }
|
14
14
|
when nil
|
15
15
|
{}
|
16
16
|
else
|
@@ -21,7 +21,7 @@ gem "rails", rails_opts
|
|
21
21
|
|
22
22
|
group :development do
|
23
23
|
unless ENV['CI']
|
24
|
-
gem 'debugger', :
|
25
|
-
gem 'ruby-debug', :
|
24
|
+
gem 'debugger', platforms: :ruby_19, require: false
|
25
|
+
gem 'ruby-debug', platforms: :ruby_18, require: false
|
26
26
|
end
|
27
27
|
end
|
data/README.md
CHANGED
@@ -22,12 +22,12 @@ They allow you to restrict access to members of your organization or a certain t
|
|
22
22
|
This is how your rails `routes.rb` could look like:
|
23
23
|
|
24
24
|
```ruby
|
25
|
-
constraints(:
|
26
|
-
github_authenticate(:
|
25
|
+
constraints(subdomain: 'admin') do
|
26
|
+
github_authenticate(org: 'my_company_inc') do
|
27
27
|
resources :users
|
28
28
|
resources :projects
|
29
29
|
|
30
|
-
github_authenticated(:
|
30
|
+
github_authenticated(team: 'sysadmins') do
|
31
31
|
resource :infrastructure
|
32
32
|
end
|
33
33
|
end
|
@@ -43,14 +43,14 @@ class UsersController < ApplicationController
|
|
43
43
|
|
44
44
|
def new
|
45
45
|
github_authenticate! # Performs OAuth flow when not logged in.
|
46
|
-
@user = User.new(:
|
46
|
+
@user = User.new(name: github_user.name, email: github_user.email)
|
47
47
|
end
|
48
48
|
|
49
49
|
def create
|
50
|
-
attrs = params.require(:user).permit(:name, :email).merge(:
|
50
|
+
attrs = params.require(:user).permit(:name, :email).merge(github_id: github_user.id)
|
51
51
|
@user = User.create(attrs)
|
52
52
|
|
53
|
-
if @user
|
53
|
+
if @user.persisted?
|
54
54
|
redirect_to :show
|
55
55
|
else
|
56
56
|
render :new
|
@@ -61,12 +61,30 @@ class UsersController < ApplicationController
|
|
61
61
|
end
|
62
62
|
```
|
63
63
|
|
64
|
+
## Example App
|
65
|
+
|
66
|
+
This repository includes an example app in [example/](example/).
|
67
|
+
To play with it, follow these steps:
|
68
|
+
|
69
|
+
1. [Create an OAuth application in your GitHub settings](https://github.com/settings/applications/new).
|
70
|
+
Set the callback URL to `http://localhost:3000/`
|
71
|
+
|
72
|
+
2. Check out this repo and run:
|
73
|
+
|
74
|
+
```
|
75
|
+
$ bundle
|
76
|
+
$ cd example
|
77
|
+
$ GITHUB_CLIENT_ID=your_id_from_step1 GITHUB_CLIENT_SECRET=your_secret_from_step1 bundle exec rails s
|
78
|
+
```
|
79
|
+
|
80
|
+
3. Point your browser to [http://localhost:3000/](http://localhost:3000/) and enjoy!
|
81
|
+
|
64
82
|
## Installation
|
65
83
|
|
66
84
|
To use this gem, add it to your `Gemfile`:
|
67
85
|
|
68
86
|
```ruby
|
69
|
-
gem 'warden-github-rails', '~> 1.0'
|
87
|
+
gem 'warden-github-rails', '~> 1.1.0'
|
70
88
|
```
|
71
89
|
|
72
90
|
If you're using devise, make sure to use version 2.2.4 or newer.
|
@@ -88,14 +106,14 @@ Here's how such a config might look like:
|
|
88
106
|
|
89
107
|
```ruby
|
90
108
|
Warden::GitHub::Rails.setup do |config|
|
91
|
-
config.add_scope :user, :
|
92
|
-
:
|
93
|
-
:
|
109
|
+
config.add_scope :user, client_id: 'foo',
|
110
|
+
client_secret: 'bar',
|
111
|
+
scope: 'user'
|
94
112
|
|
95
|
-
config.add_scope :admin, :
|
96
|
-
:
|
97
|
-
:
|
98
|
-
:
|
113
|
+
config.add_scope :admin, client_id: 'abc',
|
114
|
+
client_secret: 'xyz',
|
115
|
+
redirect_uri: '/admin/login/callback',
|
116
|
+
scope: 'repo'
|
99
117
|
|
100
118
|
config.default_scope = :admin
|
101
119
|
|
@@ -129,17 +147,17 @@ github_unauthenticated do
|
|
129
147
|
end
|
130
148
|
|
131
149
|
# Only matches when member of the organization. Initiates login if not logged in.
|
132
|
-
github_authenticate(:
|
150
|
+
github_authenticate(org: 'my_company') do
|
133
151
|
resource :admin
|
134
152
|
end
|
135
153
|
|
136
154
|
# Only matches when member of the team. Does not initiate login if not logged in.
|
137
|
-
github_authenticated(:
|
155
|
+
github_authenticated(team: 'markting') do
|
138
156
|
get '/dashboard' => 'dashboard#show'
|
139
157
|
end
|
140
158
|
|
141
159
|
# Using dynamic membership values:
|
142
|
-
github_authenticate(:
|
160
|
+
github_authenticate(org: lambda { |req| req.params[:id] }) do
|
143
161
|
get '/orgs/:id' => 'orgs#show'
|
144
162
|
end
|
145
163
|
```
|
@@ -162,7 +180,7 @@ class SomeController < ActionController::Base
|
|
162
180
|
|
163
181
|
def settings
|
164
182
|
github_authenticate!
|
165
|
-
@settings = UserSettings.
|
183
|
+
@settings = UserSettings.find_by(github_user_id: github_user.id)
|
166
184
|
end
|
167
185
|
|
168
186
|
def finish_wizard
|
@@ -177,7 +195,10 @@ end
|
|
177
195
|
|
178
196
|
### Communicating with the GitHub API
|
179
197
|
|
180
|
-
Once a user is logged in, you'll have access to it in the controller using `github_user`.
|
198
|
+
Once a user is logged in, you'll have access to it in the controller using `github_user`.
|
199
|
+
It is an instance of `Warden::GitHub::User` which is defined in the [warden-github](https://github.com/atmos/warden-github/blob/master/lib/warden/github/user.rb) gem.
|
200
|
+
The instance has several methods to access user information such as `#name`, `#id`, `#email`, etc.
|
201
|
+
It also features a method `#api` which returns a preconfigured [Octokit](https://github.com/octokit/octokit.rb) client for that user.
|
181
202
|
|
182
203
|
### Test Helpers
|
183
204
|
|
@@ -239,7 +260,7 @@ This functionality is used in this gem in order to setup the github strategy for
|
|
239
260
|
|
240
261
|
- [warden-github](https://github.com/atmos/warden-github)
|
241
262
|
- [warden](https://github.com/hassox/warden)
|
242
|
-
- [octokit](https://github.com/
|
263
|
+
- [octokit](https://github.com/octokit/octokit.rb)
|
243
264
|
|
244
265
|
### Maintainers
|
245
266
|
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
@@ -9,7 +9,7 @@ module Warden
|
|
9
9
|
# Initiates the OAuth flow if not already authenticated for the
|
10
10
|
# specified scope.
|
11
11
|
def github_authenticate!(scope=Rails.default_scope)
|
12
|
-
request.env['warden'].authenticate!(:
|
12
|
+
request.env['warden'].authenticate!(scope: scope)
|
13
13
|
end
|
14
14
|
|
15
15
|
# Logs out a user if currently logged in for the specified scope.
|
@@ -25,8 +25,8 @@ module Warden
|
|
25
25
|
|
26
26
|
def setup_scopes(config)
|
27
27
|
Rails.scopes.each do |scope, scope_config|
|
28
|
-
config.scope_defaults scope, :
|
29
|
-
:
|
28
|
+
config.scope_defaults scope, strategies: [:github],
|
29
|
+
config: scope_config
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -6,10 +6,10 @@ module Warden
|
|
6
6
|
# authenticated, it initiates the OAuth flow.
|
7
7
|
#
|
8
8
|
# Team and organization memberships can be checked by specifying a hash
|
9
|
-
# such as
|
9
|
+
# such as `team: 'foobar'` or `org: 'my_company'`.
|
10
10
|
def github_authenticate(scope=nil, options={}, &routes_block)
|
11
11
|
github_constraint(scope, options, routes_block) do |warden, scope|
|
12
|
-
warden.authenticate!(:
|
12
|
+
warden.authenticate!(scope: scope)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -17,10 +17,10 @@ module Warden
|
|
17
17
|
# not authenticated, it does not initiate the OAuth flow.
|
18
18
|
#
|
19
19
|
# Team and organization memberships can be checked by specifying a hash
|
20
|
-
# such as
|
20
|
+
# such as `team: 'foobar'` or `org: 'my_company'`.
|
21
21
|
def github_authenticated(scope=nil, options={}, &routes_block)
|
22
22
|
github_constraint(scope, options, routes_block) do |warden, scope|
|
23
|
-
warden.authenticated?(:
|
23
|
+
warden.authenticated?(scope: scope)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -30,7 +30,7 @@ module Warden
|
|
30
30
|
# limited usage.
|
31
31
|
def github_unauthenticated(scope=nil, options={}, &routes_block)
|
32
32
|
github_constraint(scope, options, routes_block) do |warden, scope|
|
33
|
-
not warden.authenticated?(:
|
33
|
+
not warden.authenticated?(scope: scope)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -2,8 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe 'controller helpers' do
|
4
4
|
{
|
5
|
-
:
|
6
|
-
:
|
5
|
+
scoped: :admin,
|
6
|
+
unscoped: Warden::GitHub::Rails.default_scope
|
7
7
|
}.each do |type, scope|
|
8
8
|
context "when using #{type}" do
|
9
9
|
describe '#github_authenticate!' do
|
@@ -86,7 +86,7 @@ describe 'controller helpers' do
|
|
86
86
|
context 'when logged in' do
|
87
87
|
it "returns the user's session" do
|
88
88
|
github_login(scope)
|
89
|
-
expect(request.body).to eq({ :
|
89
|
+
expect(request.body).to eq({ foo: :bar }.to_s)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
@@ -13,7 +13,7 @@ describe 'request to a protected resource' do
|
|
13
13
|
context 'and team member' do
|
14
14
|
before do
|
15
15
|
user = github_login
|
16
|
-
user.stub_membership(:
|
16
|
+
user.stub_membership(team: 123)
|
17
17
|
end
|
18
18
|
|
19
19
|
it { should be_ok }
|
@@ -37,7 +37,7 @@ describe 'request to a protected resource' do
|
|
37
37
|
context 'and team member' do
|
38
38
|
before do
|
39
39
|
user = github_login
|
40
|
-
user.stub_membership(:
|
40
|
+
user.stub_membership(team: 456)
|
41
41
|
end
|
42
42
|
|
43
43
|
it { should be_ok }
|
@@ -57,7 +57,7 @@ describe 'request to a protected resource' do
|
|
57
57
|
context 'and team member' do
|
58
58
|
before do
|
59
59
|
user = github_login
|
60
|
-
user.stub_membership(:
|
60
|
+
user.stub_membership(team: 123)
|
61
61
|
end
|
62
62
|
|
63
63
|
it { should be_ok }
|
@@ -72,7 +72,7 @@ describe 'request to a protected resource' do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
context 'that requires an organization membership' do
|
75
|
-
{ :
|
75
|
+
{ org: :foobar_inc, organization: 'some_org' }.each do |key, value|
|
76
76
|
context "which is specified as #{key}" do
|
77
77
|
subject { get "/#{key}/protected" }
|
78
78
|
|
@@ -84,7 +84,7 @@ describe 'request to a protected resource' do
|
|
84
84
|
context 'and organization member' do
|
85
85
|
before do
|
86
86
|
user = github_login
|
87
|
-
user.stub_membership(:
|
87
|
+
user.stub_membership(org: value)
|
88
88
|
end
|
89
89
|
|
90
90
|
it { should be_ok }
|
@@ -105,7 +105,7 @@ describe 'request to a protected resource' do
|
|
105
105
|
context 'and organization member' do
|
106
106
|
before do
|
107
107
|
user = github_login
|
108
|
-
user.stub_membership(:
|
108
|
+
user.stub_membership(org: 'some_org')
|
109
109
|
end
|
110
110
|
|
111
111
|
it { should be_ok }
|
@@ -128,7 +128,7 @@ describe 'request to a resource that only exists when logged in' do
|
|
128
128
|
context 'when team member' do
|
129
129
|
before do
|
130
130
|
user = github_login
|
131
|
-
user.stub_membership(:
|
131
|
+
user.stub_membership(team: 123)
|
132
132
|
end
|
133
133
|
|
134
134
|
it { should be_ok }
|
@@ -146,7 +146,7 @@ describe 'request to a resource that only exists when logged in' do
|
|
146
146
|
context 'when team member' do
|
147
147
|
before do
|
148
148
|
user = github_login
|
149
|
-
user.stub_membership(:
|
149
|
+
user.stub_membership(team: 456)
|
150
150
|
end
|
151
151
|
|
152
152
|
it { should be_ok }
|
@@ -160,14 +160,14 @@ describe 'request to a resource that only exists when logged in' do
|
|
160
160
|
end
|
161
161
|
|
162
162
|
context 'that requires an organization membership' do
|
163
|
-
{ :
|
163
|
+
{ org: :foobar_inc, organization: 'some_org' }.each do |key, value|
|
164
164
|
context "which is specified as #{key}" do
|
165
165
|
subject { get "/#{key}/conditional" }
|
166
166
|
|
167
167
|
context 'when organization member' do
|
168
168
|
before do
|
169
169
|
user = github_login
|
170
|
-
user.stub_membership(:
|
170
|
+
user.stub_membership(org: value)
|
171
171
|
end
|
172
172
|
|
173
173
|
it { should be_ok }
|
@@ -16,18 +16,18 @@ describe 'request to custom configured scope' do
|
|
16
16
|
context 'user' do
|
17
17
|
it 'passes the correct configs to the oauth flow' do
|
18
18
|
test_redirect('/protected',
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
19
|
+
client_id: 'foo',
|
20
|
+
redirect_uri: /\/protected$/,
|
21
|
+
scope: 'user')
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
context 'admin' do
|
26
26
|
it 'passes the correct configs to the oauth flow' do
|
27
27
|
test_redirect('/admin/protected',
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
28
|
+
client_id: 'abc',
|
29
|
+
redirect_uri: /\/admin\/login\/callback$/,
|
30
|
+
scope: 'repo')
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -1,21 +1,21 @@
|
|
1
1
|
class ScopedController < ActionController::Base
|
2
2
|
def authenticate
|
3
3
|
github_authenticate!(:admin)
|
4
|
-
render :
|
4
|
+
render nothing: true
|
5
5
|
end
|
6
6
|
|
7
7
|
def logout
|
8
8
|
was_logged_in = !github_user(:admin).nil?
|
9
9
|
github_logout(:admin)
|
10
|
-
render :
|
10
|
+
render text: was_logged_in
|
11
11
|
end
|
12
12
|
|
13
13
|
def authenticated
|
14
|
-
render :
|
14
|
+
render text: github_authenticated?(:admin)
|
15
15
|
end
|
16
16
|
|
17
17
|
def user
|
18
|
-
render :
|
18
|
+
render text: github_user(:admin)
|
19
19
|
end
|
20
20
|
|
21
21
|
def session
|
@@ -23,6 +23,6 @@ class ScopedController < ActionController::Base
|
|
23
23
|
session[:foo] = :bar
|
24
24
|
end
|
25
25
|
|
26
|
-
render :
|
26
|
+
render text: github_session(:admin)
|
27
27
|
end
|
28
28
|
end
|
@@ -1,21 +1,21 @@
|
|
1
1
|
class UnscopedController < ActionController::Base
|
2
2
|
def authenticate
|
3
3
|
github_authenticate!
|
4
|
-
render :
|
4
|
+
render nothing: true
|
5
5
|
end
|
6
6
|
|
7
7
|
def logout
|
8
8
|
was_logged_in = !github_user.nil?
|
9
9
|
github_logout
|
10
|
-
render :
|
10
|
+
render text: was_logged_in
|
11
11
|
end
|
12
12
|
|
13
13
|
def authenticated
|
14
|
-
render :
|
14
|
+
render text: github_authenticated?
|
15
15
|
end
|
16
16
|
|
17
17
|
def user
|
18
|
-
render :
|
18
|
+
render text: github_user
|
19
19
|
end
|
20
20
|
|
21
21
|
def session
|
@@ -23,6 +23,6 @@ class UnscopedController < ActionController::Base
|
|
23
23
|
session[:foo] = :bar
|
24
24
|
end
|
25
25
|
|
26
|
-
render :
|
26
|
+
render text: github_session
|
27
27
|
end
|
28
28
|
end
|
@@ -1 +1 @@
|
|
1
|
-
RailsApp::Application.config.session_store :cookie_store, :
|
1
|
+
RailsApp::Application.config.session_store :cookie_store, key: '_rails_app_session'
|
@@ -1,12 +1,12 @@
|
|
1
1
|
Warden::GitHub::Rails.setup do |config|
|
2
|
-
config.add_scope :user, :
|
3
|
-
:
|
4
|
-
:
|
2
|
+
config.add_scope :user, client_id: ENV['GITHUB_CLIENT_ID'] || 'foo',
|
3
|
+
client_secret: ENV['GITHUB_CLIENT_SECRET'] || 'bar',
|
4
|
+
scope: 'user'
|
5
5
|
|
6
|
-
config.add_scope :admin, :
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
6
|
+
config.add_scope :admin, client_id: ENV['GITHUB_CLIENT_ID'] || 'abc',
|
7
|
+
client_secret: ENV['GITHUB_CLIENT_SECRET'] || 'xyz',
|
8
|
+
redirect_uri: '/admin/login/callback',
|
9
|
+
scope: 'repo'
|
10
10
|
|
11
11
|
config.add_team :marketing, 456
|
12
12
|
end
|
@@ -15,23 +15,23 @@ RailsApp::Application.routes.draw do
|
|
15
15
|
github_authenticated(:admin) { get '/admin/conditional' => responses[200] }
|
16
16
|
github_unauthenticated(:admin) { get '/admin/conditional_inverse' => responses[200] }
|
17
17
|
|
18
|
-
github_authenticate(:
|
19
|
-
github_authenticated(:
|
18
|
+
github_authenticate(team: 123) { get '/team/protected' => responses[200] }
|
19
|
+
github_authenticated(team: 123) { get '/team/conditional' => responses[200] }
|
20
20
|
|
21
|
-
github_authenticate(:
|
22
|
-
github_authenticated(:
|
21
|
+
github_authenticate(team: :marketing) { get '/team_alias/protected' => responses[200] }
|
22
|
+
github_authenticated(team: :marketing) { get '/team_alias/conditional' => responses[200] }
|
23
23
|
|
24
|
-
github_authenticate(:
|
25
|
-
github_authenticated(:
|
24
|
+
github_authenticate(org: :foobar_inc) { get '/org/protected' => responses[200] }
|
25
|
+
github_authenticated(org: :foobar_inc) { get '/org/conditional' => responses[200] }
|
26
26
|
|
27
|
-
github_authenticate(:
|
28
|
-
github_authenticated(:
|
27
|
+
github_authenticate(organization: 'some_org') { get '/organization/protected' => responses[200] }
|
28
|
+
github_authenticated(organization: 'some_org') { get '/organization/conditional' => responses[200] }
|
29
29
|
|
30
|
-
github_authenticated(:
|
30
|
+
github_authenticated(org: lambda { |req| req.params[:id] }) do
|
31
31
|
get '/dynamic_org/:id' => responses[200]
|
32
32
|
end
|
33
33
|
|
34
|
-
github_authenticated(:
|
34
|
+
github_authenticated(team: lambda { |req| req.params[:id] }) do
|
35
35
|
get '/dynamic_team/:id' => responses[200]
|
36
36
|
end
|
37
37
|
|
data/spec/unit/mock_user_spec.rb
CHANGED
@@ -11,7 +11,7 @@ describe Warden::GitHub::Rails::TestHelpers::MockUser do
|
|
11
11
|
expect(user).not_to be_team_member(456)
|
12
12
|
expect(user).not_to be_organization_member('foobar')
|
13
13
|
|
14
|
-
user.stub_membership(:
|
14
|
+
user.stub_membership(org: 'foobar', team: [123, 456])
|
15
15
|
|
16
16
|
expect(user).to be_team_member(123)
|
17
17
|
expect(user).to be_team_member(456)
|
@@ -4,7 +4,7 @@ describe Warden::GitHub::Rails::TestHelpers do
|
|
4
4
|
describe '#github_login' do
|
5
5
|
context 'when no scope is specified' do
|
6
6
|
it 'uses the default scope from config to login' do
|
7
|
-
Warden::GitHub::Rails.stub(:
|
7
|
+
Warden::GitHub::Rails.stub(default_scope: :foobar)
|
8
8
|
should_receive(:login_as).with do |_, opts|
|
9
9
|
expect(opts.fetch(:scope)).to eq(:foobar)
|
10
10
|
end
|
data/warden-github-rails.gemspec
CHANGED
@@ -20,6 +20,6 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.add_development_dependency 'rack-test', '~> 0.6'
|
21
21
|
gem.add_development_dependency 'addressable', '~> 2.3'
|
22
22
|
|
23
|
-
gem.add_dependency 'warden-github', '~>
|
23
|
+
gem.add_dependency 'warden-github', '~> 1.0'
|
24
24
|
gem.add_dependency 'railties', '>= 3.1'
|
25
25
|
end
|
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.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philipe Fatio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: '1.0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: '1.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: railties
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|