omniauth-paypal-oauth2 1.4.11 → 1.4.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +7 -2
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/examples/shared_examples.rb +5 -5
- data/lib/omniauth/paypal_oauth2/version.rb +2 -2
- data/lib/omniauth/strategies/paypal_oauth2.rb +12 -17
- data/omniauth-paypal-oauth2.gemspec +5 -5
- data/spec/omniauth/strategies/paypal_oauth2_spec.rb +7 -7
- data/spec/spec_helper.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8db4d3f029030ed80f716e5750974921ffedf5d
|
4
|
+
data.tar.gz: e4975e1847d5ed314642996d903f0ee7743dcea9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8f3d346ceb1553f5817af559b776d5405a566b77dd417d2c4b9a476acf7cbca83cf3d6e1b2325de4acea32a47d9229c4acd0798bb0ee84751476aa15a90b3e4
|
7
|
+
data.tar.gz: 28cfba0158c0989c1f6015709e957ffd196923ce4e488476135323ebfed22e0905d1a336a3b0f28c64bf2719999c58fdb694541375cf1d14db470ab5d6c5e9f8
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -44,7 +44,7 @@ Here's an example for adding the middleware to a Rails app in `config/initialize
|
|
44
44
|
|
45
45
|
```ruby
|
46
46
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
47
|
-
provider :paypal_oauth2, ENV["PAYPAL_CLIENT_ID"], ENV["PAYPAL_CLIENT_SECRET"]
|
47
|
+
provider :paypal_oauth2, ENV["PAYPAL_CLIENT_ID"], ENV["PAYPAL_CLIENT_SECRET"]
|
48
48
|
end
|
49
49
|
```
|
50
50
|
|
@@ -138,7 +138,7 @@ Configuration options can be passed as the last parameter here as key/value pair
|
|
138
138
|
|
139
139
|
```ruby
|
140
140
|
require "omniauth-paypal-oauth2"
|
141
|
-
config.omniauth :paypal_oauth2, "PAYPAL_CLIENT_ID", "PAYPAL_CLIENT_SECRET",
|
141
|
+
config.omniauth :paypal_oauth2, "PAYPAL_CLIENT_ID", "PAYPAL_CLIENT_SECRET", { }
|
142
142
|
```
|
143
143
|
|
144
144
|
Then add the following to 'config/routes.rb' so the callback routes are defined.
|
data/Rakefile
CHANGED
data/examples/shared_examples.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
shared_examples 'an oauth2 strategy' do
|
2
2
|
describe '#client' do
|
3
3
|
it 'should be initialized with symbolized client_options' do
|
4
|
-
@options = { :
|
4
|
+
@options = { client_options: { 'authorize_url' => 'https://example.com' } }
|
5
5
|
expect(subject.client.options[:authorize_url]).to eq('https://example.com')
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
9
|
describe '#authorize_params' do
|
10
10
|
it 'should include any authorize params passed in the :authorize_params option' do
|
11
|
-
@options = { :
|
11
|
+
@options = { authorize_params: { foo: 'bar', baz: 'zip' } }
|
12
12
|
expect(subject.authorize_params['foo']).to eq('bar')
|
13
13
|
expect(subject.authorize_params['baz']).to eq('zip')
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should include top-level options that are marked as :authorize_options' do
|
17
|
-
@options = { :
|
17
|
+
@options = { authorize_options: [:scope, :foo], scope: 'bar', foo: 'baz' }
|
18
18
|
expect(subject.authorize_params['scope']).to eq('bar')
|
19
19
|
expect(subject.authorize_params['foo']).to eq('baz')
|
20
20
|
end
|
@@ -22,13 +22,13 @@ shared_examples 'an oauth2 strategy' do
|
|
22
22
|
|
23
23
|
describe '#token_params' do
|
24
24
|
it 'should include any token params passed in the :token_params option' do
|
25
|
-
@options = { :
|
25
|
+
@options = { token_params: { foo: 'bar', baz: 'zip' } }
|
26
26
|
expect(subject.token_params['foo']).to eq('bar')
|
27
27
|
expect(subject.token_params['baz']).to eq('zip')
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'should include top-level options that are marked as :token_options' do
|
31
|
-
@options = { :
|
31
|
+
@options = { token_options: [:scope, :foo], scope: 'bar', foo: 'baz' }
|
32
32
|
expect(subject.token_params['scope']).to eq('bar')
|
33
33
|
expect(subject.token_params['foo']).to eq('baz')
|
34
34
|
end
|
@@ -2,26 +2,26 @@ require 'omniauth-oauth2'
|
|
2
2
|
|
3
3
|
module OmniAuth
|
4
4
|
module Strategies
|
5
|
-
class
|
6
|
-
DEFAULT_SCOPE =
|
7
|
-
DEFAULT_RESPONSE_TYPE =
|
8
|
-
SANDBOX_SITE =
|
5
|
+
class PaypalOauth2 < OmniAuth::Strategies::OAuth2
|
6
|
+
DEFAULT_SCOPE = 'email,profile'
|
7
|
+
DEFAULT_RESPONSE_TYPE = 'code'
|
8
|
+
SANDBOX_SITE = 'https://api.sandbox.paypal.com'
|
9
9
|
SANDBOX_AUTHORIZE_URL = 'https://www.sandbox.paypal.com/signin/authorize'
|
10
10
|
|
11
|
-
option :name,
|
11
|
+
option :name, 'paypal_oauth2'
|
12
12
|
|
13
13
|
option :client_options, {
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
14
|
+
site: 'https://api.paypal.com',
|
15
|
+
authorize_url: 'https://www.paypal.com/signin/authorize',
|
16
|
+
token_url: '/v1/identity/openidconnect/tokenservice',
|
17
|
+
setup: true
|
18
18
|
}
|
19
19
|
|
20
20
|
option :authorize_options, [:scope, :response_type]
|
21
21
|
option :provider_ignores_state, true
|
22
22
|
option :sandbox, false
|
23
23
|
|
24
|
-
uid { @parsed_uid ||= (
|
24
|
+
uid { @parsed_uid ||= (%r{\/([^\/]+)\z}.match raw_info['user_id'])[1] } # https://www.paypal.com/webapps/auth/identity/user/baCNqjGvIxzlbvDCSsfhN3IrQDtQtsVr79AwAjMxekw => baCNqjGvIxzlbvDCSsfhN3IrQDtQtsVr79AwAjMxekw
|
25
25
|
|
26
26
|
info do
|
27
27
|
prune!({
|
@@ -64,7 +64,7 @@ module OmniAuth
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def raw_info
|
67
|
-
@raw_info ||= load_identity
|
67
|
+
@raw_info ||= load_identity
|
68
68
|
end
|
69
69
|
|
70
70
|
def authorize_params
|
@@ -74,17 +74,13 @@ module OmniAuth
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
def callback_url
|
78
|
-
full_host + script_name + callback_path
|
79
|
-
end
|
80
|
-
|
81
77
|
private
|
82
78
|
|
83
79
|
def load_identity
|
84
80
|
access_token.options[:mode] = :query
|
85
81
|
access_token.options[:param_name] = :access_token
|
86
82
|
access_token.options[:grant_type] = :authorization_code
|
87
|
-
access_token.get('/v1/identity/openidconnect/userinfo', { :
|
83
|
+
access_token.get('/v1/identity/openidconnect/userinfo', { params: { schema: 'openid' } }).parsed || {}
|
88
84
|
end
|
89
85
|
|
90
86
|
def prune!(hash)
|
@@ -93,7 +89,6 @@ module OmniAuth
|
|
93
89
|
value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
94
90
|
end
|
95
91
|
end
|
96
|
-
|
97
92
|
end
|
98
93
|
end
|
99
94
|
end
|
@@ -3,16 +3,16 @@ require File.expand_path(File.join('..', 'lib', 'omniauth', 'paypal_oauth2', 've
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = 'omniauth-paypal-oauth2'
|
6
|
-
gem.version = OmniAuth::
|
6
|
+
gem.version = OmniAuth::PaypalOauth2::VERSION
|
7
7
|
gem.license = 'MIT'
|
8
|
-
gem.summary =
|
9
|
-
gem.description =
|
8
|
+
gem.summary = 'A PayPal OAuth2 strategy for OmniAuth 1.x'
|
9
|
+
gem.description = 'A PayPal OAuth2 strategy for OmniAuth 1.x'
|
10
10
|
gem.authors = ['Jonas Hübotter']
|
11
11
|
gem.email = ['jonas@slooob.com']
|
12
12
|
gem.homepage = 'https://github.com/jonhue/omniauth-paypal-oauth2'
|
13
13
|
|
14
14
|
gem.files = `git ls-files`.split("\n")
|
15
|
-
gem.require_paths = [
|
15
|
+
gem.require_paths = ['lib']
|
16
16
|
|
17
17
|
gem.required_ruby_version = '>= 2.0'
|
18
18
|
|
@@ -21,4 +21,4 @@ Gem::Specification.new do |gem|
|
|
21
21
|
|
22
22
|
gem.add_development_dependency 'rspec', '~> 3.5'
|
23
23
|
gem.add_development_dependency 'rake'
|
24
|
-
end
|
24
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'omniauth-paypal-oauth2'
|
3
3
|
|
4
|
-
describe OmniAuth::Strategies::
|
4
|
+
describe OmniAuth::Strategies::PaypalOauth2 do
|
5
5
|
subject do
|
6
|
-
OmniAuth::Strategies::
|
6
|
+
OmniAuth::Strategies::PaypalOauth2.new(nil, @options || {})
|
7
7
|
end
|
8
8
|
|
9
9
|
it_should_behave_like 'an oauth2 strategy'
|
@@ -14,7 +14,7 @@ describe OmniAuth::Strategies::PayPalOauth2 do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'has correct PayPal sandbox site' do
|
17
|
-
@options = { :
|
17
|
+
@options = { sandbox: true }
|
18
18
|
subject.setup_phase
|
19
19
|
expect(subject.client.site).to eq('https://api.sandbox.paypal.com')
|
20
20
|
end
|
@@ -24,7 +24,7 @@ describe OmniAuth::Strategies::PayPalOauth2 do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'has correct sandbox authorize url' do
|
27
|
-
@options = { :
|
27
|
+
@options = { sandbox: true }
|
28
28
|
subject.setup_phase
|
29
29
|
expect(subject.client.options[:authorize_url]).to eq('https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize')
|
30
30
|
end
|
@@ -35,14 +35,14 @@ describe OmniAuth::Strategies::PayPalOauth2 do
|
|
35
35
|
|
36
36
|
it 'runs the setup block if passed one' do
|
37
37
|
counter = ''
|
38
|
-
@options = { :
|
38
|
+
@options = { setup: proc { counter = 'ok' } }
|
39
39
|
subject.setup_phase
|
40
|
-
expect(counter).to eq(
|
40
|
+
expect(counter).to eq('ok')
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
describe '#callback_path' do
|
45
|
-
it
|
45
|
+
it 'has the correct callback path' do
|
46
46
|
expect(subject.callback_path).to eq('/auth/paypal_oauth2/callback')
|
47
47
|
end
|
48
48
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-paypal-oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Hübotter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth-oauth2
|