omniauth-shapeways 0.1.0

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.
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .env
6
+ coverage
7
+ InstalledFiles
8
+ lib/bundler/man
9
+ pkg
10
+ rdoc
11
+ spec/reports
12
+ test/tmp
13
+ test/version_tmp
14
+ tmp
15
+ .sass-cache/
16
+
17
+ # YARD artifacts
18
+ .yardoc
19
+ _yardoc
20
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,54 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-shapeways (0.1.0)
5
+ json
6
+ multi_json
7
+ omniauth
8
+ omniauth-oauth
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ addressable (2.3.4)
14
+ crack (0.3.2)
15
+ diff-lcs (1.2.4)
16
+ hashie (2.0.5)
17
+ json (1.8.0)
18
+ multi_json (1.7.3)
19
+ oauth (0.4.7)
20
+ omniauth (1.1.4)
21
+ hashie (>= 1.2, < 3)
22
+ rack
23
+ omniauth-oauth (1.0.1)
24
+ oauth
25
+ omniauth (~> 1.0)
26
+ rack (1.5.2)
27
+ rake (10.0.4)
28
+ rspec (2.13.0)
29
+ rspec-core (~> 2.13.0)
30
+ rspec-expectations (~> 2.13.0)
31
+ rspec-mocks (~> 2.13.0)
32
+ rspec-core (2.13.1)
33
+ rspec-expectations (2.13.0)
34
+ diff-lcs (>= 1.1.3, < 2.0)
35
+ rspec-mocks (2.13.1)
36
+ simplecov (0.7.1)
37
+ multi_json (~> 1.0)
38
+ simplecov-html (~> 0.7.1)
39
+ simplecov-html (0.7.1)
40
+ vcr (2.5.0)
41
+ webmock (1.11.0)
42
+ addressable (>= 2.2.7)
43
+ crack (>= 0.3.2)
44
+
45
+ PLATFORMS
46
+ ruby
47
+
48
+ DEPENDENCIES
49
+ omniauth-shapeways!
50
+ rake
51
+ rspec
52
+ simplecov
53
+ vcr
54
+ webmock
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 John Barton
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,58 @@
1
+ # OmniAuth Shapeways
2
+
3
+ This gem is an OmniAuth 1.0 Strategy for the [Shapeways API](http://developer.shapeways.com/)
4
+
5
+ It supports the Shapeways API which uses OAuth 1.0a.
6
+
7
+ ## Usage
8
+
9
+ Add the strategy to your `Gemfile` alongside OmniAuth:
10
+
11
+ ```ruby
12
+ gem 'omniauth'
13
+ gem 'omniauth-shapeways'
14
+ ```
15
+
16
+ Then integrate the strategy into your middleware:
17
+
18
+ ```ruby
19
+ use OmniAuth::Builder do
20
+ provider :shapeways, ENV['SHAPEWAYS_CONSUMER_TOKEN'], ENV['SHAPEWAYS_CONSUMER_SECRET']
21
+ end
22
+ ```
23
+
24
+ In Rails, add this to the middleware stack:
25
+
26
+ ```ruby
27
+ Rails.application.config.middleware.use OmniAuth::Builder do
28
+ provider :shapeways, ENV['SHAPEWAYS_CONSUMER_TOKEN'], ENV['SHAPEWAYS_CONSUMER_SECRET']
29
+ end
30
+ ```
31
+
32
+ You will have to put in your consumer key and secret.
33
+
34
+ For additional information, refer to the [OmniAuth wiki](https://github.com/intridea/omniauth/wiki).
35
+
36
+ ## <a name="build"></a>Build Status
37
+ [![Build Status](https://secure.travis-ci.org/phy5ics/omniauth-shapeways.png?branch=master)][travis]
38
+
39
+ [travis]: http://travis-ci.org/phy5ics/omniauth-shapeways
40
+
41
+ ## <a name="dependencies"></a>Dependency Status
42
+ [![Dependency Status](https://gemnasium.com/phy5ics/omniauth-shapeways.png?travis)][gemnasium]
43
+
44
+ [gemnasium]: https://gemnasium.com/phy5ics/omniauth-shapeways
45
+
46
+ ## Contributing
47
+
48
+ * Fork the project.
49
+ * Make your feature addition or bug fix.
50
+ * Add tests for it. This is important so I don't break it in a
51
+ future version unintentionally.
52
+ * Commit, do not mess with rakefile, version, or history.
53
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
54
+ * Send me a pull request. Bonus points for topic branches.
55
+
56
+ ## Copyright
57
+
58
+ Copyright (c) 2013 John Barton. See [LICENSE](https://github.com/phy5ics/omniauth-shapeways/blob/master/LICENSE.txt) for details.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :test => :spec
8
+ task :default => :spec
@@ -0,0 +1,2 @@
1
+ require 'omniauth-shapeways/version'
2
+ require 'omniauth/strategies/shapeways'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Shapeways
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,60 @@
1
+ require 'multi_json'
2
+ require 'omniauth-oauth'
3
+ require 'rack/utils'
4
+
5
+ module OmniAuth
6
+ module Strategies
7
+ class Shapeways < OmniAuth::Strategies::OAuth
8
+ option :name, 'shapeways'
9
+
10
+ option :client_options, {
11
+ :signature_method => 'HMAC-SHA1',
12
+ :site => 'http://api.shapeways.com',
13
+ :authorize_url => 'http://api.shapeways.com/login',
14
+ :request_token_url => 'http://api.shapeways.com/oauth1/request_token/v1',
15
+ :access_token_url => 'http://api.shapeways.com/oauth1/access_token/v1'
16
+ }
17
+
18
+ def request_phase
19
+ request_token = consumer.get_request_token(:oauth_callback => callback_url)
20
+
21
+ # Shapeways seems to have a way of providing the token that does not play nicely with the underlying oauth gem.
22
+ # I think that normally the token is provided in the body instead of as a query string parameter.
23
+ # As a result, we need parse it out of the query string provided by Shapeways:
24
+ q = Rack::Utils.parse_query URI(request_token.params['authentication_url']).query
25
+ request_token.token = q['oauth_token']
26
+
27
+ session['oauth'] ||= {}
28
+ session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => q['oauth_token'], 'request_secret' => request_token.secret}
29
+
30
+ if request_token.callback_confirmed?
31
+ redirect request_token.authorize_url(options[:authorize_params].merge(:oauth_consumer_key => consumer.key))
32
+ else
33
+ redirect request_token.authorize_url(options[:authorize_params].merge(:oauth_callback => callback_url, :oauth_consumer_key => consumer.key))
34
+ end
35
+
36
+ rescue ::Timeout::Error => e
37
+ fail!(:timeout, e)
38
+ rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e
39
+ fail!(:service_unavailable, e)
40
+ end
41
+
42
+ info do
43
+ {
44
+ :info => raw_info['info']
45
+ }
46
+ end
47
+
48
+ extra do
49
+ {
50
+ 'raw_info' => raw_info
51
+ }
52
+ end
53
+
54
+ def raw_info
55
+ @raw_info ||= MultiJson.decode(access_token.get('/api/v1/').body)
56
+ end
57
+
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth-shapeways/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "omniauth-shapeways"
8
+ gem.version = OmniAuth::Shapeways::VERSION
9
+ gem.authors = ["John Barton"]
10
+ gem.email = ["jb@phy5ics.com"]
11
+ gem.description = %q{Omniauth strategy for Shapeways.}
12
+ gem.summary = %q{Omniauth strategy for Shapeways.}
13
+ gem.homepage = "https://github.com/phy5ics/omniauth-shapeways"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'omniauth'
21
+ gem.add_dependency 'omniauth-oauth'
22
+ gem.add_dependency 'multi_json'
23
+ gem.add_dependency 'json'
24
+
25
+ gem.add_development_dependency 'rake'
26
+ gem.add_development_dependency 'rspec'
27
+ gem.add_development_dependency 'simplecov'
28
+ gem.add_development_dependency 'webmock'
29
+ gem.add_development_dependency 'vcr'
30
+
31
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Shapeways do
4
+ before :each do
5
+ @request = double('Request')
6
+ @request.stub(:params) { {} }
7
+ end
8
+
9
+ subject do
10
+ OmniAuth::Strategies::Shapeways.new(nil, @options || {}).tap do |strategy|
11
+ strategy.stub(:request) { @request }
12
+ end
13
+ end
14
+
15
+ describe '#client_options' do
16
+ it 'has correct Shapeways site' do
17
+ subject.options.client_options.site.should eq('http://api.shapeways.com')
18
+ end
19
+
20
+ it 'has correct authorize url' do
21
+ subject.options.client_options.authorize_url.should eq('http://api.shapeways.com/login')
22
+ end
23
+
24
+ it 'has correct request token url' do
25
+ subject.options.client_options.request_token_url.should eq('http://api.shapeways.com/oauth1/request_token/v1')
26
+ end
27
+
28
+ it 'has correct access token url' do
29
+ subject.options.client_options.access_token_url.should eq('http://api.shapeways.com/oauth1/access_token/v1')
30
+ end
31
+ end
32
+
33
+ describe '#request_phase' do
34
+ it 'should redirect to an authorization page on Shapeways' do
35
+ pending 'I have no idea how to implement this test properly'
36
+ end
37
+ end
38
+
39
+ describe '#info' do
40
+ before :each do
41
+ @raw_info ||= { 'info' => { 'result' => 'success', 'name' => 'nil'} }
42
+ subject.stub(:raw_info) { @raw_info }
43
+ end
44
+
45
+ context 'when data is present in the raw info' do
46
+ it 'returns the name' do
47
+ subject.info[:info]['name'].should eq('nil')
48
+ end
49
+
50
+ it 'returns the result' do
51
+ subject.info[:info]['result'].should eq('success')
52
+ end
53
+ end
54
+ end
55
+
56
+ describe '#extra' do
57
+ before :each do
58
+ @raw_info_hash = { "extra" => [] }
59
+ subject.stub(:raw_info) { @raw_info_hash }
60
+ end
61
+
62
+ it 'returns a Hash' do
63
+ subject.extra.should be_a(Hash)
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,13 @@
1
+ unless ENV['CI']
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_filter "/spec"
5
+ end
6
+ end
7
+
8
+ $:.unshift File.expand_path('..', __FILE__)
9
+ $:.unshift File.expand_path('../../lib', __FILE__)
10
+
11
+ require 'omniauth-shapeways'
12
+ require 'rspec'
13
+ require 'webmock/rspec'
metadata ADDED
@@ -0,0 +1,203 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-shapeways
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - John Barton
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: omniauth-oauth
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: multi_json
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: json
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rspec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: simplecov
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: webmock
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: vcr
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ description: Omniauth strategy for Shapeways.
159
+ email:
160
+ - jb@phy5ics.com
161
+ executables: []
162
+ extensions: []
163
+ extra_rdoc_files: []
164
+ files:
165
+ - .gitignore
166
+ - Gemfile
167
+ - Gemfile.lock
168
+ - LICENSE.txt
169
+ - README.md
170
+ - Rakefile
171
+ - lib/omniauth-shapeways.rb
172
+ - lib/omniauth-shapeways/version.rb
173
+ - lib/omniauth/strategies/shapeways.rb
174
+ - omniauth-shapeways.gemspec
175
+ - spec/omniauth/strategies/shapeways_spec.rb
176
+ - spec/spec_helper.rb
177
+ homepage: https://github.com/phy5ics/omniauth-shapeways
178
+ licenses: []
179
+ post_install_message:
180
+ rdoc_options: []
181
+ require_paths:
182
+ - lib
183
+ required_ruby_version: !ruby/object:Gem::Requirement
184
+ none: false
185
+ requirements:
186
+ - - ! '>='
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ required_rubygems_version: !ruby/object:Gem::Requirement
190
+ none: false
191
+ requirements:
192
+ - - ! '>='
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ requirements: []
196
+ rubyforge_project:
197
+ rubygems_version: 1.8.25
198
+ signing_key:
199
+ specification_version: 3
200
+ summary: Omniauth strategy for Shapeways.
201
+ test_files:
202
+ - spec/omniauth/strategies/shapeways_spec.rb
203
+ - spec/spec_helper.rb