rails_sso 0.4.0 → 0.5.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/README.md +21 -2
- data/lib/rails_sso/app.rb +34 -7
- data/lib/rails_sso/engine.rb +6 -0
- data/lib/rails_sso/sso_strategy.rb +1 -1
- data/lib/rails_sso/token_mock.rb +17 -0
- data/lib/rails_sso/version.rb +1 -1
- data/lib/rails_sso.rb +1 -0
- data/test/dummy/log/test.log +43 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26aee36b2cf776c7887e8076d19fb8a06ee868f1
|
4
|
+
data.tar.gz: 1b2d7f063181a77747f38479578cfae1ef43b350
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3e99e4f290a9c6158b76b043e7ced982a7e8745914d9d550d3f72c1e3384b95416023016122a64631c37ebcf6e9aaa629d8250e73330077485aae50c5d00d6c
|
7
|
+
data.tar.gz: 2af36a116a0f166d01c5a5240be0bd78d6993b05927e522f84794981d30304f2d04db3e0cbbeeee995c1219910e0e62beb32d8236e19a5694e643c1e2ecbb364
|
data/README.md
CHANGED
@@ -71,14 +71,33 @@ Available helpers for controllers and views:
|
|
71
71
|
Available filters and helpers for controllers:
|
72
72
|
|
73
73
|
* `authenticate_user!`
|
74
|
-
* `
|
75
|
-
* `
|
74
|
+
* `sign_in_with_access_token!(access_token)`
|
75
|
+
* `sign_out!`
|
76
|
+
* `warden`
|
77
|
+
* `sso_app`
|
76
78
|
|
77
79
|
Available helpers for views:
|
78
80
|
|
79
81
|
* `sso.sign_in_path`
|
80
82
|
* `sso.sign_out_path`
|
81
83
|
|
84
|
+
## Testing & Development mode
|
85
|
+
|
86
|
+
You can turn on "test mode" by enabling [OmniAuth test mode](https://github.com/intridea/omniauth/wiki/Integration-Testing).
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
OmniAuth.config.test_mode = true
|
90
|
+
```
|
91
|
+
|
92
|
+
To mock user data use OmniAuth `mock_auth` feature with your provider.
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
OmniAuth.config.mock_auth[:example] = OmniAuth::AuthHash.new({
|
96
|
+
name: 'John Kowalski',
|
97
|
+
uid: '42'
|
98
|
+
})
|
99
|
+
```
|
100
|
+
|
82
101
|
## Contributing
|
83
102
|
|
84
103
|
1. Fork it
|
data/lib/rails_sso/app.rb
CHANGED
@@ -30,6 +30,8 @@ module RailsSso
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def access_token
|
33
|
+
return mock_token if OmniAuth.config.test_mode
|
34
|
+
|
33
35
|
OAuth2::AccessToken.new(strategy.client, session[:access_token], {
|
34
36
|
refresh_token: session[:refresh_token]
|
35
37
|
})
|
@@ -43,16 +45,41 @@ module RailsSso
|
|
43
45
|
|
44
46
|
def provider_client
|
45
47
|
@provider_client ||= RailsSso::Client.new(RailsSso.provider_url) do |conn|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
shared_cache: false
|
48
|
+
case
|
49
|
+
when OmniAuth.config.test_mode
|
50
|
+
mock_connection(conn)
|
51
|
+
else
|
52
|
+
setup_connection(conn)
|
52
53
|
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def setup_connection(conn)
|
60
|
+
if RailsSso.use_cache
|
61
|
+
conn.use :http_cache,
|
62
|
+
store: Rails.cache,
|
63
|
+
logger: Rails.logger,
|
64
|
+
serializer: Marshal,
|
65
|
+
shared_cache: false
|
66
|
+
end
|
53
67
|
|
54
|
-
|
68
|
+
conn.adapter Faraday.default_adapter
|
69
|
+
end
|
70
|
+
|
71
|
+
def mock_connection(conn)
|
72
|
+
conn.adapter :test do |stub|
|
73
|
+
stub.get(RailsSso.provider_profile_path) { |env| [200, {}, mock_auth] }
|
55
74
|
end
|
56
75
|
end
|
76
|
+
|
77
|
+
def mock_auth
|
78
|
+
OmniAuth.config.mock_auth[RailsSso.provider_name.to_sym].to_json
|
79
|
+
end
|
80
|
+
|
81
|
+
def mock_token
|
82
|
+
RailsSso::TokenMock.new
|
83
|
+
end
|
57
84
|
end
|
58
85
|
end
|
data/lib/rails_sso/engine.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
|
3
|
+
module RailsSso
|
4
|
+
class TokenMock
|
5
|
+
attr_reader :connection
|
6
|
+
|
7
|
+
delegate :get, :post, :put, :patch, :delete, to: :connection
|
8
|
+
|
9
|
+
def initialize(*)
|
10
|
+
@connection = Faraday.new do |builder|
|
11
|
+
builder.adapter :test do |stub|
|
12
|
+
stub.delete(RailsSso.provider_sign_out_path) { |env| [200, {}, ''] }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/rails_sso/version.rb
CHANGED
data/lib/rails_sso.rb
CHANGED
data/test/dummy/log/test.log
CHANGED
@@ -4548,3 +4548,46 @@ RailsSso::ResponseErrorTest: test_assigns_unauthenticated_error_message_from_loc
|
|
4548
4548
|
----------------------------------------------------------------------------
|
4549
4549
|
RailsSso::ResponseErrorTest: test_assigns_unknown_error_message_from_locales
|
4550
4550
|
----------------------------------------------------------------------------
|
4551
|
+
-----------------------------------------------------------------------------
|
4552
|
+
RailsSso::FailureAppTest: test_.call_runs_respond_action_and_redirects_to_sso
|
4553
|
+
-----------------------------------------------------------------------------
|
4554
|
+
---------------------------------------------------------------------
|
4555
|
+
RailsSso::FetchUserTest: test_unauthenticated_call_should_raise_error
|
4556
|
+
---------------------------------------------------------------------
|
4557
|
+
-----------------------------------------------------------------------------------------------------
|
4558
|
+
RailsSso::FetchUserTest: test_success_call_should_fetch_user_with_access_token_and_return_parsed_data
|
4559
|
+
-----------------------------------------------------------------------------------------------------
|
4560
|
+
-------------------------------------------------------------
|
4561
|
+
RailsSso::FetchUserTest: test_unknown_call_should_raise_error
|
4562
|
+
-------------------------------------------------------------
|
4563
|
+
----------------------------------------------------
|
4564
|
+
RailsSso::ResponseErrorTest: test_assigns_error_code
|
4565
|
+
----------------------------------------------------
|
4566
|
+
----------------------------------------------------------------------------
|
4567
|
+
RailsSso::ResponseErrorTest: test_assigns_unknown_error_message_from_locales
|
4568
|
+
----------------------------------------------------------------------------
|
4569
|
+
------------------------------------------------------------------------------------
|
4570
|
+
RailsSso::ResponseErrorTest: test_assigns_unauthenticated_error_message_from_locales
|
4571
|
+
------------------------------------------------------------------------------------
|
4572
|
+
----------------------------------------------------
|
4573
|
+
SsoRoutesTest: test_should_route_/:provider/callback
|
4574
|
+
----------------------------------------------------
|
4575
|
+
------------------------------------------
|
4576
|
+
SsoRoutesTest: test_should_route_/sign_out
|
4577
|
+
------------------------------------------
|
4578
|
+
------------------------------------------------------------------------------------------------
|
4579
|
+
RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
|
4580
|
+
------------------------------------------------------------------------------------------------
|
4581
|
+
Processing by RailsSso::SessionsController#create as HTML
|
4582
|
+
Parameters: {"provider"=>"developer"}
|
4583
|
+
Redirected to http://test.host/
|
4584
|
+
Completed 302 Found in 0ms
|
4585
|
+
-------------------------------------------------------------------------------------------------------
|
4586
|
+
RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
|
4587
|
+
-------------------------------------------------------------------------------------------------------
|
4588
|
+
Processing by RailsSso::SessionsController#destroy as HTML
|
4589
|
+
Redirected to http://test.host/
|
4590
|
+
Completed 302 Found in 0ms
|
4591
|
+
------------------------
|
4592
|
+
RailsSsoTest: test_truth
|
4593
|
+
------------------------
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_sso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Dudulski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- lib/rails_sso/helpers.rb
|
133
133
|
- lib/rails_sso/response_error.rb
|
134
134
|
- lib/rails_sso/sso_strategy.rb
|
135
|
+
- lib/rails_sso/token_mock.rb
|
135
136
|
- lib/rails_sso/version.rb
|
136
137
|
- lib/tasks/rails_sso_tasks.rake
|
137
138
|
- test/controllers/rails_sso/sessions_controller_test.rb
|