omniauth-paypal-oauth2 1.4.13 → 1.4.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2e4a7a29dbe49818dd003fba0c84883a3b25dc67
4
- data.tar.gz: 7d47686bf5f3fd6d1a445ff149c2467eae949644
2
+ SHA256:
3
+ metadata.gz: 12c2999b4af5ff0ac88422ec09126eccf6c8815f7524cb891f10ea9915d11c9e
4
+ data.tar.gz: 2da82c21ffa65e20c8b18edb9decf7c69728f1ff9c83c8aeed416bf97bb74f8b
5
5
  SHA512:
6
- metadata.gz: f2d916910b12788dfe14e24018cbb786bc36d7891dbe79abc1cef4b6718e6f7f329198a51ec611dd3fc8d0e7f2c04a1f94c82030682d7c526d6bce901d5ed061
7
- data.tar.gz: 1b6e4ec2e840037f609f7171e5d4908546f4e95eead7c8f50635639c1440626327069d6117f46c039429c1b6a70632cca0e702cf322efb9b36853ea9ccfdb302
6
+ metadata.gz: 99700535c14d5efda09a5d1843464b145115d5392d10ec2d4df65ca473cf0006cb6421eda57e1eee2db3e8fd735176be396360eb73ae4f4dceda3bee48fd58ef
7
+ data.tar.gz: 9438dc31f7abbb189a9586fd5251813dd399b1ff703ec8959da34a60fc9b6eea7f390f32d212fd6132820d463abc889b9a0086ba438a2286102d082b9e1da411
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ ### master
4
+
5
+ * nothing yet
6
+
7
+ ### 1.4.14 - 2018-01-06
8
+
9
+ * enhancements
10
+ * cleaning up gem files
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # OmniAuth PayPal OAuth2 Strategy
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/omniauth-paypal-oauth2.svg)](https://badge.fury.io/rb/omniauth-paypal-oauth2) <img src="https://travis-ci.org/jonhue/omniauth-paypal-oauth2.svg?branch=master" />
4
+
3
5
  Strategy to authenticate with PayPal via OmniAuth.
4
6
 
5
7
  Get your API key at: https://developer.paypal.com/developer/applications/ in the section **RESTApps**. Note the Client ID and the Client Secret.
@@ -9,6 +11,24 @@ Use the [config Gem](https://rubygems.org/gems/config) to organize your keys and
9
11
 
10
12
  For more details, read the PayPal docs: https://developer.paypal.com/docs/integration/direct/identity/
11
13
 
14
+ ---
15
+
16
+ ## Table of Contents
17
+
18
+ * [Installation](#installation)
19
+ * [Usage](#usage)
20
+ * [PayPal API Setup](#paypal-api-setup)
21
+ * [Rails middleware](#rails-middleware)
22
+ * [Devise](#Devise)
23
+ * [Configuration](#configuration)
24
+ * [Auth hash](#auth-hash)
25
+ * [To Do](#to-do)
26
+ * [Contributing](#contributing)
27
+ * [Contributors](#contributors)
28
+ * [Semantic versioning](#semantic-versioning)
29
+ * [License](#license)
30
+
31
+ ---
12
32
 
13
33
  ## Installation
14
34
 
@@ -26,8 +46,11 @@ Or install it yourself as:
26
46
 
27
47
  $ gem install omniauth-paypal-oauth2
28
48
 
49
+ ---
29
50
 
30
- ## PayPal API Setup
51
+ ## Usage
52
+
53
+ ### PayPal API Setup
31
54
 
32
55
  * Go to 'https://developer.paypal.com/developer/applications/'
33
56
  * Select your project.
@@ -37,8 +60,7 @@ Or install it yourself as:
37
60
  * Go to Credentials, then select the "OAuth consent screen" tab on top, and provide an 'EMAIL ADDRESS' and a 'PRODUCT NAME'
38
61
  * Wait 10 minutes for changes to take effect.
39
62
 
40
-
41
- ## Usage
63
+ ### Rails middleware
42
64
 
43
65
  Here's an example for adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
44
66
 
@@ -52,8 +74,76 @@ You can now access the OmniAuth PayPal OAuth2 URL: `/auth/paypal_oauth2`
52
74
 
53
75
  **Note**: While developing your application, if you change the scope in the initializer you will need to restart your app server. Remember that either the 'email' or 'profile' scope is required!
54
76
 
77
+ ### Devise
78
+
79
+ First define your application id and secret in `config/initializers/devise.rb`. Do not use the snippet mentioned in the [Usage](https://github.com/jonhue/omniauth-paypal-oauth2#usage) section.
80
+
81
+ ```ruby
82
+ require "omniauth-paypal-oauth2"
83
+ config.omniauth :paypal_oauth2, "PAYPAL_CLIENT_ID", "PAYPAL_CLIENT_SECRET"
84
+ ```
85
+
86
+ Then add the following to 'config/routes.rb' so the callback routes are defined.
87
+
88
+ ```ruby
89
+ devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
90
+ ```
91
+
92
+ Make sure your model is omniauthable. Generally this is "/app/models/user.rb"
93
+
94
+ ```ruby
95
+ devise :omniauthable, :omniauth_providers => [:paypal_oauth2]
96
+ ```
97
+
98
+ Then make sure your callbacks controller is setup.
99
+
100
+ ```ruby
101
+ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
102
+ def paypal_oauth2
103
+ # You need to implement the method below in your model (e.g. app/models/user.rb)
104
+ @user = User.from_omniauth(request.env["omniauth.auth"])
105
+
106
+ if @user.persisted?
107
+ flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "PayPal"
108
+ sign_in_and_redirect @user, :event => :authentication
109
+ else
110
+ session["devise.paypal_data"] = request.env["omniauth.auth"]
111
+ redirect_to new_user_registration_url
112
+ end
113
+ end
114
+ end
115
+ ```
116
+
117
+ and bind to or create the user
118
+
119
+ ```ruby
120
+ def self.from_omniauth(access_token)
121
+ data = access_token.info
122
+ user = User.where(:email => data["email"]).first
123
+
124
+ # Uncomment the section below if you want users to be created if they don't exist
125
+ # unless user
126
+ # user = User.create(name: data["name"],
127
+ # email: data["email"],
128
+ # password: Devise.friendly_token[0,20]
129
+ # )
130
+ # end
131
+ user
132
+ end
133
+ ```
55
134
 
56
- ## Configuration
135
+ For your views you can login using:
136
+
137
+ ```erb
138
+ <%= link_to "Sign in with PayPal", user_paypal_oauth2_omniauth_authorize_path %>
139
+
140
+ <%# Devise prior 4.1.0: %>
141
+ <%= link_to "Sign in with PayPal", user_omniauth_authorize_path(:paypal_oauth2) %>
142
+ ```
143
+
144
+ An overview is available at https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
145
+
146
+ ### Configuration
57
147
 
58
148
  If you click from your [Applications Dashboard](https://developer.paypal.com/developer/applications/) in your Application on "Advanced Options" in the "APP SETTINGS" section and "Log In with PayPal" subsection, you can configure several options:
59
149
 
@@ -81,8 +171,7 @@ If you click from your [Applications Dashboard](https://developer.paypal.com/dev
81
171
  * `Locale`: Permits a locale string which indicates where the PayPal customer is.
82
172
  * `Language`: Permits the language the customer uses on PayPal.
83
173
 
84
-
85
- ## Auth Hash
174
+ ### Auth Hash
86
175
 
87
176
  Here's an example of an authentication hash available in the callback by accessing `request.env["omniauth.auth"]`:
88
177
 
@@ -129,76 +218,31 @@ Here's an example of an authentication hash available in the callback by accessi
129
218
 
130
219
  For more details see the PayPal [List Of Attributes](https://developer.paypal.com/webapps/developer/docs/integration/direct/log-in-with-paypal/detailed/#attributes).
131
220
 
221
+ ---
132
222
 
133
- ### Devise
223
+ ## To Do
134
224
 
135
- First define your application id and secret in `config/initializers/devise.rb`. Do not use the snippet mentioned in the [Usage](https://github.com/jonhue/omniauth-paypal-oauth2#usage) section.
225
+ [Here](https://github.com/jonhue/omniauth-paypal-oauth2/projects/1) is the full list of current projects.
136
226
 
137
- ```ruby
138
- require "omniauth-paypal-oauth2"
139
- config.omniauth :paypal_oauth2, "PAYPAL_CLIENT_ID", "PAYPAL_CLIENT_SECRET"
140
- ```
227
+ To propose your ideas, initiate the discussion by adding a [new issue](https://github.com/jonhue/omniauth-paypal-oauth2/issues/new).
141
228
 
142
- Then add the following to 'config/routes.rb' so the callback routes are defined.
229
+ ---
143
230
 
144
- ```ruby
145
- devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
146
- ```
231
+ ## Contributing
147
232
 
148
- Make sure your model is omniauthable. Generally this is "/app/models/user.rb"
233
+ We hope that you will consider contributing to omniauth-paypal-oauth2. Please read this short overview for some information about how to get started:
149
234
 
150
- ```ruby
151
- devise :omniauthable, :omniauth_providers => [:paypal_oauth2]
152
- ```
235
+ [Learn more about contributing to this repository](https://github.com/jonhue/omniauth-paypal-oauth2/blob/master/CONTRIBUTING.md), [Code of Conduct](https://github.com/jonhue/omniauth-paypal-oauth2/blob/master/CODE_OF_CONDUCT.md)
153
236
 
154
- Then make sure your callbacks controller is setup.
237
+ ### Contributors
155
238
 
156
- ```ruby
157
- class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
158
- def paypal_oauth2
159
- # You need to implement the method below in your model (e.g. app/models/user.rb)
160
- @user = User.from_omniauth(request.env["omniauth.auth"])
239
+ Give the people some :heart: who are working on this project. See them all at:
161
240
 
162
- if @user.persisted?
163
- flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "PayPal"
164
- sign_in_and_redirect @user, :event => :authentication
165
- else
166
- session["devise.paypal_data"] = request.env["omniauth.auth"]
167
- redirect_to new_user_registration_url
168
- end
169
- end
170
- end
171
- ```
241
+ https://github.com/jonhue/omniauth-paypal-oauth2/graphs/contributors
172
242
 
173
- and bind to or create the user
174
-
175
- ```ruby
176
- def self.from_omniauth(access_token)
177
- data = access_token.info
178
- user = User.where(:email => data["email"]).first
179
-
180
- # Uncomment the section below if you want users to be created if they don't exist
181
- # unless user
182
- # user = User.create(name: data["name"],
183
- # email: data["email"],
184
- # password: Devise.friendly_token[0,20]
185
- # )
186
- # end
187
- user
188
- end
189
- ```
190
-
191
- For your views you can login using:
192
-
193
- ```erb
194
- <%= link_to "Sign in with PayPal", user_paypal_oauth2_omniauth_authorize_path %>
195
-
196
- <%# Devise prior 4.1.0: %>
197
- <%= link_to "Sign in with PayPal", user_omniauth_authorize_path(:paypal_oauth2) %>
198
- ```
199
-
200
- An overview is available at https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
243
+ ### Semantic Versioning
201
244
 
245
+ omniauth-paypal-oauth2 follows Semantic Versioning 2.0 as defined at http://semver.org.
202
246
 
203
247
  ## License
204
248
 
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module PaypalOauth2
3
- VERSION = '1.4.13'
3
+ VERSION = '1.4.14'
4
4
  end
5
5
  end
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.13
4
+ version: 1.4.14
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-08-22 00:00:00.000000000 Z
11
+ date: 2018-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth-oauth2
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.4'
19
+ version: '1.5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.4'
26
+ version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,55 +38,62 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.3'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '3'
61
+ version: '3.7'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '3'
68
+ version: '3.7'
55
69
  - !ruby/object:Gem::Dependency
56
- name: rake
70
+ name: rubocop
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - ">="
73
+ - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '0'
75
+ version: '0.52'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ">="
80
+ - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '0'
82
+ version: '0.52'
69
83
  description: A PayPal OAuth2 strategy for OmniAuth
70
84
  email:
71
- - jonas@slooob.com
85
+ - jonas.huebotter@gmail.com
72
86
  executables: []
73
87
  extensions: []
74
88
  extra_rdoc_files: []
75
89
  files:
76
- - ".gitignore"
77
- - Gemfile
90
+ - CHANGELOG.md
78
91
  - LICENSE
79
92
  - README.md
80
- - Rakefile
81
- - _config.yml
82
- - examples/shared_examples.rb
83
93
  - lib/omniauth-paypal-oauth2.rb
84
94
  - lib/omniauth/paypal_oauth2.rb
85
95
  - lib/omniauth/paypal_oauth2/version.rb
86
96
  - lib/omniauth/strategies/paypal_oauth2.rb
87
- - omniauth-paypal-oauth2.gemspec
88
- - spec/omniauth/strategies/paypal_oauth2_spec.rb
89
- - spec/spec_helper.rb
90
97
  homepage: https://github.com/jonhue/omniauth-paypal-oauth2
91
98
  licenses:
92
99
  - MIT
@@ -107,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
114
  version: '0'
108
115
  requirements: []
109
116
  rubyforge_project:
110
- rubygems_version: 2.6.12
117
+ rubygems_version: 2.7.4
111
118
  signing_key:
112
119
  specification_version: 4
113
120
  summary: A PayPal OAuth2 strategy for OmniAuth
data/.gitignore DELETED
@@ -1,20 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- .idea/
19
- .ruby-version
20
- .ruby-gemset
data/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
-
5
- # Development
6
- group :development do
7
- gem 'rubocop', '~> 0.47.1', require: false
8
- end
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task default: :spec
data/_config.yml DELETED
@@ -1 +0,0 @@
1
- theme: jekyll-theme-minimal
@@ -1,36 +0,0 @@
1
- shared_examples 'an oauth2 strategy' do
2
- describe '#client' do
3
- it 'should be initialized with symbolized client_options' do
4
- @options = { client_options: { 'authorize_url' => 'https://example.com' } }
5
- expect(subject.client.options[:authorize_url]).to eq('https://example.com')
6
- end
7
- end
8
-
9
- describe '#authorize_params' do
10
- it 'should include any authorize params passed in the :authorize_params option' do
11
- @options = { authorize_params: { foo: 'bar', baz: 'zip' } }
12
- expect(subject.authorize_params['foo']).to eq('bar')
13
- expect(subject.authorize_params['baz']).to eq('zip')
14
- end
15
-
16
- it 'should include top-level options that are marked as :authorize_options' do
17
- @options = { authorize_options: [:scope, :foo], scope: 'bar', foo: 'baz' }
18
- expect(subject.authorize_params['scope']).to eq('bar')
19
- expect(subject.authorize_params['foo']).to eq('baz')
20
- end
21
- end
22
-
23
- describe '#token_params' do
24
- it 'should include any token params passed in the :token_params option' do
25
- @options = { token_params: { foo: 'bar', baz: 'zip' } }
26
- expect(subject.token_params['foo']).to eq('bar')
27
- expect(subject.token_params['baz']).to eq('zip')
28
- end
29
-
30
- it 'should include top-level options that are marked as :token_options' do
31
- @options = { token_options: [:scope, :foo], scope: 'bar', foo: 'baz' }
32
- expect(subject.token_params['scope']).to eq('bar')
33
- expect(subject.token_params['foo']).to eq('baz')
34
- end
35
- end
36
- end
@@ -1,24 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path(File.join('..', 'lib', 'omniauth', 'paypal_oauth2', 'version'), __FILE__)
3
-
4
- Gem::Specification.new do |gem|
5
- gem.name = 'omniauth-paypal-oauth2'
6
- gem.version = OmniAuth::PaypalOauth2::VERSION
7
- gem.license = 'MIT'
8
- gem.summary = 'A PayPal OAuth2 strategy for OmniAuth'
9
- gem.description = 'A PayPal OAuth2 strategy for OmniAuth'
10
- gem.authors = ['Jonas Hübotter']
11
- gem.email = ['jonas@slooob.com']
12
- gem.homepage = 'https://github.com/jonhue/omniauth-paypal-oauth2'
13
-
14
- gem.files = `git ls-files`.split("\n")
15
- gem.require_paths = ['lib']
16
-
17
- gem.required_ruby_version = '>= 2.0'
18
-
19
- gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.4'
20
- gem.add_runtime_dependency 'json', '~> 1.7'
21
-
22
- gem.add_development_dependency 'rspec', '~> 3'
23
- gem.add_development_dependency 'rake'
24
- end
@@ -1,49 +0,0 @@
1
- require 'spec_helper'
2
- require 'omniauth-paypal-oauth2'
3
-
4
- describe OmniAuth::Strategies::PaypalOauth2 do
5
- subject do
6
- OmniAuth::Strategies::PaypalOauth2.new(nil, @options || {})
7
- end
8
-
9
- it_should_behave_like 'an oauth2 strategy'
10
-
11
- describe '#client' do
12
- it 'has correct PayPal site' do
13
- expect(subject.client.site).to eq('https://api.paypal.com')
14
- end
15
-
16
- it 'has correct PayPal sandbox site' do
17
- @options = { sandbox: true }
18
- subject.setup_phase
19
- expect(subject.client.site).to eq('https://api.sandbox.paypal.com')
20
- end
21
-
22
- it 'has correct authorize url' do
23
- expect(subject.client.options[:authorize_url]).to eq('https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize')
24
- end
25
-
26
- it 'has correct sandbox authorize url' do
27
- @options = { sandbox: true }
28
- subject.setup_phase
29
- expect(subject.client.options[:authorize_url]).to eq('https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize')
30
- end
31
-
32
- it 'has correct token url' do
33
- expect(subject.client.options[:token_url]).to eq('/v1/identity/openidconnect/tokenservice')
34
- end
35
-
36
- it 'runs the setup block if passed one' do
37
- counter = ''
38
- @options = { setup: proc { counter = 'ok' } }
39
- subject.setup_phase
40
- expect(counter).to eq('ok')
41
- end
42
- end
43
-
44
- describe '#callback_path' do
45
- it 'has the correct callback path' do
46
- expect(subject.callback_path).to eq('/auth/paypal_oauth2/callback')
47
- end
48
- end
49
- end
data/spec/spec_helper.rb DELETED
@@ -1,8 +0,0 @@
1
- require File.join('bundler', 'setup')
2
- require 'rspec'
3
- require 'omniauth-oauth2'
4
- Dir[File.expand_path('../support/**/*', __FILE__)].each { |f| require f }
5
-
6
- RSpec.configure do
7
- OmniAuth.config.test_mode = true
8
- end