omniauth-icalia 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -0
- data/lib/icalia/stubbed_sso_service.rb +44 -15
- data/lib/omniauth-icalia/version.rb +1 -1
- data/lib/omniauth/strategies/icalia.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: 4dfbfb47218190adfbee66c478cf9787d52b5de4ccea2f9d325c415553ed3ec8
|
4
|
+
data.tar.gz: 775e1514daa1c195234328daf2534a90b773f3ce27f75e390d743e03791b069a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 478333a7b552a4961d892e3088b8a86755743605124d8aed6897bfb366c3aadd6a93b205cf565ddbaf30d1ff4f5dd2f3a0c7ae587e839ab796ec45382fb50dcb
|
7
|
+
data.tar.gz: 2dd160af460ee9a27f54efca2e702ab2b3e3c86d571e8235ef301dfb3c40c938bdab3596b531289e69e15611f04ac48b983dc6114c34267657298335eaa84b36
|
data/README.md
CHANGED
@@ -51,6 +51,35 @@ before do
|
|
51
51
|
end
|
52
52
|
```
|
53
53
|
|
54
|
+
If your'e testing a sign-in flow:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
scenario 'sign-in' do
|
58
|
+
# Simulate that the user will sign-in at the SSO site:
|
59
|
+
Icalia::StubbedSSOService.sign_in_on_authorize
|
60
|
+
visit root_path # or any path in your app that requires authentication
|
61
|
+
|
62
|
+
#...
|
63
|
+
end
|
64
|
+
```
|
65
|
+
|
66
|
+
If your'e testing a sign-out flow:
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
scenario 'sign-out' do
|
70
|
+
# Simulate that the user will sign-in at the SSO site:
|
71
|
+
Icalia::StubbedSSOService.sign_in_on_authorize
|
72
|
+
visit root_path # or any path in your app that requires authentication
|
73
|
+
|
74
|
+
# Simulate that the user won't sign-in at the SSO site:
|
75
|
+
Icalia::StubbedSSOService.do_not_sign_in_on_authorize
|
76
|
+
click_link 'Logout'
|
77
|
+
|
78
|
+
# The message coming from Artanis & the Fake Artanis "StubbedSSOService":
|
79
|
+
expect(page).to have_content 'Signed out successfully.'
|
80
|
+
end
|
81
|
+
```
|
82
|
+
|
54
83
|
## Development
|
55
84
|
|
56
85
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -10,6 +10,8 @@ module Icalia
|
|
10
10
|
FIND_AVAILABLE_PORT = 0
|
11
11
|
CODE = 'icalia_oauth_authorization_code'.freeze
|
12
12
|
|
13
|
+
@@sign_in_user_on_authorize = false
|
14
|
+
|
13
15
|
post '/oauth/token' do
|
14
16
|
if params[:code] == CODE
|
15
17
|
response.headers['Content-Type'] = 'application/json'
|
@@ -30,7 +32,18 @@ module Icalia
|
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
35
|
+
get '/sign-in' do
|
36
|
+
'Signed out successfully.'
|
37
|
+
end
|
38
|
+
|
39
|
+
get '/sign-out' do
|
40
|
+
uri = URI(params[:redirect_uri])
|
41
|
+
redirect uri
|
42
|
+
end
|
43
|
+
|
33
44
|
get '/oauth/authorize' do
|
45
|
+
return redirect '/sign-in' unless @@sign_in_user_on_authorize
|
46
|
+
|
34
47
|
store_oauth_flow_data params
|
35
48
|
uri = URI(params[:redirect_uri])
|
36
49
|
uri.query = URI.encode_www_form(state: params[:state], code: CODE)
|
@@ -116,37 +129,53 @@ module Icalia
|
|
116
129
|
def store_oauth_flow_data(data)
|
117
130
|
oauth_flows << data
|
118
131
|
end
|
132
|
+
|
133
|
+
def url
|
134
|
+
"http://localhost:#{server_port}"
|
135
|
+
end
|
136
|
+
|
137
|
+
def sign_in_url
|
138
|
+
"#{url}/sign-in"
|
139
|
+
end
|
119
140
|
|
120
141
|
# Taken from FakeStripe.stub_stripe at fake_stripe gem:
|
121
142
|
def prepare
|
122
143
|
reset
|
123
|
-
|
144
|
+
|
124
145
|
yield self if block_given?
|
125
|
-
|
146
|
+
|
126
147
|
# Since the OAuth flow is performed by the browser, we'll need to boot
|
127
148
|
# the Sinatra app instead of just stubbing the app with WebMock...
|
128
149
|
boot_once
|
129
|
-
|
130
|
-
oauth_host = "http://localhost:#{server_port}"
|
131
150
|
|
132
|
-
OmniAuth::Strategies::Icalia.instances.each do |
|
133
|
-
client_options
|
134
|
-
|
135
|
-
|
136
|
-
|
151
|
+
OmniAuth::Strategies::Icalia.instances.each do |strategy|
|
152
|
+
strategy.options.client_options.tap do |options|
|
153
|
+
options.site = url
|
154
|
+
options.token_url = "#{oauth_host}/oauth/token"
|
155
|
+
options.authorize_url = "#{oauth_host}/oauth/authorize"
|
156
|
+
end
|
137
157
|
end
|
138
158
|
end
|
139
159
|
|
160
|
+
def sign_in_on_authorize
|
161
|
+
@@sign_in_user_on_authorize = true
|
162
|
+
end
|
163
|
+
|
164
|
+
def do_not_sign_in_on_authorize
|
165
|
+
@@sign_in_user_on_authorize = false
|
166
|
+
end
|
167
|
+
|
140
168
|
def teardown
|
141
169
|
default_client_options = OmniAuth::Strategies::Icalia
|
142
170
|
.default_options
|
143
171
|
.client_options
|
144
|
-
|
145
|
-
OmniAuth::Strategies::Icalia.instances.each do |
|
146
|
-
client_options
|
147
|
-
|
148
|
-
|
149
|
-
|
172
|
+
|
173
|
+
OmniAuth::Strategies::Icalia.instances.each do |strategy|
|
174
|
+
strategy.options.client_options.tap do |options|
|
175
|
+
options.site = default_client_options.site
|
176
|
+
options.token_url = default_client_options.token_url
|
177
|
+
options.authorize_url = default_client_options.authorize_url
|
178
|
+
end
|
150
179
|
end
|
151
180
|
end
|
152
181
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-icalia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Quintanilla
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth
|