omniauth-signnow 0.5.0

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: 7a37c1eef09087180fed82d643241ae5cc961a28
4
+ data.tar.gz: 0ecf07e019ec47656c71a36c015d755b88fa1808
5
+ SHA512:
6
+ metadata.gz: 707645d365fb1760bd0ee0ca1cbbf66373b8e8ee78abd6a7a1e075b6347fa8cf07c0a4094ad31cff4696374b69797a4a05c31056d767cff311ada1e99b28f1ff
7
+ data.tar.gz: db1d0716d7367dae52ddecff3631ac9c3bc889ddaccc3f1bd3aedda9bfa3edcb5320daf296e3e0bddcf00a379bb76de726d74f6e4a93ac533f8810dc02eb9b51
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ InstalledFiles
7
+ _yardoc
8
+ coverage
9
+ doc/
10
+ lib/bundler/man
11
+ /pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-copy.gemspec
4
+ gemspec
5
+
6
+ gem 'rake'
7
+ gem 'coveralls', require: false
8
+ gem 'rspec'
9
+
10
+ group :development, :test do
11
+ gem 'guard'
12
+ gem 'guard-rspec'
13
+ gem 'guard-bundler'
14
+ gem 'rb-fsevent'
15
+ gem 'growl'
16
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,114 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-signnow (0.5.0)
5
+ omniauth (~> 1.0)
6
+ omniauth-oauth2 (~> 1.1.1)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ addressable (2.3.4)
12
+ coderay (1.0.9)
13
+ coveralls (0.7.0)
14
+ multi_json (~> 1.3)
15
+ rest-client
16
+ simplecov (>= 0.7)
17
+ term-ansicolor
18
+ thor
19
+ crack (0.3.2)
20
+ diff-lcs (1.2.4)
21
+ faraday (0.8.9)
22
+ multipart-post (~> 1.2.0)
23
+ ffi (1.8.1)
24
+ formatador (0.2.4)
25
+ growl (1.0.3)
26
+ guard (1.8.0)
27
+ formatador (>= 0.2.4)
28
+ listen (>= 1.0.0)
29
+ lumberjack (>= 1.0.2)
30
+ pry (>= 0.9.10)
31
+ thor (>= 0.14.6)
32
+ guard-bundler (1.0.0)
33
+ bundler (~> 1.0)
34
+ guard (~> 1.1)
35
+ guard-rspec (2.6.0)
36
+ guard (>= 1.8)
37
+ rspec (~> 2.13)
38
+ hashie (2.0.5)
39
+ httpauth (0.2.0)
40
+ jwt (0.1.8)
41
+ multi_json (>= 1.5)
42
+ listen (1.0.3)
43
+ rb-fsevent (>= 0.9.3)
44
+ rb-inotify (>= 0.9)
45
+ rb-kqueue (>= 0.2)
46
+ lumberjack (1.0.3)
47
+ method_source (0.8.1)
48
+ mime-types (2.0)
49
+ multi_json (1.7.2)
50
+ multipart-post (1.2.0)
51
+ oauth2 (0.8.1)
52
+ faraday (~> 0.8)
53
+ httpauth (~> 0.1)
54
+ jwt (~> 0.1.4)
55
+ multi_json (~> 1.0)
56
+ rack (~> 1.2)
57
+ omniauth (1.1.4)
58
+ hashie (>= 1.2, < 3)
59
+ rack
60
+ omniauth-oauth2 (1.1.1)
61
+ oauth2 (~> 0.8.0)
62
+ omniauth (~> 1.0)
63
+ pry (0.9.12.1)
64
+ coderay (~> 1.0.5)
65
+ method_source (~> 0.8)
66
+ slop (~> 3.4)
67
+ rack (1.5.2)
68
+ rack-test (0.6.2)
69
+ rack (>= 1.0)
70
+ rake (0.9.6)
71
+ rb-fsevent (0.9.3)
72
+ rb-inotify (0.9.0)
73
+ ffi (>= 0.5.0)
74
+ rb-kqueue (0.2.0)
75
+ ffi (>= 0.5.0)
76
+ rest-client (1.6.7)
77
+ mime-types (>= 1.16)
78
+ rspec (2.13.0)
79
+ rspec-core (~> 2.13.0)
80
+ rspec-expectations (~> 2.13.0)
81
+ rspec-mocks (~> 2.13.0)
82
+ rspec-core (2.13.1)
83
+ rspec-expectations (2.13.0)
84
+ diff-lcs (>= 1.1.3, < 2.0)
85
+ rspec-mocks (2.13.1)
86
+ simplecov (0.7.1)
87
+ multi_json (~> 1.0)
88
+ simplecov-html (~> 0.7.1)
89
+ simplecov-html (0.7.1)
90
+ slop (3.4.4)
91
+ term-ansicolor (1.2.2)
92
+ tins (~> 0.8)
93
+ thor (0.18.1)
94
+ tins (0.13.1)
95
+ webmock (1.11.0)
96
+ addressable (>= 2.2.7)
97
+ crack (>= 0.3.2)
98
+
99
+ PLATFORMS
100
+ ruby
101
+
102
+ DEPENDENCIES
103
+ coveralls
104
+ growl
105
+ guard
106
+ guard-bundler
107
+ guard-rspec
108
+ omniauth-signnow!
109
+ rack-test
110
+ rake
111
+ rb-fsevent
112
+ rspec
113
+ simplecov
114
+ webmock
data/Guardfile ADDED
@@ -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-signnow.gemspec')
10
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2012 Andres Bravo
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 NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # OmniAuth Signow.com
2
+
3
+ [![Build Status](https://travis-ci.org/andresbravog/omniauth-signnow.png)](https://travis-ci.org/andresbravog/omniauth-signnow) [![Coverage Status](https://coveralls.io/repos/andresbravog/omniauth-signnow/badge.png?branch=master)](https://coveralls.io/r/andresbravog/omniauth-signnow?branch=master)
4
+
5
+ An unofficial OmniAuth strategy for authenticating to Signnow.com using OAuth2. To use it, you'll
6
+ need to have a Signow.com [developer account](https://www.signow.com/developer).
7
+
8
+ ## Installation
9
+
10
+ Add to your `Gemfile`:
11
+
12
+ ```ruby
13
+ gem "omniauth-signnow"
14
+ ```
15
+
16
+ Then `bundle install`.
17
+
18
+ ## Usage
19
+
20
+ Here's an example for adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
21
+
22
+ ```ruby
23
+ Rails.application.config.middleware.use OmniAuth::Builder do
24
+ provider :signnow, ENV['SIGNNOW_APP_KEY'], ENV['SIGNNOW_APP_SECRET']
25
+ end
26
+ ```
27
+
28
+ You can now access the OmniAuth Google OAuth2 URL: `/auth/signnow`
data/Rakefile ADDED
@@ -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-signnow/version'
2
+ require 'omniauth/strategies/signnow'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Signnow
3
+ VERSION = '0.5.0'
4
+ end
5
+ end
@@ -0,0 +1,64 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Signnow < OmniAuth::Strategies::OAuth2
6
+ # Give your strategy a name.
7
+ option :name, "signnow"
8
+
9
+ option :provider_ignores_state, true
10
+
11
+ # This is where you pass the options you would pass when
12
+ # initializing your consumer from the OAuth gem.
13
+ option :client_options, {
14
+ site: 'https://api.signnow.com/api',
15
+ authorize_url: 'https://www.signnow.com/proxy/index.php/authorize',
16
+ token_url: 'https://api.signnow.com/api/oauth2/token'
17
+ }
18
+
19
+ option :authorize_params, {
20
+ response_type: 'code'
21
+ }
22
+
23
+ # These are called after authentication has succeeded. If
24
+ # possible, you should try to set the UID without making
25
+ # additional calls (if the user id is returned with the token
26
+ # or as a URI parameter). This may not be possible with all
27
+ # providers.
28
+ uid{ raw_info['id'] }
29
+
30
+ info do
31
+ {
32
+ :name => [ raw_info['first_name'], raw_info['last_name'] ].join(' '),
33
+ :email => (raw_info['emails'] || []).first
34
+ }
35
+ end
36
+
37
+ extra do
38
+ {
39
+ 'raw_info' => raw_info
40
+ }
41
+ end
42
+
43
+ def raw_info
44
+ @raw_info ||= access_token.get('https://api.signnow.com/api/user').parsed
45
+ end
46
+
47
+ def build_access_token
48
+ verifier = request.params['code']
49
+ new_params = { :redirect_uri => callback_url }.merge(auth_options)
50
+ params = new_params.merge(token_params.to_hash(:symbolize_keys => true))
51
+ opts = deep_symbolize(options.auth_token_params || {})
52
+ client.auth_code.get_token(verifier, params, opts)
53
+ end
54
+
55
+ def auth_options
56
+ {
57
+ :headers => {
58
+ 'Authorization' => "Basic #{Base64.encode64(client.id+':'+client.secret).gsub(/[\n=]/,'')}"
59
+ }
60
+ }
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,23 @@
1
+ require File.expand_path('../lib/omniauth-signnow/version', __FILE__)
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.authors = ["Andres Bravo"]
5
+ gem.email = ["hola@andresbravo.com"]
6
+ gem.description = %q{Unofficial OmniAuth strategy for Signnow.com.}
7
+ gem.summary = gem.description
8
+ gem.homepage = "https://github.com/andresbravog/omniauth-signnow"
9
+
10
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
11
+ gem.files = `git ls-files`.split("\n")
12
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
+ gem.name = "omniauth-signnow"
14
+ gem.require_paths = ["lib"]
15
+ gem.version = OmniAuth::Signnow::VERSION
16
+
17
+ gem.add_dependency 'omniauth', '~> 1.0'
18
+ gem.add_dependency 'omniauth-oauth2', '~> 1.1.1'
19
+ gem.add_development_dependency 'rspec', '~> 2.7'
20
+ gem.add_development_dependency 'rack-test'
21
+ gem.add_development_dependency 'simplecov'
22
+ gem.add_development_dependency 'webmock'
23
+ end
@@ -0,0 +1,118 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Signnow do
4
+ let(:app) do
5
+ lambda do |env|
6
+ [200, {}, ["Hello."]]
7
+ end
8
+ end
9
+ let(:request) { double('Request', :params => {}, :cookies => {}, :env => {}) }
10
+ let(:fresh_strategy){ Class.new(OmniAuth::Strategies::Signnow) }
11
+
12
+ let(:signnow_strategy) do
13
+ fresh_strategy.new(app, '_your_app_id_', '_your_app_secret_', @options || {}).tap do |strategy|
14
+ strategy.stub(:request) {
15
+ request
16
+ }
17
+ end
18
+ end
19
+
20
+ subject { signnow_strategy }
21
+
22
+ before do
23
+ OmniAuth.config.test_mode = true
24
+ end
25
+
26
+ after do
27
+ OmniAuth.config.test_mode = false
28
+ end
29
+
30
+ describe '#client_options' do
31
+
32
+ it 'should be initialized with correct authorize url' do
33
+ expect(subject.client.options[:authorize_url]).to eql 'https://www.signnow.com/proxy/index.php/authorize'
34
+ end
35
+
36
+ it 'should be initialized with correct token url' do
37
+ expect(subject.client.options[:token_url]).to eql 'https://api.signnow.com/api/oauth2/token'
38
+ end
39
+
40
+ describe "overrides" do
41
+ it 'should allow overriding the site' do
42
+ @options = {:client_options => {'site' => 'https://example.com'}}
43
+ subject.client.site.should == 'https://example.com'
44
+ end
45
+
46
+ it 'should allow overriding the authorize_url' do
47
+ @options = {:client_options => {'authorize_url' => 'https://example.com'}}
48
+ subject.client.options[:authorize_url].should == 'https://example.com'
49
+ end
50
+
51
+ it 'should allow overriding the token_url' do
52
+ @options = {:client_options => {'token_url' => 'https://example.com'}}
53
+ subject.client.options[:token_url].should == 'https://example.com'
54
+ end
55
+ end
56
+ end
57
+
58
+ describe '#authorize_params' do
59
+
60
+ it 'should include any authorize params passed in the :authorize_params option' do
61
+ @options = {:authorize_params => {:request_visible_actions => 'something', :foo => 'bar', :baz => 'zip'}, :bad => 'not_included'}
62
+ subject.authorize_params['request_visible_actions'].should eq('something')
63
+ subject.authorize_params['foo'].should eq('bar')
64
+ subject.authorize_params['baz'].should eq('zip')
65
+ subject.authorize_params['bad'].should eq(nil)
66
+ end
67
+
68
+ it 'should include :response_type option' do
69
+ expect(subject.authorize_params).to include('response_type')
70
+ expect(subject.authorize_params['response_type']).to eql('code')
71
+ end
72
+
73
+ it 'should include random state in the authorize params' do
74
+ expect(subject.authorize_params).to include('state')
75
+ subject.session['omniauth.state'].should_not be_empty
76
+ end
77
+ end
78
+
79
+ describe '#token_params' do
80
+ it 'should include any token params passed in the :token_params option' do
81
+ @options = {:token_params => {:foo => 'bar', :baz => 'zip'}}
82
+ subject.token_params['foo'].should eq('bar')
83
+ subject.token_params['baz'].should eq('zip')
84
+ end
85
+ end
86
+
87
+ describe "#token_options" do
88
+ it 'should include top-level options that are marked as :token_options' do
89
+ @options = {:token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz', :bad => 'not_included'}
90
+ subject.token_params['scope'].should eq('bar')
91
+ subject.token_params['foo'].should eq('baz')
92
+ subject.token_params['bad'].should eq(nil)
93
+ end
94
+ end
95
+
96
+ describe '#callback_path' do
97
+ it 'has the correct callback path' do
98
+ subject.callback_path.should eq('/auth/signnow/callback')
99
+ end
100
+ end
101
+
102
+ describe '#auth_options' do
103
+ let(:base64_client_key) {
104
+ Base64.encode64(subject.client.id + ':' + subject.client.secret).gsub(/[\n=]/,'')
105
+ }
106
+ it 'is protected' do
107
+ expect(subject.auth_options).to raise_error(NoMethodError)
108
+ end
109
+ it 'returns a hash with the Autorization header' do
110
+ expect(subject.send(:auth_options).class).to eql(Hash)
111
+ expect(subject.send(:auth_options)).to include(:headers)
112
+ expect(subject.send(:auth_options)[:headers]).to include('Authorization')
113
+ expect(subject.send(:auth_options)[:headers]['Authorization']).to match(/Basic/)
114
+ expect(subject.send(:auth_options)[:headers]['Authorization']).to match(/#{base64_client_key}/)
115
+ end
116
+ end
117
+
118
+ end
@@ -0,0 +1,17 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ require 'coveralls'
6
+ Coveralls.wear!
7
+ require 'rspec'
8
+ require 'rack/test'
9
+ require 'webmock/rspec'
10
+ require 'omniauth'
11
+ require 'omniauth-signnow'
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,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-signnow
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - Andres Bravo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-13 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
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.1.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
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: rack-test
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: simplecov
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: webmock
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
+ description: Unofficial OmniAuth strategy for Signnow.com.
98
+ email:
99
+ - hola@andresbravo.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - .travis.yml
106
+ - Gemfile
107
+ - Gemfile.lock
108
+ - Guardfile
109
+ - LICENSE
110
+ - README.md
111
+ - Rakefile
112
+ - lib/omniauth-signnow.rb
113
+ - lib/omniauth-signnow/version.rb
114
+ - lib/omniauth/strategies/signnow.rb
115
+ - omniauth-signnow.gemspec
116
+ - spec/omniauth/strategies/signnow_spec.rb
117
+ - spec/spec_helper.rb
118
+ homepage: https://github.com/andresbravog/omniauth-signnow
119
+ licenses: []
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.2.0
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: Unofficial OmniAuth strategy for Signnow.com.
141
+ test_files:
142
+ - spec/omniauth/strategies/signnow_spec.rb
143
+ - spec/spec_helper.rb