omniauth-bigcommerce 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +6 -6
- data/.travis.yml +3 -3
- data/Gemfile +0 -10
- data/lib/omniauth-bigcommerce.rb +1 -1
- data/lib/omniauth/bigcommerce/version.rb +2 -2
- data/lib/omniauth/strategies/bigcommerce.rb +32 -10
- data/omniauth-bigcommerce.gemspec +8 -9
- data/spec/omniauth/strategies/bigcommerce_spec.rb +55 -19
- data/spec/spec_helper.rb +4 -7
- metadata +15 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fd32cd52747a4e99dbeb7fa6ac4b940f4efd540
|
4
|
+
data.tar.gz: a02adf6795281e1b97256aa74ac14641e4995668
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7d4e9e0b458833e6ac4266669b1716f2c19998fee1ebe81eaac9362b10dfe208b15e0c53ac1827273b6d38d5a3f45c21eb25cdcf835375460b2191e8bbde6a0
|
7
|
+
data.tar.gz: cacc7e225d778745ea2d50a4eb1131263ef78d7b58244ec4ea50d8aa11e367d5d24de626d44461357ffe597a2766d257e27f18dfd120e00003b6294be5a6b9b1
|
data/.gitignore
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
/
|
1
|
+
.bundle
|
2
|
+
Gemfile.lock
|
3
|
+
coverage
|
4
|
+
reports
|
5
|
+
pkg
|
6
|
+
vendor/bundle
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/lib/omniauth-bigcommerce.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require
|
1
|
+
require 'omniauth/bigcommerce/version'
|
2
2
|
require 'omniauth/strategies/bigcommerce'
|
@@ -2,15 +2,13 @@ require 'omniauth-oauth2'
|
|
2
2
|
|
3
3
|
module OmniAuth
|
4
4
|
module Strategies
|
5
|
-
class
|
6
|
-
option :name,
|
7
|
-
|
5
|
+
class BigCommerce < OmniAuth::Strategies::OAuth2
|
6
|
+
option :name, 'bigcommerce'
|
8
7
|
option :provider_ignores_state, true
|
9
|
-
|
10
|
-
option :scope,
|
11
|
-
|
12
|
-
option :client_options,
|
13
|
-
{
|
8
|
+
option :scope, 'users_basic_information'
|
9
|
+
option :authorize_options, [:scope, :context]
|
10
|
+
option :token_options, [:scope, :context]
|
11
|
+
option :client_options, {
|
14
12
|
site: ENV['BC_AUTH_SERVICE'] || 'https://login.bigcommerce.com',
|
15
13
|
authorize_url: '/oauth2/authorize',
|
16
14
|
token_url: '/oauth2/token'
|
@@ -27,7 +25,7 @@ module OmniAuth
|
|
27
25
|
|
28
26
|
credentials do
|
29
27
|
{
|
30
|
-
:
|
28
|
+
token: access_token
|
31
29
|
}
|
32
30
|
end
|
33
31
|
|
@@ -43,8 +41,32 @@ module OmniAuth
|
|
43
41
|
@raw_info ||= access_token.params
|
44
42
|
end
|
45
43
|
|
44
|
+
# Exclude query string in callback url. This used to be part of omniauth-oauth2, but was
|
45
|
+
# removed in 1.4.0: https://github.com/intridea/omniauth-oauth2/pull/70
|
46
|
+
def callback_url
|
47
|
+
full_host + script_name + callback_path
|
48
|
+
end
|
49
|
+
|
50
|
+
# Make sure to pass scope and context through to the authorize call
|
51
|
+
# https://github.com/zquestz/omniauth-google-oauth2/blob/master/lib/omniauth/strategies/google_oauth2.rb#L26
|
52
|
+
def authorize_params
|
53
|
+
super.tap do |params|
|
54
|
+
options[:authorize_options].each do |k|
|
55
|
+
params[k] = request.params[k.to_s] unless [nil, ''].include?(request.params[k.to_s])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Make sure to pass scope and context through to the token exchange call
|
61
|
+
def token_params
|
62
|
+
super.tap do |params|
|
63
|
+
options[:token_options].each do |k|
|
64
|
+
params[k] = request.params[k.to_s] unless [nil, ''].include?(request.params[k.to_s])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
46
68
|
end
|
47
69
|
end
|
48
70
|
end
|
49
71
|
|
50
|
-
OmniAuth.config.add_camelization 'bigcommerce', '
|
72
|
+
OmniAuth.config.add_camelization 'bigcommerce', 'BigCommerce'
|
@@ -4,8 +4,8 @@ require File.expand_path('../lib/omniauth/bigcommerce/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Tom Allen, Phil Muir, Sasha Gerrand"]
|
6
6
|
gem.email = ["developer@bigcommerce.com"]
|
7
|
-
gem.description = %q{Official OmniAuth strategy for
|
8
|
-
gem.summary = %q{Official OmniAuth strategy for
|
7
|
+
gem.description = %q{Official OmniAuth strategy for BigCommerce.}
|
8
|
+
gem.summary = %q{Official OmniAuth strategy for BigCommerce.}
|
9
9
|
gem.homepage = "https://github.com/bigcommerce/omniauth-bigcommerce"
|
10
10
|
|
11
11
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
@@ -13,13 +13,12 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
14
|
gem.name = "omniauth-bigcommerce"
|
15
15
|
gem.require_paths = ["lib"]
|
16
|
-
gem.
|
16
|
+
gem.required_ruby_version = '>= 2.1'
|
17
|
+
gem.version = OmniAuth::BigCommerce::VERSION
|
17
18
|
|
18
|
-
gem.add_dependency 'omniauth'
|
19
|
-
gem.add_dependency 'omniauth-oauth2', '
|
20
|
-
gem.add_development_dependency 'rake'
|
21
|
-
gem.add_development_dependency 'rspec'
|
22
|
-
gem.add_development_dependency 'rack-test'
|
19
|
+
gem.add_dependency 'omniauth'
|
20
|
+
gem.add_dependency 'omniauth-oauth2', '>= 1.1.1'
|
21
|
+
gem.add_development_dependency 'rake'
|
22
|
+
gem.add_development_dependency 'rspec'
|
23
23
|
gem.add_development_dependency 'simplecov'
|
24
|
-
gem.add_development_dependency 'webmock'
|
25
24
|
end
|
@@ -1,40 +1,76 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe OmniAuth::Strategies::
|
3
|
+
RSpec.describe OmniAuth::Strategies::BigCommerce do
|
4
|
+
let(:store_hash) { 'abcdefg' }
|
5
|
+
let(:context) { "stores/#{store_hash}" }
|
6
|
+
let(:scope) { 'store_v2_products' }
|
7
|
+
let(:request) { double('Request', :params => { 'context' => context, 'scope' => scope }, :cookies => {}, :env => {}) }
|
4
8
|
|
5
|
-
|
6
|
-
OmniAuth
|
9
|
+
before do
|
10
|
+
OmniAuth.config.test_mode = true
|
11
|
+
allow(subject).to receive(:request).and_return(request)
|
7
12
|
end
|
13
|
+
after { OmniAuth.config.test_mode = false }
|
14
|
+
subject { OmniAuth::Strategies::BigCommerce.new({}) }
|
8
15
|
|
9
|
-
|
16
|
+
describe 'options' do
|
10
17
|
it 'should have correct name' do
|
11
18
|
expect(subject.options.name).to eq('bigcommerce')
|
12
19
|
end
|
13
20
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
21
|
+
describe 'client options' do
|
22
|
+
it 'should have correct site' do
|
23
|
+
# env variable set in spec_helper.rb
|
24
|
+
# TODO: change this once we have bigcommerceapp.com url
|
25
|
+
expect(subject.options.client_options.site).to eq('https://example.com')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should have correct authorize url' do
|
29
|
+
expect(subject.options.client_options.authorize_url).to eq('/oauth2/authorize')
|
30
|
+
end
|
19
31
|
|
20
|
-
|
21
|
-
|
32
|
+
it 'should have correct token url' do
|
33
|
+
expect(subject.options.client_options.token_url).to eq('/oauth2/token')
|
34
|
+
end
|
22
35
|
end
|
23
36
|
|
24
|
-
|
25
|
-
|
37
|
+
describe 'OAuth2 settings' do
|
38
|
+
it 'should ignore state' do
|
39
|
+
expect(subject.options.provider_ignores_state).to eq true
|
40
|
+
end
|
26
41
|
end
|
27
42
|
end
|
28
43
|
|
29
|
-
|
30
|
-
it 'should
|
31
|
-
expect(subject.
|
44
|
+
describe 'callback url' do
|
45
|
+
it 'should have the correct path' do
|
46
|
+
expect(subject.callback_path).to eq('/auth/bigcommerce/callback')
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when callback url has a query string' do
|
50
|
+
let(:host) { 'https://example.com' }
|
51
|
+
let(:query_string) { 'foo=bar' }
|
52
|
+
before do
|
53
|
+
allow(subject).to receive(:full_host).and_return(host)
|
54
|
+
allow(subject).to receive(:script_name).and_return('')
|
55
|
+
allow(subject).to receive(:query_string).and_return(query_string)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'query string should not be included in the callback url' do
|
59
|
+
expect(subject.callback_url).to eq("#{host}#{subject.callback_path}")
|
60
|
+
expect(subject.callback_url).to_not include(query_string)
|
61
|
+
end
|
32
62
|
end
|
33
63
|
end
|
34
64
|
|
35
|
-
|
36
|
-
it 'should
|
37
|
-
subject.
|
65
|
+
describe 'extra params for authorize and token exchange' do
|
66
|
+
it 'should set the context and scope parameters in the authorize request' do
|
67
|
+
expect(subject.authorize_params['context']).to eq(context)
|
68
|
+
expect(subject.authorize_params['scope']).to eq(scope)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should set the context and scope parameters in the token request' do
|
72
|
+
expect(subject.token_params['context']).to eq(context)
|
73
|
+
expect(subject.token_params['scope']).to eq(scope)
|
38
74
|
end
|
39
75
|
end
|
40
76
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,15 +2,12 @@ ENV['BC_AUTH_SERVICE'] = 'https://example.com'
|
|
2
2
|
|
3
3
|
require 'simplecov'
|
4
4
|
SimpleCov.start
|
5
|
-
|
6
|
-
require 'rack/test'
|
7
|
-
require 'webmock/rspec'
|
8
|
-
require 'omniauth'
|
5
|
+
|
9
6
|
require 'omniauth-bigcommerce'
|
10
7
|
|
11
8
|
RSpec.configure do |config|
|
12
|
-
config.
|
13
|
-
config.
|
14
|
-
config.
|
9
|
+
config.color = true
|
10
|
+
config.order = :random
|
11
|
+
Kernel.srand config.seed
|
15
12
|
end
|
16
13
|
|
metadata
CHANGED
@@ -1,73 +1,45 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-bigcommerce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Allen, Phil Muir, Sasha Gerrand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: omniauth-oauth2
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.1.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 1.1.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ~>
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '2.7'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ~>
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '2.7'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '2.7'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '2.7'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rack-test
|
71
43
|
requirement: !ruby/object:Gem::Requirement
|
72
44
|
requirements:
|
73
45
|
- - '>='
|
@@ -81,7 +53,7 @@ dependencies:
|
|
81
53
|
- !ruby/object:Gem::Version
|
82
54
|
version: '0'
|
83
55
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
56
|
+
name: rspec
|
85
57
|
requirement: !ruby/object:Gem::Requirement
|
86
58
|
requirements:
|
87
59
|
- - '>='
|
@@ -95,7 +67,7 @@ dependencies:
|
|
95
67
|
- !ruby/object:Gem::Version
|
96
68
|
version: '0'
|
97
69
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
70
|
+
name: simplecov
|
99
71
|
requirement: !ruby/object:Gem::Requirement
|
100
72
|
requirements:
|
101
73
|
- - '>='
|
@@ -108,7 +80,7 @@ dependencies:
|
|
108
80
|
- - '>='
|
109
81
|
- !ruby/object:Gem::Version
|
110
82
|
version: '0'
|
111
|
-
description: Official OmniAuth strategy for
|
83
|
+
description: Official OmniAuth strategy for BigCommerce.
|
112
84
|
email:
|
113
85
|
- developer@bigcommerce.com
|
114
86
|
executables: []
|
@@ -138,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
138
110
|
requirements:
|
139
111
|
- - '>='
|
140
112
|
- !ruby/object:Gem::Version
|
141
|
-
version: '
|
113
|
+
version: '2.1'
|
142
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
115
|
requirements:
|
144
116
|
- - '>='
|
@@ -149,7 +121,7 @@ rubyforge_project:
|
|
149
121
|
rubygems_version: 2.0.14
|
150
122
|
signing_key:
|
151
123
|
specification_version: 4
|
152
|
-
summary: Official OmniAuth strategy for
|
124
|
+
summary: Official OmniAuth strategy for BigCommerce.
|
153
125
|
test_files:
|
154
126
|
- spec/omniauth/strategies/bigcommerce_spec.rb
|
155
127
|
- spec/spec_helper.rb
|