omniauth-pavlok 0.1.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: 3e2ba90c098f52a226cadf86e03f15042f0a09c5
4
+ data.tar.gz: 84dfca5f4bfebb54088415d9fc5f6b0d887eea9a
5
+ SHA512:
6
+ metadata.gz: f40882c129a19ef3caac3c88842519a12aeb088d49cc7af55e996b4d09b2c772f0d12f363812323cc193e1dff70c5d51393ec84455436d4eda4948cc86200ac8
7
+ data.tar.gz: a0065f3ff62c94812e45ab860f1b7e8d8fc00c751c40e58fd78dad9c4c800b8a1a70f0e5918b80c08b290f5cba53df43fce67e41585b9beac312321be7166481
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-pavlok.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'guard'
8
+ gem 'guard-rspec'
9
+ gem 'guard-bundler'
10
+ gem 'rb-fsevent'
11
+ 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-pavlok.gemspec')
10
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Johnny Boursiquot
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.
@@ -0,0 +1,38 @@
1
+ # OmniAuth::Pavlok
2
+
3
+ This is the OmniAuth strategy provided by Pavlok to make building an
4
+ OAuth client for interacting with the Pavlok device easier.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'omniauth-pavlok'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ `$ bundle`
17
+
18
+ Or install it yourself as:
19
+
20
+ `$ gem install omniauth-pavlok`
21
+
22
+ ## Usage
23
+
24
+ ```ruby
25
+ use OmniAuth::Builder do
26
+ provider :pavlok, ENV['PAVLOK_KEY'], ENV['PAVLOK_SECRET']
27
+ end
28
+ ```
29
+
30
+ ## MIT License
31
+
32
+ Copyright (c) 2015 Pavlok
33
+
34
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
35
+
36
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
37
+
38
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -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-pavlok/version"
2
+ require 'omniauth/strategies/pavlok'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Pavlok
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,31 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Pavlok < OmniAuth::Strategies::OAuth2
6
+ option :name, :pavlok
7
+
8
+ option :client_options, {
9
+ :site => ENV['PAVLOK_SITE_URL'] || 'https://pavlok-mvp.herokuapp.com',
10
+ :authorize_url => ENV['PAVLOK_AUTH_URL'] || 'https://pavlok-mvp.herokuapp.com/oauth/authorize',
11
+ :token_url => ENV['PAVLOK_TOKEN_URL'] || 'https://pavlok-mvp.herokuapp.com/oauth/token'
12
+ }
13
+
14
+ uid { raw_info["id"] }
15
+
16
+ info do
17
+ { :email => raw_info["email"] }
18
+ end
19
+
20
+ def raw_info
21
+ @raw_info ||= access_token.get('/api/v1/me').parsed
22
+ rescue ::Errno::ETIMEDOUT
23
+ raise ::Timeout::Error
24
+ end
25
+
26
+ def email
27
+ raw_info['email']
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth-pavlok/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-pavlok"
8
+ spec.version = OmniAuth::Pavlok::VERSION
9
+ spec.authors = ["Pavlok"]
10
+ spec.email = ["team@pavlok.com"]
11
+ spec.summary = %q{Pavlok OmniAuth strategy}
12
+ spec.description = %q{Pavlok OmniAuth strategy to make Ruby/Rails OmniAuth clients easier to implement.}
13
+ spec.homepage = "http://pavlok.com"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'omniauth', '~> 1.0'
22
+ spec.add_dependency 'omniauth-oauth2', '>= 1.1.1', '< 2.0'
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency 'rspec', '~> 2.99'
27
+ spec.add_development_dependency 'rack-test', '~> 0.6'
28
+ spec.add_development_dependency 'simplecov', '~> 0.10'
29
+ spec.add_development_dependency 'webmock', '~> 1.21'
30
+ end
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Pavlok do
4
+ let(:access_token) { double('AccessToken', :options => {}) }
5
+ let(:parsed_response) { double('ParsedResponse') }
6
+ let(:response) { double('Response', :parsed => parsed_response) }
7
+
8
+ let(:site) { 'https://some.other.site.com/api/v1' }
9
+ let(:authorize_url) { 'https://some.other.site.com/oauth/authorize' }
10
+ let(:token_url) { 'https://some.other.site.com/oauth/token' }
11
+ let(:pavlok) do
12
+ OmniAuth::Strategies::Pavlok.new('PAVLOK_KEY', 'PAVLOK_SECRET',
13
+ {
14
+ :client_options => {
15
+ :site => site,
16
+ :authorize_url => authorize_url,
17
+ :token_url => token_url
18
+ }
19
+ }
20
+ )
21
+ end
22
+
23
+ subject do
24
+ OmniAuth::Strategies::Pavlok.new({})
25
+ end
26
+
27
+ before(:each) do
28
+ allow(subject).to receive(:access_token).and_return(access_token)
29
+ end
30
+
31
+ context "client options" do
32
+ it 'should have correct site' do
33
+ subject.options.client_options.site.should eq("https://pavlok-mvp.herokuapp.com")
34
+ end
35
+
36
+ it 'should have correct authorize url' do
37
+ subject.options.client_options.authorize_url.should eq('https://pavlok-mvp.herokuapp.com/oauth/authorize')
38
+ end
39
+
40
+ it 'should have correct token url' do
41
+ subject.options.client_options.token_url.should eq('https://pavlok-mvp.herokuapp.com/oauth/token')
42
+ end
43
+
44
+ describe "should be overrideable" do
45
+ it "for site" do
46
+ pavlok.options.client_options.site.should eq(site)
47
+ end
48
+
49
+ it "for authorize url" do
50
+ pavlok.options.client_options.authorize_url.should eq(authorize_url)
51
+ end
52
+
53
+ it "for token url" do
54
+ pavlok.options.client_options.token_url.should eq(token_url)
55
+ end
56
+ end
57
+ end
58
+
59
+ context "info" do
60
+ it "should return email from raw_info if available" do
61
+ expect(subject).to receive(:raw_info).and_return({'email' => 'you@example.com'})
62
+ subject.email.should eq('you@example.com')
63
+ end
64
+
65
+ it "should return nil if there is no raw_info and email access is not allowed" do
66
+ expect(subject).to receive(:raw_info).and_return({})
67
+ subject.email.should be_nil
68
+ end
69
+ end
70
+
71
+ context "client timeout" do
72
+ it "should raise Timeout::Error if it fails to connect with site" do
73
+ allow(access_token).to receive(:get).and_raise(::Errno::ETIMEDOUT)
74
+ expect{subject.email}.to raise_error ::Timeout::Error
75
+ end
76
+ end
77
+
78
+ end
@@ -0,0 +1,17 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+
4
+ require 'simplecov'
5
+ SimpleCov.start
6
+
7
+ require 'rspec'
8
+ require 'rack/test'
9
+ require 'webmock/rspec'
10
+ require 'omniauth'
11
+ require 'omniauth-pavlok'
12
+
13
+ RSpec.configure do |config|
14
+ config.include WebMock::API
15
+ config.include Rack::Test::Methods
16
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
17
+ end
metadata ADDED
@@ -0,0 +1,179 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-pavlok
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Pavlok
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-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.1
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '2.0'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.1.1
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.7'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.7'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '10.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '10.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '2.99'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '2.99'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rack-test
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '0.6'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '0.6'
103
+ - !ruby/object:Gem::Dependency
104
+ name: simplecov
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '0.10'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '0.10'
117
+ - !ruby/object:Gem::Dependency
118
+ name: webmock
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '1.21'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '1.21'
131
+ description: Pavlok OmniAuth strategy to make Ruby/Rails OmniAuth clients easier to
132
+ implement.
133
+ email:
134
+ - team@pavlok.com
135
+ executables: []
136
+ extensions: []
137
+ extra_rdoc_files: []
138
+ files:
139
+ - ".gitignore"
140
+ - ".rspec"
141
+ - Gemfile
142
+ - Guardfile
143
+ - LICENSE.txt
144
+ - README.md
145
+ - Rakefile
146
+ - lib/omniauth-pavlok.rb
147
+ - lib/omniauth-pavlok/version.rb
148
+ - lib/omniauth/strategies/pavlok.rb
149
+ - omniauth-pavlok.gemspec
150
+ - spec/omniauth/strategies/pavlok_spec.rb
151
+ - spec/spec_helper.rb
152
+ homepage: http://pavlok.com
153
+ licenses:
154
+ - MIT
155
+ metadata: {}
156
+ post_install_message:
157
+ rdoc_options: []
158
+ require_paths:
159
+ - lib
160
+ required_ruby_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ requirements: []
171
+ rubyforge_project:
172
+ rubygems_version: 2.2.2
173
+ signing_key:
174
+ specification_version: 4
175
+ summary: Pavlok OmniAuth strategy
176
+ test_files:
177
+ - spec/omniauth/strategies/pavlok_spec.rb
178
+ - spec/spec_helper.rb
179
+ has_rdoc: