warden-github-rails 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/warden/github/rails/railtie.rb +9 -2
- data/lib/warden/github/rails/test_helpers/mock_user.rb +2 -1
- data/spec/integration/controller_helpers_spec.rb +2 -2
- data/spec/rails_app/app/controllers/scoped_controller.rb +7 -7
- data/spec/rails_app/app/controllers/unscoped_controller.rb +7 -7
- data/spec/rails_app/config/environments/production.rb +0 -1
- data/spec/rails_app/config/environments/test.rb +0 -2
- data/spec/rails_app/config/initializers/cookies_serializer.rb +1 -0
- data/spec/rails_app/config/secrets.yml +4 -0
- data/spec/unit/mock_user_spec.rb +6 -2
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f3cc06e90da76617d5fd6e220ebba3827b86c97
|
4
|
+
data.tar.gz: eb0ee4af0658eb0cf9b5a5e7e1b7a8dd200284e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c2ce60318b2cb2b9e6c5b1f47609d85fd364809fb71831aaf0a2ed2c746f1c387f6f00d0b2025df8a004353585c471b24fe8d6b6a7b9a0141a4f2a8728e88b1
|
7
|
+
data.tar.gz: beaa4a6322bc4a4ac0ebe41dac94fe459c37f55c007fee66decf4faa2a02fe585711126af781fe4cde136c7128aae34239422bdefbbccbafbc145d03db6615f4
|
data/.travis.yml
CHANGED
@@ -11,11 +11,12 @@ env:
|
|
11
11
|
global:
|
12
12
|
- JRUBY_OPTS="--2.0"
|
13
13
|
matrix:
|
14
|
-
- RAILS_VERSION=3
|
15
14
|
- RAILS_VERSION=4
|
15
|
+
- RAILS_VERSION=5.beta
|
16
16
|
- RAILS_VERSION=master
|
17
17
|
matrix:
|
18
18
|
fast_finish: true
|
19
19
|
allow_failures:
|
20
|
+
- env: RAILS_VERSION=5.beta
|
20
21
|
- env: RAILS_VERSION=master
|
21
22
|
- rvm: ruby-head
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.3
|
@@ -2,6 +2,13 @@ module Warden
|
|
2
2
|
module GitHub
|
3
3
|
module Rails
|
4
4
|
class Railtie < ::Rails::Railtie
|
5
|
+
SERIALIZE_FROM_SESSION = -> ((class_name, data)) do
|
6
|
+
class_name.constantize.new.tap { |user| user.marshal_load(data) }
|
7
|
+
end
|
8
|
+
SERIALIZE_INTO_SESSION = -> (user) do
|
9
|
+
[user.class.name, user.marshal_dump]
|
10
|
+
end
|
11
|
+
|
5
12
|
initializer 'warden-github-rails.warden' do |app|
|
6
13
|
# When devise is used, it inserts a warden middlware. Multiple warden
|
7
14
|
# middlewares do not work properly. Devise allows for a block to be
|
@@ -28,8 +35,8 @@ module Warden
|
|
28
35
|
Rails.scopes.each do |scope, scope_config|
|
29
36
|
config.scope_defaults scope, strategies: [:github],
|
30
37
|
config: scope_config
|
31
|
-
config.serialize_from_session(scope
|
32
|
-
config.serialize_into_session(scope
|
38
|
+
config.serialize_from_session(scope, &SERIALIZE_FROM_SESSION)
|
39
|
+
config.serialize_into_session(scope, &SERIALIZE_INTO_SESSION)
|
33
40
|
end
|
34
41
|
end
|
35
42
|
|
@@ -79,14 +79,14 @@ describe 'controller helpers' do
|
|
79
79
|
|
80
80
|
context 'when not logged in' do
|
81
81
|
it 'returns nil' do
|
82
|
-
expect(request.body).to
|
82
|
+
expect(request.body).to eq('null')
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
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({ foo: :bar }.
|
89
|
+
expect(request.body).to eq({ foo: :bar }.to_json)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
@@ -1,28 +1,28 @@
|
|
1
1
|
class ScopedController < ActionController::Base
|
2
2
|
def authenticate
|
3
3
|
github_authenticate!(:admin)
|
4
|
-
|
4
|
+
head :ok
|
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 plain: was_logged_in
|
11
11
|
end
|
12
12
|
|
13
13
|
def authenticated
|
14
|
-
render
|
14
|
+
render plain: github_authenticated?(:admin)
|
15
15
|
end
|
16
16
|
|
17
17
|
def user
|
18
|
-
render
|
18
|
+
render plain: github_user(:admin)
|
19
19
|
end
|
20
20
|
|
21
21
|
def session
|
22
|
-
if
|
23
|
-
|
22
|
+
if github_session(:admin)
|
23
|
+
github_session(:admin)[:foo] = :bar
|
24
24
|
end
|
25
25
|
|
26
|
-
render
|
26
|
+
render json: github_session(:admin)
|
27
27
|
end
|
28
28
|
end
|
@@ -1,28 +1,28 @@
|
|
1
1
|
class UnscopedController < ActionController::Base
|
2
2
|
def authenticate
|
3
3
|
github_authenticate!
|
4
|
-
|
4
|
+
head :ok
|
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 plain: was_logged_in
|
11
11
|
end
|
12
12
|
|
13
13
|
def authenticated
|
14
|
-
render
|
14
|
+
render plain: github_authenticated?
|
15
15
|
end
|
16
16
|
|
17
17
|
def user
|
18
|
-
render
|
18
|
+
render plain: github_user
|
19
19
|
end
|
20
20
|
|
21
21
|
def session
|
22
|
-
if
|
23
|
-
|
22
|
+
if github_session
|
23
|
+
github_session[:foo] = :bar
|
24
24
|
end
|
25
25
|
|
26
|
-
render
|
26
|
+
render json: github_session
|
27
27
|
end
|
28
28
|
end
|
@@ -3,7 +3,6 @@ RailsApp::Application.configure do
|
|
3
3
|
config.cache_classes = true
|
4
4
|
config.consider_all_requests_local = false
|
5
5
|
config.action_controller.perform_caching = true
|
6
|
-
config.serve_static_assets = false
|
7
6
|
config.i18n.fallbacks = true
|
8
7
|
config.active_support.deprecation = :notify
|
9
8
|
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
RailsApp::Application.configure do
|
2
2
|
config.eager_load = true
|
3
3
|
config.cache_classes = true
|
4
|
-
config.serve_static_assets = true
|
5
|
-
config.static_cache_control = "public, max-age=3600"
|
6
4
|
config.whiny_nils = true
|
7
5
|
config.consider_all_requests_local = true
|
8
6
|
config.action_controller.perform_caching = false
|
@@ -0,0 +1 @@
|
|
1
|
+
Rails.application.config.action_dispatch.cookies_serializer = :json
|
data/spec/unit/mock_user_spec.rb
CHANGED
@@ -19,10 +19,14 @@ describe Warden::GitHub::Rails::TestHelpers::MockUser do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
it 'can be
|
22
|
+
it 'can be serialized and deserialized with JSON' do
|
23
23
|
user = described_class.new
|
24
24
|
user.stub_membership(org: ['apple', 'facebook'], team: [12, 34])
|
25
|
-
|
25
|
+
|
26
|
+
json = ActiveSupport::JSON.encode(user.marshal_dump)
|
27
|
+
marshaled_user = described_class.new.tap do |u|
|
28
|
+
u.marshal_load(ActiveSupport::JSON.decode(json))
|
29
|
+
end
|
26
30
|
|
27
31
|
expect(marshaled_user.memberships).to eq(user.memberships)
|
28
32
|
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.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philipe Fatio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -156,11 +156,13 @@ files:
|
|
156
156
|
- spec/rails_app/config/environments/development.rb
|
157
157
|
- spec/rails_app/config/environments/production.rb
|
158
158
|
- spec/rails_app/config/environments/test.rb
|
159
|
+
- spec/rails_app/config/initializers/cookies_serializer.rb
|
159
160
|
- spec/rails_app/config/initializers/secret_token.rb
|
160
161
|
- spec/rails_app/config/initializers/session_store.rb
|
161
162
|
- spec/rails_app/config/initializers/warden_github_rails.rb
|
162
163
|
- spec/rails_app/config/initializers/wrap_parameters.rb
|
163
164
|
- spec/rails_app/config/routes.rb
|
165
|
+
- spec/rails_app/config/secrets.yml
|
164
166
|
- spec/rails_app/script/rails
|
165
167
|
- spec/spec_helper.rb
|
166
168
|
- spec/unit/config_spec.rb
|
@@ -209,11 +211,13 @@ test_files:
|
|
209
211
|
- spec/rails_app/config/environments/development.rb
|
210
212
|
- spec/rails_app/config/environments/production.rb
|
211
213
|
- spec/rails_app/config/environments/test.rb
|
214
|
+
- spec/rails_app/config/initializers/cookies_serializer.rb
|
212
215
|
- spec/rails_app/config/initializers/secret_token.rb
|
213
216
|
- spec/rails_app/config/initializers/session_store.rb
|
214
217
|
- spec/rails_app/config/initializers/warden_github_rails.rb
|
215
218
|
- spec/rails_app/config/initializers/wrap_parameters.rb
|
216
219
|
- spec/rails_app/config/routes.rb
|
220
|
+
- spec/rails_app/config/secrets.yml
|
217
221
|
- spec/rails_app/script/rails
|
218
222
|
- spec/spec_helper.rb
|
219
223
|
- spec/unit/config_spec.rb
|