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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d06f1431dfda1ada1148f0bab1f236e31c80ed15e3e3050f1938f30dd508e9e
4
- data.tar.gz: c12528d4977371f2d235cb4abcf7630655fb87efd64a4e940cf189d02adb2c5d
3
+ metadata.gz: df66e95e6c84e90d6a829873da316c0d3cdb336b3b2e126048f25bcea0bfa7c3
4
+ data.tar.gz: 5ce9214a84bab031917d274952deebbc459817d8e0239ba26bc403a0747ac3ee
5
5
  SHA512:
6
- metadata.gz: fca2e07d268d7d06f4146ec7cc1ddef34cf13480853e6900d5da33fa445e8512cdb222fc32d30636e9ec682df52a5802d7b8509040a4008102f41179198b153c
7
- data.tar.gz: 75b3acc3b3c4af7d898e4f974295ef7d6884fd2b3d661fd3de3352d28af9524d02a250630898bd88f949c2f23d4cfbe372a80227eb08b108de07a2d4c5c2311c
6
+ metadata.gz: fa41259af8b031cc3acb9a31ae790f698ed8b67bee7b8b795ffc673ed421fcff741460b259cf2003832b8348746510561337bd8002b95357c02cba83ff94f3ec
7
+ data.tar.gz: 0a0495472379faa31531b12ab6bfd9d4e2c58ca4704c5d411c7ed2c33a5e0eb4fe79a0989ae3abbad9ae5ca2f9d7beaf6e9c079b8c0945212442a46c8283ee22
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ *.gem
@@ -5,6 +5,10 @@ Metrics/BlockLength:
5
5
  Exclude:
6
6
  - 'spec/**/*'
7
7
 
8
+ Naming/FileName:
9
+ Exclude:
10
+ - 'lib/omniauth-osso.rb'
11
+
8
12
  Style/Documentation:
9
13
  Exclude:
10
14
  - 'spec/**/*'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omniauth-osso (0.1.0)
4
+ omniauth-osso (0.1.1)
5
5
  omniauth-oauth2 (~> 1.6.0)
6
6
 
7
7
  GEM
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'bundler/setup'
5
- require 'omniauth_osso'
5
+ require 'omniauth-osso'
6
6
 
7
7
  require 'irb'
8
8
  IRB.start(__FILE__)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module Osso
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
6
6
  end
7
7
  end
@@ -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 domain]
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 options_for(option)
59
- options_for = options.send(:"#{option}_options")
60
- params_for = options.send(:"#{option}_params")
69
+ def request_domain
70
+ return @request_domain if defined?(@request_domain)
61
71
 
62
- options_for.each_with_object({}) do |key, hash|
63
- value = params_for[key] || options[key]
64
- hash[key.to_sym] = value.respond_to?(:call) ? value.call : value
65
- end
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', authorize_params: { domain: 'bar.com' })
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: proc { 'qux' }, domain: 'foo.com' })
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
@@ -3,7 +3,7 @@
3
3
  $LOAD_PATH.unshift File.expand_path(__dir__)
4
4
  $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
5
5
 
6
- require 'omniauth_osso'
6
+ require 'omniauth-osso'
7
7
 
8
8
  require 'omniauth'
9
9
  require 'omniauth-oauth2'
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.0
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