omniauth-stripe-connect 2.2.0 → 2.3.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: c53f51f69f299d64286948df5aaa531558368bbb
4
+ data.tar.gz: 276f6ecc06181e31af0dd72d232a58158c8d8a25
5
+ SHA512:
6
+ metadata.gz: 6ad3c0a7cc75cdc97606be199786dcefa1dec2c8cf0c3ccf71133ad542467a8a1a8e0675f4a4e60e873c110eb2154437868b652a15c55cfa03669399347ac65f
7
+ data.tar.gz: ff36566a2298eb57a9be768291f3e058fdcf76cf4db7c6877759b4bea6edcdb15900bb2d601ac02a093f54d9d2a8dbc34cd59208d9b9838d9288c8580a94986f
data/Gemfile CHANGED
@@ -3,3 +3,7 @@ gem 'rake'
3
3
 
4
4
  # Specify your gem's dependencies in omniauth-stripe-connect.gemspec
5
5
  gemspec
6
+
7
+ group :test do
8
+ gem 'rspec', '>= 2.14'
9
+ end
data/README.md CHANGED
@@ -35,13 +35,34 @@ end
35
35
 
36
36
  Your `STRIPE_CONNECT_CLIENT_ID` is application-specific and your `STRIPE_SECRET` is account-specific and may also be known as your Stripe API key or Stripe Private key.
37
37
 
38
+ Edit your routes.rb file to have:
39
+ `devise_for :users, :controllers => { :omniauth_callbacks => "omniauth_callbacks" }`
40
+
41
+ And create a file called `omniauth_callbacks_controller.rb` which should have this inside:
42
+ ```ruby
43
+ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
44
+
45
+ def stripe_connect
46
+ # Delete the code inside of this method and write your own.
47
+ # The code below is to show you where to access the data.
48
+ raise request.env["omniauth.auth"].to_yaml
49
+ end
50
+ end
51
+ ```
52
+
53
+ Make sure to go to Stripe's Account Settings > Applications and set your Redirect URL to:
54
+ `http://localhost:3003/users/auth/stripe_connect/callback`
55
+
56
+ The Webhook URL will be something similar:
57
+ `http://www.yourdomain.com/users/auth/stripe_connect/callback`
58
+
38
59
  Then you can hit `/auth/stripe_connect`
39
60
 
