omniauth-bigcommerce 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ae29ba3aca8d409d3dd30d0701c87dd328d98657
4
+ data.tar.gz: f0adc06fd7a179cd2d1010667890204b8d8d0ce7
5
+ SHA512:
6
+ metadata.gz: a9656528f068f1c5b7d31e4c69571727d52b16bed0c851a5b1e2205d3f5d5a571d389657a34d1561bef8a0d42ac19a2c2fd960d17ad7953b0f489085ec2f7fd0
7
+ data.tar.gz: 8145de6b8825c9762b6f0120532b4d4625a740809c7746f42d6673059abaf64b73e05c19db87e6a33537c8c57e5f37bf5f1da93a185707c2f6c2313be2237596
@@ -0,0 +1,6 @@
1
+ # Ignore lockfiles
2
+ /Gemfile.lock
3
+
4
+ # Ignore test output
5
+ /spec/coverage
6
+ /spec/reports
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - ruby-head
4
+ - 2.1.1
5
+ - 2.0.0
6
+ - 1.9.3
7
+ matrix:
8
+ allow_failures:
9
+ - rvm: ruby-head
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-bigcommerce.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'rake'
8
+ gem 'guard'
9
+ gem 'guard-rspec'
10
+ gem 'guard-bundler'
11
+ gem 'rb-fsevent'
12
+ gem 'growl'
13
+ end
@@ -0,0 +1,10 @@
1
+ guard 'rspec', :version => 2 do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
6
+
7
+ guard 'bundler' do
8
+ watch('Gemfile')
9
+ watch('omniauth-bigcommerce.gemspec')
10
+ end
@@ -0,0 +1,67 @@
1
+ # OmniAuth Bigcommerce Strategy
2
+ [![Build Status](https://travis-ci.org/bigcommerce/omniauth-bigcommerce.png?branch=master)](https://travis-ci.org/bigcommerce/omniauth-bigcommerce)
3
+
4
+ This gem provides a dead simple way to authenticate to Bigcommerce using OmniAuth.
5
+
6
+ ## Installation
7
+
8
+ Add to your application's Gemfile:
9
+
10
+ ```
11
+ gem 'omniauth-bigcommerce'
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ First, you will need to [register an application](https://developer.bigcommerce.com).
17
+
18
+ Create a `config/initializers/omniauth.rb` initializer:
19
+ ```
20
+ use OmniAuth::Builder do
21
+ provider :bigcommerce, ENV['BC_CLIENT_ID'], ENV['BC_CLIENT_SECRET'], 'users_basic_information store_v2_settings store_v2_orders'
22
+ end
23
+ ```
24
+
25
+ You may also overwrite default config options:
26
+ ```
27
+ Rails.application.config.middleware.use OmniAuth::Builder do
28
+ provider :bigcommerce, ENV['BC_CLIENT_ID'], ENV['BC_CLIENT_SECRET'],
29
+ {
30
+ scope: "users_basic_information store_v2_products store_v2_information",
31
+ client_options: {
32
+ site: 'https://login.bigcommerce.com'
33
+ }
34
+ }
35
+ end
36
+ ```
37
+ See the [Omniauth Wiki](https://github.com/intridea/omniauth/wiki) for more information.
38
+
39
+ ## Environment Variables
40
+ The gem will look for the bigcommerce oauth provider URL in the `BC_AUTH_SERVICE` environment variable.
41
+ It defaults to https://login.bigcommerce.com if the env variable is not defined.
42
+
43
+ ## Auth Hash Schema
44
+
45
+ The following information is provided back to you for this provider:
46
+
47
+ ```
48
+ {
49
+ uid: '12345',
50
+ info: {
51
+ name: 'Philip Muir',
52
+ email: 'philip.muir@example.com'
53
+ },
54
+ credentials: {
55
+ token: 'xyz123abc'
56
+ },
57
+ extra: {
58
+ raw_info: {},
59
+ scopes: 'requested_scopes store_v2_settings'
60
+ context: 'store/xyz123'
61
+ }
62
+ }
63
+ ```
64
+
65
+ ## Contributing
66
+
67
+ Fork & submit a pull request.
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new
6
+
7
+ desc 'Run specs'
8
+ task :default => :spec
@@ -0,0 +1,2 @@
1
+ require "omniauth/bigcommerce/version"
2
+ require 'omniauth/strategies/bigcommerce'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Bigcommerce
3
+ VERSION = "0.2.0"
4
+ end
5
+ end
@@ -0,0 +1,50 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Bigcommerce < OmniAuth::Strategies::OAuth2
6
+ option :name, "bigcommerce"
7
+
8
+ option :provider_ignores_state, true
9
+
10
+ option :scope, "users_basic_information"
11
+
12
+ option :client_options,
13
+ {
14
+ site: ENV['BC_AUTH_SERVICE'] || 'https://login.bigcommerce.com',
15
+ authorize_url: '/oauth2/authorize',
16
+ token_url: '/oauth2/token'
17
+ }
18
+
19
+ uid { access_token.params['user']['id'] }
20
+
21
+ info do
22
+ {
23
+ name: access_token.params['user']['username'],
24
+ email: access_token.params['user']['email'],
25
+ }
26
+ end
27
+
28
+ credentials do
29
+ {
30
+ :token => access_token
31
+ }
32
+ end
33
+
34
+ extra do
35
+ {
36
+ raw_info: raw_info,
37
+ scopes: raw_info['scope'],
38
+ context: raw_info['context']
39
+ }
40
+ end
41
+
42
+ def raw_info
43
+ @raw_info ||= access_token.params
44
+ end
45
+
46
+ end
47
+ end
48
+ end
49
+
50
+ OmniAuth.config.add_camelization 'bigcommerce', 'Bigcommerce'
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth/bigcommerce/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Tom Allen, Phil Muir, Sasha Gerrand"]
6
+ gem.email = ["developer@bigcommerce.com"]
7
+ gem.description = %q{Official OmniAuth strategy for Bigcommerce.}
8
+ gem.summary = %q{Official OmniAuth strategy for Bigcommerce.}
9
+ gem.homepage = "https://github.com/bigcommerce/omniauth-bigcommerce"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "omniauth-bigcommerce"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = OmniAuth::Bigcommerce::VERSION
17
+
18
+ gem.add_dependency 'omniauth', '~> 1.0'
19
+ gem.add_dependency 'omniauth-oauth2', '~> 1.1'
20
+ gem.add_development_dependency 'rake', '~> 2.7'
21
+ gem.add_development_dependency 'rspec', '~> 2.7'
22
+ gem.add_development_dependency 'rack-test'
23
+ gem.add_development_dependency 'simplecov'
24
+ gem.add_development_dependency 'webmock'
25
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Bigcommerce do
4
+
5
+ subject do
6
+ OmniAuth::Strategies::Bigcommerce.new({})
7
+ end
8
+
9
+ context 'client options' do
10
+ it 'should have correct name' do
11
+ expect(subject.options.name).to eq('bigcommerce')
12
+ end
13
+
14
+ it 'should have correct site' do
15
+ # env variable set in spec_helper.rb
16
+ # TODO: change this once we have bigcommerceapp.com url
17
+ expect(subject.options.client_options.site).to eq('https://example.com')
18
+ end
19
+
20
+ it 'should have correct authorize url' do
21
+ expect(subject.options.client_options.authorize_url).to eq('/oauth2/authorize')
22
+ end
23
+
24
+ it 'should have correct token url' do
25
+ expect(subject.options.client_options.token_url).to eq('/oauth2/token')
26
+ end
27
+ end
28
+
29
+ context 'oauth2 settings' do
30
+ it 'should ignore state' do
31
+ expect(subject.options.provider_ignores_state).to eq true
32
+ end
33
+ end
34
+
35
+ context 'callback url' do
36
+ it 'should have the correct path' do
37
+ subject.callback_path.should eq('/auth/bigcommerce/callback')
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,16 @@
1
+ ENV['BC_AUTH_SERVICE'] = 'https://example.com'
2
+
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ require 'rspec'
6
+ require 'rack/test'
7
+ require 'webmock/rspec'
8
+ require 'omniauth'
9
+ require 'omniauth-bigcommerce'
10
+
11
+ RSpec.configure do |config|
12
+ config.include WebMock::API
13
+ config.include Rack::Test::Methods
14
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
15
+ end
16
+
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-bigcommerce
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Tom Allen, Phil Muir, Sasha Gerrand
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ - !ruby/object:Gem::Dependency
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
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Official OmniAuth strategy for Bigcommerce.
112
+ email:
113
+ - developer@bigcommerce.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - .travis.yml
120
+ - Gemfile
121
+ - Guardfile
122
+ - README.md
123
+ - Rakefile
124
+ - lib/omniauth-bigcommerce.rb
125
+ - lib/omniauth/bigcommerce/version.rb
126
+ - lib/omniauth/strategies/bigcommerce.rb
127
+ - omniauth-bigcommerce.gemspec
128
+ - spec/omniauth/strategies/bigcommerce_spec.rb
129
+ - spec/spec_helper.rb
130
+ homepage: https://github.com/bigcommerce/omniauth-bigcommerce
131
+ licenses: []
132
+ metadata: {}
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubyforge_project:
149
+ rubygems_version: 2.0.14
150
+ signing_key:
151
+ specification_version: 4
152
+ summary: Official OmniAuth strategy for Bigcommerce.
153
+ test_files:
154
+ - spec/omniauth/strategies/bigcommerce_spec.rb
155
+ - spec/spec_helper.rb