omniauth-osso 0.1.0 → 0.1.1
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/.gitignore +1 -0
- data/.rubocop.yml +4 -0
- data/Gemfile.lock +1 -1
- data/bin/console +1 -1
- data/lib/{omniauth_osso.rb → omniauth-osso.rb} +0 -0
- data/lib/omniauth-osso/version.rb +1 -1
- data/lib/omniauth/strategies/osso.rb +21 -10
- data/spec/omniauth/strategies/osso_spec.rb +2 -18
- data/spec/spec_helper.rb +1 -1
- 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: df66e95e6c84e90d6a829873da316c0d3cdb336b3b2e126048f25bcea0bfa7c3
|
4
|
+
data.tar.gz: 5ce9214a84bab031917d274952deebbc459817d8e0239ba26bc403a0747ac3ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa41259af8b031cc3acb9a31ae790f698ed8b67bee7b8b795ffc673ed421fcff741460b259cf2003832b8348746510561337bd8002b95357c02cba83ff94f3ec
|
7
|
+
data.tar.gz: 0a0495472379faa31531b12ab6bfd9d4e2c58ca4704c5d411c7ed2c33a5e0eb4fe79a0989ae3abbad9ae5ca2f9d7beaf6e9c079b8c0945212442a46c8283ee22
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/bin/console
CHANGED
File without changes
|
@@ -14,17 +14,28 @@ module OmniAuth
|
|
14
14
|
option :client_secret, nil
|
15
15
|
option :client_options, { site: ENV['OSSO_BASE_URL'] }
|
16
16
|
option :authorize_params, { state: SecureRandom.hex(24) }
|
17
|
-
option :authorize_options, %i[state
|
17
|
+
option :authorize_options, %i[state]
|
18
18
|
option :token_params, {}
|
19
19
|
option :token_options, []
|
20
20
|
option :auth_token_params, {}
|
21
21
|
option :provider_ignores_state, false
|
22
22
|
|
23
|
+
def request_phase
|
24
|
+
redirect(
|
25
|
+
client
|
26
|
+
.auth_code
|
27
|
+
.authorize_url(
|
28
|
+
{
|
29
|
+
redirect_uri: callback_url,
|
30
|
+
domain: request_domain
|
31
|
+
}.merge(authorize_params)
|
32
|
+
)
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
23
36
|
def authorize_params
|
24
37
|
params = options.authorize_params.merge(options_for('authorize')) || {}
|
25
38
|
|
26
|
-
raise StandardError if params[:domain].nil?
|
27
|
-
|
28
39
|
if OmniAuth.config.test_mode
|
29
40
|
@env ||= {}
|
30
41
|
@env['rack.session'] ||= {}
|
@@ -55,14 +66,14 @@ module OmniAuth
|
|
55
66
|
|
56
67
|
protected
|
57
68
|
|
58
|
-
def
|
59
|
-
|
60
|
-
params_for = options.send(:"#{option}_params")
|
69
|
+
def request_domain
|
70
|
+
return @request_domain if defined?(@request_domain)
|
61
71
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
72
|
+
@request_domain = request.params['domain'] || request.params['email'].split('@')[1]
|
73
|
+
|
74
|
+
raise StandardError if @request_domain.nil?
|
75
|
+
|
76
|
+
@request_domain
|
66
77
|
end
|
67
78
|
end
|
68
79
|
end
|
@@ -39,33 +39,17 @@ describe OmniAuth::Strategies::Osso do
|
|
39
39
|
describe '#authorize_params' do
|
40
40
|
subject { fresh_strategy }
|
41
41
|
|
42
|
-
it 'includes the domain authorize param passed in the :authorize_params option' do
|
43
|
-
instance = subject.new('abc', 'def', authorize_params: { domain: 'bar.com' })
|
44
|
-
expect(instance.authorize_params['domain']).to eq('bar.com')
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'includes top-level domain' do
|
48
|
-
instance = subject.new('abc', 'def', domain: 'bar.com')
|
49
|
-
expect(instance.authorize_params['domain']).to eq('bar.com')
|
50
|
-
expect(instance.authorize_params['state']).not_to be_empty
|
51
|
-
end
|
52
|
-
|
53
42
|
it 'includes random state in the authorize params' do
|
54
|
-
instance = subject.new('abc', 'def'
|
43
|
+
instance = subject.new('abc', 'def')
|
55
44
|
expect(instance.authorize_params.keys).to include('state')
|
56
45
|
expect(instance.session['omniauth.state']).not_to be_empty
|
57
46
|
end
|
58
47
|
|
59
48
|
it 'includes custom state in the authorize params' do
|
60
|
-
instance = subject.new('abc', 'def', authorize_params: { state:
|
49
|
+
instance = subject.new('abc', 'def', authorize_params: { state: 'qux' })
|
61
50
|
expect(instance.authorize_params.keys).to include('state')
|
62
51
|
expect(instance.session['omniauth.state']).to eq('qux')
|
63
52
|
end
|
64
|
-
|
65
|
-
it 'includes state and domain as authorize options' do
|
66
|
-
instance = subject.new('abc', 'def', domain: 'foo.com')
|
67
|
-
expect(instance.authorize_params.keys).to eq(%w[state domain])
|
68
|
-
end
|
69
53
|
end
|
70
54
|
|
71
55
|
describe '#token_params' do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-osso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Bauch
|
@@ -56,9 +56,9 @@ files:
|
|
56
56
|
- Rakefile
|
57
57
|
- bin/console
|
58
58
|
- bin/setup
|
59
|
+
- lib/omniauth-osso.rb
|
59
60
|
- lib/omniauth-osso/version.rb
|
60
61
|
- lib/omniauth/strategies/osso.rb
|
61
|
-
- lib/omniauth_osso.rb
|
62
62
|
- omniauth-osso.gemspec
|
63
63
|
- spec/omniauth/strategies/osso_spec.rb
|
64
64
|
- spec/spec_helper.rb
|