40
61
  If you hit `/auth/stripe_connect` with any query params, they will be passed along to Stripe. Read [Stripe's OAuth Reference](https://stripe.com/docs/connect/reference) for more information.
41
62
 
42
63
  ### Ruby on Rails apps with Devise
43
64
 
44
- After setting up Devise to use OmniAuth, you only need to add the following line of code to handle the OAuth2 part of Stripe Connect.
65
+ After setting up Devise to use OmniAuth, you only need to add the following line of code to handle the OAuth2 part of Stripe Connect. Since this Devise initializer code takes care of OmniAuth, do not use a separate OmniAuth initializer.
45
66
 
46
67
  ```ruby
47
68
  # Put this in config/initializers/devise.rb with the rest of your Devise configuration
data/Rakefile CHANGED
@@ -1,2 +1,9 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ desc 'Default: run specs.'
6
+ task :default => :spec
7
+
8
+ desc "Run specs"
9
+ RSpec::Core::RakeTask.new
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module StripeConnect
3
- VERSION = "2.2.0"
3
+ VERSION = "2.3.0"
4
4
  end
5
5
  end
@@ -32,18 +32,38 @@ module OmniAuth
32
32
  @raw_info ||= deep_symbolize(access_token.params)
33
33
  end
34
34
 
35
+ def redirect_params
36
+ if options.key?(:callback_path) || OmniAuth.config.full_host
37
+ {:redirect_uri => callback_url}
38
+ else
39
+ {}
40
+ end
41
+ end
42
+
43
+ # NOTE: We call redirect_params AFTER super in these methods intentionally
44
+ # the OAuth2 strategy uses the authorize_params and token_params methods
45
+ # to set up some state for testing that we need in redirect_params
46
+
47
+ def authorize_params
48
+ params = super
49
+ params = params.merge(request.params) unless OmniAuth.config.test_mode
50
+ redirect_params.merge(params)
51
+ end
52
+
53
+ def token_params
54
+ params = super.to_hash(:symbolize_keys => true) \
55
+ .merge(:headers => { 'Authorization' => "Bearer #{client.secret}" })
56
+
57
+ redirect_params.merge(params)
58
+ end
59
+
35
60
  def request_phase
36
- redirect client.auth_code.authorize_url({:redirect_uri => callback_url}.merge(authorize_params.merge(request.params)))
61
+ redirect client.auth_code.authorize_url(authorize_params)
37
62
  end
38
63
 
39
64
  def build_access_token
40
- headers = {
41
- :headers => {
42
- 'Authorization' => "Bearer #{client.secret}"
43
- }
44
- }
45
65
  verifier = request.params['code']
46
- client.auth_code.get_token(verifier, {:redirect_uri => callback_url}.merge(token_params.to_hash(:symbolize_keys => true)).merge(headers))
66
+ client.auth_code.get_token(verifier, token_params)
47
67
  end
48
68
  end
49
69
  end
@@ -0,0 +1,74 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::StripeConnect do
4
+ let(:fresh_strategy){ Class.new(OmniAuth::Strategies::StripeConnect) }
5
+
6
+
7
+ before(:each) do
8
+ OmniAuth.config.test_mode = true
9
+ @old_host = OmniAuth.config.full_host
10
+ end
11
+
12
+ after(:each) do
13
+ OmniAuth.config.full_host = @old_host
14
+ OmniAuth.config.test_mode = false
15
+ end
16
+
17
+ describe '#authorize_params' do
18
+ subject { fresh_strategy }
19
+
20
+ it 'should include redirect_uri if full_host is set' do
21
+ OmniAuth.config.full_host = 'https://foo.com/'
22
+ instance = subject.new('abc', 'def')
23
+
24
+ instance.authorize_params[:redirect_uri].should =~ /\Ahttps:\/\/foo\.com/
25
+ end
26
+
27
+ it 'should include redirect_uri if callback_path is set' do
28
+ # TODO: It would be nice to grab this from the request URL
29
+ # instead of setting it on the config
30
+ OmniAuth.config.full_host = 'https://foo.com/'
31
+ instance = subject.new('abc', 'def', :callback_path => 'bar/baz')
32
+
33
+ instance.authorize_params[:redirect_uri].should == 'https://foo.com/bar/baz'
34
+ end
35
+
36
+ it 'should not include redirect_uri by default' do
37
+ instance = subject.new('abc', 'def')
38
+
39
+ expect(instance.authorize_params[:redirect_uri]).to be_nil
40
+ end
41
+ end
42
+
43
+ describe '#token_params' do
44
+ subject { fresh_strategy }
45
+
46
+ # NOTE: We call authorize_params first in each of these methods
47
+ # since the OAuth2 gem uses it to setup some state for testing
48
+
49
+ it 'should include redirect_uri if full_host is set' do
50
+ OmniAuth.config.full_host = 'https://foo.com/'
51
+ instance = subject.new('abc', 'def')
52
+
53
+ instance.authorize_params
54
+ instance.token_params[:redirect_uri].should =~ /\Ahttps:\/\/foo\.com/
55
+ end
56
+
57
+ it 'should include redirect_uri if callback_path is set' do
58
+ # TODO: It would be nice to grab this from the request URL
59
+ # instead of setting it on the config
60
+ OmniAuth.config.full_host = 'https://foo.com/'
61
+ instance = subject.new('abc', 'def', :callback_path => 'bar/baz')
62
+
63
+ instance.authorize_params
64
+ instance.token_params[:redirect_uri].should == 'https://foo.com/bar/baz'
65
+ end
66
+
67
+ it 'should not include redirect_uri by default' do
68
+ instance = subject.new('abc', 'def')
69
+
70
+ instance.authorize_params
71
+ expect(instance.token_params[:redirect_uri]).to be_nil
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,2 @@
1
+ require 'rspec'
2
+ require 'omniauth-stripe-connect'
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-stripe-connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
5
- prerelease:
4
+ version: 2.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Isaac Sanders
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-02 00:00:00.000000000 Z
11
+ date: 2013-09-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: omniauth
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,17 +27,15 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: omniauth-oauth2
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: 1.0.3
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: 1.0.3
46
41
  description: Stripe Connect OAuth2 Strategy for OmniAuth 1.0.
@@ -60,35 +55,32 @@ files:
60
55
  - lib/omniauth/strategies/stripe_connect.rb
61
56
  - lib/omniauth/stripe_connect.rb
62
57
  - omniauth-stripe-connect.gemspec
58
+ - spec/omniauth/strategies/stripe_connect_spec.rb
59
+ - spec/spec_helper.rb
63
60
  homepage: https://stripe.com/docs/connect
64
61
  licenses: []
62
+ metadata: {}
65
63
  post_install_message:
66
64
  rdoc_options: []
67
65
  require_paths:
68
66
  - lib
69
67
  required_ruby_version: !ruby/object:Gem::Requirement
70
- none: false
71
68
  requirements:
72
- - - ! '>='
69
+ - - '>='
73
70
  - !ruby/object:Gem::Version
74
71
  version: '0'
75
- segments:
76
- - 0
77
- hash: 3075695850396348084
78
72
  required_rubygems_version: !ruby/object:Gem::Requirement
79
- none: false
80
73
  requirements:
81
- - - ! '>='
74
+ - - '>='
82
75
  - !ruby/object:Gem::Version
83
76
  version: '0'
84
- segments:
85
- - 0
86
- hash: 3075695850396348084
87
77
  requirements: []
88
78
  rubyforge_project:
89
- rubygems_version: 1.8.24
79
+ rubygems_version: 2.0.3
90
80
  signing_key:
91
- specification_version: 3
92
- summary: ! 'Supports the OAuth 2.0 server-side and client-side flows. Read the Stripe
81
+ specification_version: 4
82
+ summary: 'Supports the OAuth 2.0 server-side and client-side flows. Read the Stripe
93
83
  Connect docs for more details: https://stripe.com/docs/connect'
94
- test_files: []
84
+ test_files:
85
+ - spec/omniauth/strategies/stripe_connect_spec.rb
86
+ - spec/spec_helper.rb