omniauth-venmo 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/Gemfile +2 -0
- data/Guardfile +10 -0
- data/Rakefile +9 -0
- data/lib/omniauth-venmo.rb +2 -0
- data/lib/omniauth/strategies/venmo.rb +65 -0
- data/lib/omniauth/venmo/version.rb +5 -0
- data/omniauth-venmo.gemspec +27 -0
- data/spec/app.rb +49 -0
- data/spec/omniauth/strategies/venmo_spec.rb +66 -0
- data/spec/spec_helper.rb +13 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 60bdfd003b5d583bfadcb37f10841a063cc7ddf2
|
4
|
+
data.tar.gz: ab3676ea93ee823dcfe07e623f4d6506cd343755
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cf9bd0ae7115a489990b7698fc69c0d510da4af43bdd0494159338f9881c770fff0428464c6b1384d22f54c7c2e46056b6a2606810648358744df744250a69ae
|
7
|
+
data.tar.gz: 6b983c319373e6c23acd31898f7cb39daaaea3176967012ea8baec625ee86a01b2407645d42d4ea5ebecfd4eb88b8c37b8db86ae75fd4f77420fdd90b097e87f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
# access_feed, access_profile, access_friends, make_payments
|
4
|
+
|
5
|
+
module OmniAuth
|
6
|
+
module Strategies
|
7
|
+
class Venmo < OmniAuth::Strategies::OAuth2
|
8
|
+
DEFAULT_SCOPE = 'access_profile'
|
9
|
+
|
10
|
+
option :provider_ignores_state, true
|
11
|
+
option :client_options, {
|
12
|
+
:site => 'https://api.venmo.com',
|
13
|
+
:authorize_url => '/oauth/authorize',
|
14
|
+
:token_url => '/oauth/access_token'
|
15
|
+
}
|
16
|
+
|
17
|
+
uid { raw_info['id'] }
|
18
|
+
|
19
|
+
info do
|
20
|
+
prune!({
|
21
|
+
'username' => raw_info['username'],
|
22
|
+
'email' => raw_info['email'],
|
23
|
+
'phone' => raw_info['phone'],
|
24
|
+
'name' => raw_info['name'],
|
25
|
+
'first_name' => raw_info['first_name'],
|
26
|
+
'last_name' => raw_info['last_name'],
|
27
|
+
'image' => raw_info['picture'],
|
28
|
+
'balance' => raw_info['balance'],
|
29
|
+
'urls' => {
|
30
|
+
'profile' => nil # TODO: Fill in when Venmo is back online.
|
31
|
+
}
|
32
|
+
})
|
33
|
+
end
|
34
|
+
|
35
|
+
extra do
|
36
|
+
hash = {}
|
37
|
+
hash['raw_info'] = raw_info unless skip_info?
|
38
|
+
prune! hash
|
39
|
+
end
|
40
|
+
|
41
|
+
def raw_info
|
42
|
+
@raw_info ||= access_token.params['user'] || {}
|
43
|
+
end
|
44
|
+
|
45
|
+
def request_phase
|
46
|
+
options[:authorize_params] = {
|
47
|
+
:client_id => options['client_id'],
|
48
|
+
:response_type => 'code',
|
49
|
+
:scope => (options['scope'] || DEFAULT_SCOPE)
|
50
|
+
}
|
51
|
+
|
52
|
+
super
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def prune!(hash)
|
58
|
+
hash.delete_if do |_, value|
|
59
|
+
prune!(value) if value.is_a?(Hash)
|
60
|
+
value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'omniauth/venmo/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'omniauth-venmo'
|
7
|
+
s.version = OmniAuth::Venmo::VERSION
|
8
|
+
s.authors = ['Tom Milewski']
|
9
|
+
s.email = ['tmilewski@gmail.com']
|
10
|
+
s.summary = 'Venmo strategy for OmniAuth'
|
11
|
+
s.homepage = 'https://github.com/tmilewski/omniauth-venmo'
|
12
|
+
s.license = 'MIT'
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
17
|
+
s.require_paths = ['lib']
|
18
|
+
|
19
|
+
s.add_runtime_dependency 'omniauth'
|
20
|
+
s.add_runtime_dependency 'omniauth-oauth2', '~> 1.1'
|
21
|
+
|
22
|
+
s.add_development_dependency 'dotenv'
|
23
|
+
s.add_development_dependency 'sinatra'
|
24
|
+
s.add_development_dependency 'rake'
|
25
|
+
s.add_development_dependency 'rspec', '~> 2.7'
|
26
|
+
s.add_development_dependency 'simplecov'
|
27
|
+
end
|
data/spec/app.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'dotenv'
|
5
|
+
require 'sinatra'
|
6
|
+
require 'omniauth'
|
7
|
+
require 'omniauth-venmo'
|
8
|
+
|
9
|
+
Dotenv.load
|
10
|
+
|
11
|
+
use Rack::Session::Cookie, key: 'key',
|
12
|
+
domain: "localhost",
|
13
|
+
path: '/',
|
14
|
+
expire_after: 14400,
|
15
|
+
secret: 'secret'
|
16
|
+
|
17
|
+
use OmniAuth::Builder do
|
18
|
+
provider :venmo, ENV['CLIENT_ID'], ENV['CLIENT_SECRET'], :scope => 'access_profile'
|
19
|
+
end
|
20
|
+
|
21
|
+
get '/' do
|
22
|
+
<<-HTML
|
23
|
+
<a href='/auth/venmo'>Sign in with Venmo</a>
|
24
|
+
HTML
|
25
|
+
end
|
26
|
+
|
27
|
+
get '/auth/failure' do
|
28
|
+
env['omniauth.error'].to_s
|
29
|
+
end
|
30
|
+
|
31
|
+
get '/auth/:name/callback' do
|
32
|
+
auth = request.env['omniauth.auth']
|
33
|
+
|
34
|
+
puts %Q{
|
35
|
+
>> UID
|
36
|
+
#{auth.uid.inspect}
|
37
|
+
|
38
|
+
>> ACCESS TOKEN
|
39
|
+
#{auth.credentials.token.inspect}
|
40
|
+
|
41
|
+
>> INFO
|
42
|
+
#{auth.info.inspect}
|
43
|
+
#
|
44
|
+
>> EXTRA
|
45
|
+
#{auth.extra.inspect}
|
46
|
+
}
|
47
|
+
|
48
|
+
"Check logs for user information."
|
49
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Venmo do
|
4
|
+
subject do
|
5
|
+
@subject ||= begin
|
6
|
+
args = ['client_id', 'client_secret', @options || {}].compact
|
7
|
+
OmniAuth::Strategies::Venmo.new(*args)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context "client options" do
|
12
|
+
it 'should have correct name' do
|
13
|
+
expect(subject.options.name).to eq("venmo")
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should have correct site' do
|
17
|
+
expect(subject.options.client_options.site).to eq('https://api.venmo.com')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should have correct authorize url' do
|
21
|
+
expect(subject.options.client_options.authorize_url).to eq('/oauth/authorize')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should have correct access token url' do
|
25
|
+
expect(subject.options.client_options.token_url).to eq('/oauth/access_token')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should indicate that the provider ignores the state parameted' do
|
29
|
+
expect(subject.options.provider_ignores_state).to be_true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "#prune!" do
|
34
|
+
it "should remove nil values" do
|
35
|
+
expect(
|
36
|
+
subject.send(:prune!, { "a" => "b", "c" => nil })
|
37
|
+
).to eq({ "a" => "b" })
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should remove empty values" do
|
41
|
+
expect(
|
42
|
+
subject.send(:prune!, { "a" => "b", "c" => "" })
|
43
|
+
).to eq({ "a" => "b" })
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should remove nil values recursively" do
|
47
|
+
expect(
|
48
|
+
subject.send(:prune!, { "a" => "b", "c" => { "d" => nil} })
|
49
|
+
).to eq({ "a" => "b" })
|
50
|
+
|
51
|
+
expect(
|
52
|
+
subject.send(:prune!, { "a" => "b", "c" => { "d" => nil, "e" => "f"} })
|
53
|
+
).to eq({ "a" => "b", "c" => {"e" => "f"} })
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should remove empty values recursively" do
|
57
|
+
expect(
|
58
|
+
subject.send(:prune!, { "a" => "b", "c" => { "d" => ""} })
|
59
|
+
).to eq({ "a" => "b" })
|
60
|
+
|
61
|
+
expect(
|
62
|
+
subject.send(:prune!, { "a" => "b", "c" => { "d" => "", "e" => "f"} })
|
63
|
+
).to eq({ "a" => "b", "c" => {"e" => "f"} })
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'rspec'
|
5
|
+
require 'simplecov'
|
6
|
+
SimpleCov.start
|
7
|
+
|
8
|
+
require 'omniauth'
|
9
|
+
require 'omniauth-venmo'
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-venmo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tom Milewski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-09 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: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '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: dotenv
|
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: sinatra
|
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: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.7'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.7'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
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
|
+
- tmilewski@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- Gemfile
|
120
|
+
- Guardfile
|
121
|
+
- Rakefile
|
122
|
+
- lib/omniauth-venmo.rb
|
123
|
+
- lib/omniauth/strategies/venmo.rb
|
124
|
+
- lib/omniauth/venmo/version.rb
|
125
|
+
- omniauth-venmo.gemspec
|
126
|
+
- spec/app.rb
|
127
|
+
- spec/omniauth/strategies/venmo_spec.rb
|
128
|
+
- spec/spec_helper.rb
|
129
|
+
homepage: https://github.com/tmilewski/omniauth-venmo
|
130
|
+
licenses:
|
131
|
+
- MIT
|
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.3
|
150
|
+
signing_key:
|
151
|
+
specification_version: 4
|
152
|
+
summary: Venmo strategy for OmniAuth
|
153
|
+
test_files:
|
154
|
+
- spec/app.rb
|
155
|
+
- spec/omniauth/strategies/venmo_spec.rb
|
156
|
+
- spec/spec_helper.rb
|
157
|
+
has_rdoc:
|