omniauth-stitchlabs 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5784af97311af54f5a9995d918f36344196ef11f
4
+ data.tar.gz: 16c9f380b84490ce431ab9158681f9026141a866
5
+ SHA512:
6
+ metadata.gz: 384d58c9d58f5c66a446aa9e08157a8ef60a2dc353fefa88a99cf77c36e52770adeb581a8494a3744db6481fa66f41f59378334df27b450b6f6a2232c5191cf0
7
+ data.tar.gz: 5e939179571d2e901848d2fec39795fe63b2401b5822ecd759fa1dbb759f05277e75b20f178285cae244727a2337e0c52d7a54f199077bd0e3d18ad31797e648
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ .bundle/
2
+ coverage
3
+ .idea
4
+ log/*.log
5
+ pkg/
6
+ spec/dummy/db/*.sqlite3
7
+ spec/dummy/log/*.log
8
+ spec/dummy/tmp/
9
+ spec/dummy/.sass-cache
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in stitchlabs.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,82 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-stitchlabs (0.0.1)
5
+ omniauth-oauth2 (~> 1.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.3.5)
11
+ coveralls (0.7.0)
12
+ multi_json (~> 1.3)
13
+ rest-client
14
+ simplecov (>= 0.7)
15
+ term-ansicolor
16
+ thor
17
+ crack (0.4.2)
18
+ safe_yaml (~> 1.0.0)
19
+ diff-lcs (1.2.5)
20
+ docile (1.1.3)
21
+ faraday (0.9.0)
22
+ multipart-post (>= 1.2, < 3)
23
+ hashie (2.0.5)
24
+ jwt (0.1.11)
25
+ multi_json (>= 1.5)
26
+ mime-types (2.2)
27
+ multi_json (1.9.2)
28
+ multi_xml (0.5.5)
29
+ multipart-post (2.0.0)
30
+ oauth2 (0.9.3)
31
+ faraday (>= 0.8, < 0.10)
32
+ jwt (~> 0.1.8)
33
+ multi_json (~> 1.3)
34
+ multi_xml (~> 0.5)
35
+ rack (~> 1.2)
36
+ omniauth (1.2.1)
37
+ hashie (>= 1.2, < 3)
38
+ rack (~> 1.0)
39
+ omniauth-oauth2 (1.1.2)
40
+ faraday (>= 0.8, < 0.10)
41
+ multi_json (~> 1.3)
42
+ oauth2 (~> 0.9.3)
43
+ omniauth (~> 1.2)
44
+ rack (1.5.2)
45
+ rack-test (0.6.2)
46
+ rack (>= 1.0)
47
+ rake (10.1.1)
48
+ rest-client (1.6.7)
49
+ mime-types (>= 1.16)
50
+ rspec (2.14.1)
51
+ rspec-core (~> 2.14.0)
52
+ rspec-expectations (~> 2.14.0)
53
+ rspec-mocks (~> 2.14.0)
54
+ rspec-core (2.14.8)
55
+ rspec-expectations (2.14.5)
56
+ diff-lcs (>= 1.1.3, < 2.0)
57
+ rspec-mocks (2.14.6)
58
+ safe_yaml (1.0.1)
59
+ simplecov (0.8.2)
60
+ docile (~> 1.1.0)
61
+ multi_json
62
+ simplecov-html (~> 0.8.0)
63
+ simplecov-html (0.8.0)
64
+ term-ansicolor (1.3.0)
65
+ tins (~> 1.0)
66
+ thor (0.18.1)
67
+ tins (1.0.1)
68
+ webmock (1.17.4)
69
+ addressable (>= 2.2.7)
70
+ crack (>= 0.3.2)
71
+
72
+ PLATFORMS
73
+ ruby
74
+
75
+ DEPENDENCIES
76
+ coveralls
77
+ omniauth-stitchlabs!
78
+ rack-test
79
+ rake
80
+ rspec (~> 2.12)
81
+ simplecov
82
+ webmock
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Theo Mills
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # OmniAuth StitchLabs
2
+
3
+ StitchLabs OAuth2 Strategy for OmniAuth 1.0.
4
+
5
+ ## Installing
6
+
7
+ Add to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem 'omniauth-stitchlabs'
11
+ ```
12
+
13
+ Then `bundle install`.
14
+
15
+ ## Usage
16
+
17
+ `OmniAuth::Strategies::StitchLabs` is simply a Rack middleware. Read [the OmniAuth 1.0 docs](https://github.com/intridea/omniauth) for detailed instructions.
18
+
19
+ Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
20
+
21
+ ```ruby
22
+ Rails.application.config.middleware.use OmniAuth::Builder do
23
+ provider :stitchlabs, ENV['SHOPIFY_API_KEY'], ENV['SHOPIFY_SHARED_SECRET']
24
+ end
25
+ ```
26
+
27
+ ## Authentication Hash
28
+
29
+ Here's an example *Authentication Hash* available in `request.env['omniauth.auth']`:
30
+
31
+ ```ruby
32
+ {
33
+ :provider => 'shopify',
34
+ :credentials => {
35
+ :token => 'afasd923kjh0934kf', # OAuth 2.0 access_token, which you store and use to authenticate API requests
36
+ }
37
+ }
38
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/example/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ gem 'sinatra'
4
+ gem 'omniauth-stitchlabs'
data/example/config.ru ADDED
@@ -0,0 +1,30 @@
1
+ require 'bundler/setup'
2
+ require 'sinatra/base'
3
+ require 'omniauth-stitchlabs'
4
+
5
+ class App < Sinatra::Base
6
+ get '/' do
7
+ redirect '/auth/stitchlabs'
8
+ end
9
+
10
+ get '/auth/stitchlabs/callback' do
11
+ response = "Your user is successfully authenticated. Here are the details you need:<br/><br/>"
12
+ response << "access token: #{request.env['omniauth.auth']['credentials']['token']}<br/>"
13
+ response << "refresh token: #{request.env['omniauth.auth']['credentials']['refresh_token']}<br/>"
14
+ response << "expires at: #{request.env['omniauth.auth']['credentials']['expires_at']}<br/>"
15
+ response
16
+ end
17
+
18
+ get '/auth/failure' do
19
+ content_type 'application/json'
20
+ MultiJson.encode(request.env)
21
+ end
22
+ end
23
+
24
+ use Rack::Session::Cookie
25
+
26
+ use OmniAuth::Builder do
27
+ provider :stitchlabs, ENV['STITCHLABS_CLIENT_ID'], ENV['STITCHLABS_CLIENT_SECRET']
28
+ end
29
+
30
+ run App.new
@@ -0,0 +1 @@
1
+ require 'omniauth/stitchlabs'
@@ -0,0 +1,2 @@
1
+ require 'omniauth/stitchlabs/version'
2
+ require 'omniauth/strategies/stitchlabs'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module StitchLabs
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ require 'omniauth/strategies/oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class StitchLabs < OmniAuth::Strategies::OAuth2
6
+ option :name, "stitchlabs"
7
+ option :client_options, {
8
+ :site => 'https://api.stitchlabs.com',
9
+ :authorize_url => '/oauth/authorize',
10
+ :token_url => '/oauth/access_token'
11
+ }
12
+ end
13
+ end
14
+ end
15
+
16
+ OmniAuth.config.add_camelization 'stitchlabs', 'StitchLabs'
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'omniauth/stitchlabs/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "omniauth-stitchlabs"
7
+ spec.version = OmniAuth::StitchLabs::VERSION
8
+ spec.platform = Gem::Platform::RUBY
9
+ spec.authors = ["Theo Mills"]
10
+ spec.email = ["theo@shippingeasy.com"]
11
+ spec.summary = "StitchLabs OAuth2 strategy for OmniAuth"
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.1'
21
+ spec.add_development_dependency 'rspec', '~> 2.12'
22
+ spec.add_development_dependency 'rack-test'
23
+ spec.add_development_dependency 'webmock'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'simplecov'
26
+ spec.add_development_dependency 'coveralls'
27
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::StitchLabs do
4
+ def app; lambda{|env| [200, {}, ["Hello."]]} end
5
+ let(:fresh_strategy){ Class.new(OmniAuth::Strategies::StitchLabs) }
6
+
7
+ before do
8
+ OmniAuth.config.test_mode = true
9
+ end
10
+
11
+ after do
12
+ OmniAuth.config.test_mode = false
13
+ end
14
+
15
+ describe '#client' do
16
+ subject{ fresh_strategy }
17
+
18
+ it 'should have the correct stitchlabs site' do
19
+ instance = subject.new(app, {})
20
+ instance.client.site.should eq("https://api.stitchlabs.com")
21
+ end
22
+
23
+ it 'should have the correct authorization url' do
24
+ instance = subject.new(app, {})
25
+ instance.client.options[:authorize_url].should eq("/oauth/authorize")
26
+ end
27
+
28
+ it 'should have the correct token url' do
29
+ instance = subject.new(app, {})
30
+ instance.client.options[:token_url].should eq('/oauth/access_token')
31
+ end
32
+ end
33
+
34
+ describe '#authorize_params' do
35
+ subject { fresh_strategy }
36
+
37
+ it 'should include the appropriate authorize params passed in the :authorize_params option' do
38
+ instance = subject.new('abc', 'def', :authorize_params => {:scope => 'ViewReports,ImportSubscribers', :something => 'else', :state => '4321'})
39
+ instance.authorize_params[:scope].should eq('ViewReports,ImportSubscribers')
40
+ end
41
+
42
+ it 'should include appropriate top-level options that are marked as :authorize_options' do
43
+ instance = subject.new('abc', 'def', :authorize_options => [:scope], :scope => 'ViewReports,ImportSubscribers', :something => 'else', :authorize_params => {:state => '4321'})
44
+ instance.authorize_params[:scope].should eq('ViewReports,ImportSubscribers')
45
+ end
46
+ end
47
+
48
+ describe '#callback_path' do
49
+ subject{ fresh_strategy }
50
+
51
+ it 'should have the correct callback path' do
52
+ instance = subject.new(app, {})
53
+ instance.callback_path.should eq('/auth/stitchlabs/callback')
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,23 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+
4
+ require 'simplecov'
5
+ require 'coveralls'
6
+
7
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
8
+ SimpleCov::Formatter::HTMLFormatter,
9
+ Coveralls::SimpleCov::Formatter
10
+ ]
11
+ SimpleCov.start
12
+
13
+ require 'rspec'
14
+ require 'rack/test'
15
+ require 'webmock/rspec'
16
+ require 'omniauth'
17
+ require 'omniauth-stitchlabs'
18
+
19
+ RSpec.configure do |config|
20
+ config.include WebMock::API
21
+ config.include Rack::Test::Methods
22
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
23
+ end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-stitchlabs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Theo Mills
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '2.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '2.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rack-test
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
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: coveralls
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:
112
+ email:
113
+ - theo@shippingeasy.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - Gemfile
120
+ - Gemfile.lock
121
+ - LICENSE.txt
122
+ - README.md
123
+ - Rakefile
124
+ - example/Gemfile
125
+ - example/config.ru
126
+ - lib/omniauth-stitchlabs.rb
127
+ - lib/omniauth/stitchlabs.rb
128
+ - lib/omniauth/stitchlabs/version.rb
129
+ - lib/omniauth/strategies/stitchlabs.rb
130
+ - omniauth-stitchlabs.gemspec
131
+ - spec/omniauth/strategies/stitchlabs_spec.rb
132
+ - spec/spec_helper.rb
133
+ homepage: ''
134
+ licenses:
135
+ - MIT
136
+ metadata: {}
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - '>='
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.2.0
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: StitchLabs OAuth2 strategy for OmniAuth
157
+ test_files:
158
+ - spec/omniauth/strategies/stitchlabs_spec.rb
159
+ - spec/spec_helper.rb
160
+ has_rdoc: