omniauth-intuit 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/.rvmrc +1 -0
- data/Gemfile +16 -0
- data/Guardfile +11 -0
- data/README.md +45 -0
- data/Rakefile +6 -0
- data/example/Gemfile +9 -0
- data/example/config-example.yml +3 -0
- data/example/config.ru +48 -0
- data/example/views/auth.erb +13 -0
- data/example/views/bye.erb +8 -0
- data/lib/omniauth-intuit.rb +9 -0
- data/lib/omniauth-intuit/version.rb +5 -0
- data/lib/omniauth/strategies/intuit.rb +55 -0
- data/omniauth-intuit.gemspec +25 -0
- data/spec/omniauth/strategies/intuit_spec.rb +37 -0
- data/spec/spec_helper.rb +14 -0
- metadata +119 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use --create 1.8.7@omniauth-intuit
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in omniauth-intuit.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem 'crack'
|
7
|
+
|
8
|
+
group :development, :test do
|
9
|
+
gem "ruby-debug19", :platforms => :mri_19, :require => 'ruby-debug'
|
10
|
+
gem 'guard'
|
11
|
+
gem 'guard-rspec'
|
12
|
+
gem 'guard-bundler'
|
13
|
+
gem 'growl'
|
14
|
+
gem 'rb-fsevent'
|
15
|
+
gem 'multi_json'
|
16
|
+
end
|
data/Guardfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# OmniAuth Intuit
|
2
|
+
|
3
|
+
This gem contains the Intuit strategy for OmniAuth 1.0
|
4
|
+
|
5
|
+
Intuit uses the OAuth 1.0a flow, you can read about it here: https://ipp.developer.intuit.com/0010_Intuit_Partner_Platform/0030_Intuit_Anywhere/0036_Coding_Your_App/0050_OAuth_for_Intuit_Anywhere
|
6
|
+
|
7
|
+
## How To Use It
|
8
|
+
|
9
|
+
Usage is as per any other OmniAuth 1.0 strategy. So let's say you're using Rails, you need to add the strategy to your `Gemfile` along side omniauth:
|
10
|
+
|
11
|
+
gem 'omniauth'
|
12
|
+
gem 'omniauth-intuit'
|
13
|
+
|
14
|
+
Next, you need to add the following to your `config/initializers/omniauth.rb`:
|
15
|
+
|
16
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
17
|
+
provider :intuit, "consumer_key", "consumer_secret"
|
18
|
+
end
|
19
|
+
|
20
|
+
You will get your consumer key and secret when you register your app with Intuit Anywhere. (See
|
21
|
+
https://ipp.developer.intuit.com/0010_Intuit_Partner_Platform/0030_Intuit_Anywhere/0040_Hello_World_IA for an example)
|
22
|
+
|
23
|
+
You can now follow the OmniAuth README at: https://github.com/intridea/omniauth
|
24
|
+
|
25
|
+
## Running example code
|
26
|
+
|
27
|
+
`shotgun -s thin -d -p 3000 config.ru`
|
28
|
+
|
29
|
+
## Note on Patches/Pull Requests
|
30
|
+
|
31
|
+
- Fork the project.
|
32
|
+
- Make your feature addition or bug fix.
|
33
|
+
- Add tests for it. This is important so I don’t break it in a future version unintentionally.
|
34
|
+
- Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
35
|
+
- Send me a pull request. Bonus points for topic branches.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
Copyright (c) 2011 by Jaigouk Kim, Profitably
|
40
|
+
|
41
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
42
|
+
|
43
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
44
|
+
|
45
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/example/Gemfile
ADDED
data/example/config.ru
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.require
|
4
|
+
|
5
|
+
require 'sinatra/base'
|
6
|
+
require 'omniauth-intuit'
|
7
|
+
require 'crack'
|
8
|
+
require 'rack-ssl-enforcer'
|
9
|
+
|
10
|
+
|
11
|
+
class App < Sinatra::Base
|
12
|
+
get '/' do
|
13
|
+
@blue_dot_url = ""
|
14
|
+
@intuit_connect_url = "#{request.url}auth/intuit"
|
15
|
+
erb :auth
|
16
|
+
end
|
17
|
+
|
18
|
+
get '/bye' do
|
19
|
+
erb :bye
|
20
|
+
end
|
21
|
+
|
22
|
+
get '/auth/:provider/callback' do
|
23
|
+
|
24
|
+
puts "================"
|
25
|
+
puts params[:oauth_token]
|
26
|
+
puts params[:oauth_verifier]
|
27
|
+
puts params[:realmId]
|
28
|
+
puts params[:dataSource]
|
29
|
+
puts "================"
|
30
|
+
content_type 'application/json'
|
31
|
+
MultiJson.encode(request.env)
|
32
|
+
end
|
33
|
+
|
34
|
+
get '/auth/failure' do
|
35
|
+
content_type 'application/json'
|
36
|
+
MultiJson.encode(request.env)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
use Rack::Session::Cookie
|
41
|
+
# use Rack::SslEnforcer
|
42
|
+
|
43
|
+
config = YAML.load(File.read('config.yml'))
|
44
|
+
use OmniAuth::Builder do
|
45
|
+
provider :intuit, config['INTUIT_CONSUMER_KEY'], config['INTUIT_CONSUMER_SECRET']
|
46
|
+
end
|
47
|
+
|
48
|
+
run App.new
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<script type="text/javascript" src="https://js.appcenter.intuit.com/Content/IA/intuit.ipp.anywhere.js"></script>
|
4
|
+
<script>intuit.ipp.anywhere.setup({
|
5
|
+
menuProxy: '<%= @blue_dot_url %>',
|
6
|
+
grantUrl: "<%= @intuit_connect_url %>"
|
7
|
+
});</script>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<ipp:connectToIntuit></ipp:connectToIntuit>
|
11
|
+
<ipp:blueDot></ipp:blueDot>
|
12
|
+
</body>
|
13
|
+
</html>
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'omniauth/strategies/oauth'
|
2
|
+
require 'crack'
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Intuit < OmniAuth::Strategies::OAuth
|
6
|
+
option :name, "intuit"
|
7
|
+
|
8
|
+
option :client_options, {
|
9
|
+
:site => 'https://oauth.intuit.com',
|
10
|
+
:request_token_path => '/oauth/v1/get_request_token',
|
11
|
+
:access_token_path => '/oauth/v1/get_access_token',
|
12
|
+
:authorize_url => "https://workplace.intuit.com/Connect/Begin"
|
13
|
+
}
|
14
|
+
|
15
|
+
# uid{ raw_info['id'] }
|
16
|
+
|
17
|
+
# info do
|
18
|
+
# {
|
19
|
+
# :first_name => raw_info['firstName'],
|
20
|
+
# :last_name => raw_info['lastName'],
|
21
|
+
# :name => "#{raw_info['firstName']} #{raw_info['lastName']}",
|
22
|
+
# :email => raw_info['email'],
|
23
|
+
# :data_source => raw_info['dataSource'],
|
24
|
+
# :oauth_verifier => raw_info['oauth_verifier'],
|
25
|
+
# :realm_id => raw_info['realmId']
|
26
|
+
#
|
27
|
+
# }
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# extra do
|
31
|
+
# { 'raw_info' => raw_info }
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# def raw_info
|
35
|
+
# # access_token.get(path, headers={})
|
36
|
+
# # dataSource
|
37
|
+
# # "QBO"
|
38
|
+
# # oauth_token
|
39
|
+
# # "qyprdhjNbeM7UGDHYrgSvwqCRUQP0nZejdHw3IIFTaHY8mj5"
|
40
|
+
# # oauth_verifier
|
41
|
+
# # "ee3njpe"
|
42
|
+
# # realmId
|
43
|
+
# # "313247180"
|
44
|
+
#
|
45
|
+
# puts "==================="
|
46
|
+
# # access_token.get("/auth/intuit/callback").body
|
47
|
+
# puts "==================="
|
48
|
+
# @raw_info ||= Crack::XML.parse(access_token.get("").body)["RestResponse"]
|
49
|
+
# end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
OmniAuth.config.add_camelization 'intuit', 'Intuit'
|
55
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "omniauth-intuit/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "omniauth-intuit"
|
7
|
+
s.version = Omniauth::Intuit::VERSION
|
8
|
+
s.authors = ["Jaigouk Kim, Graham Siener"]
|
9
|
+
s.email = ["jaigouk@gmail.com, graham.siener@profitably.com"]
|
10
|
+
s.homepage = "https://github.com/profitably/omniauth-intuit"
|
11
|
+
s.summary = %q{Intuit strategy for OmniAuth.}
|
12
|
+
s.description = %q{Intuit strategy for OmniAuth.}
|
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-oauth', '~> 1.0.0'
|
20
|
+
|
21
|
+
s.add_development_dependency 'rspec', '~> 2.7.0'
|
22
|
+
s.add_development_dependency 'rake'
|
23
|
+
s.add_development_dependency 'webmock'
|
24
|
+
s.add_development_dependency 'rack-test'
|
25
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "OmniAuth::Strategies::Intuit" do
|
4
|
+
before :each do
|
5
|
+
@request = double('Request')
|
6
|
+
@request.stub(:params) { {} }
|
7
|
+
end
|
8
|
+
|
9
|
+
subject do
|
10
|
+
OmniAuth::Strategies::Intuit.new(nil, @options || {}).tap do |strategy|
|
11
|
+
strategy.stub(:request) { @request }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should add a camelization for itself' do
|
16
|
+
OmniAuth::Utils.camelize('intuit').should == 'Intuit'
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'client options' do
|
20
|
+
it 'has correct Intuit site' do
|
21
|
+
subject.options.client_options.site.should eq('https://oauth.intuit.com')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'has correct request token path' do
|
25
|
+
subject.options.client_options.request_token_path.should eq('/oauth/v1/get_request_token')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'has correct access token path' do
|
29
|
+
subject.options.client_options.access_token_path.should eq('/oauth/v1/get_access_token')
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'has correct authorize url' do
|
33
|
+
subject.options.client_options.authorize_url.should eq('https://workplace.intuit.com/Connect/Begin')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'rspec'
|
5
|
+
require 'rack/test'
|
6
|
+
require 'webmock/rspec'
|
7
|
+
require 'omniauth'
|
8
|
+
require 'omniauth-intuit'
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.include WebMock::API
|
12
|
+
config.include Rack::Test::Methods
|
13
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-intuit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jaigouk Kim, Graham Siener
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-20 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth-oauth
|
16
|
+
requirement: &2165016900 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2165016900
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &2165015460 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.7.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2165015460
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
requirement: &2165014640 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2165014640
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: webmock
|
49
|
+
requirement: &2165002020 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2165002020
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rack-test
|
60
|
+
requirement: &2165000680 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2165000680
|
69
|
+
description: Intuit strategy for OmniAuth.
|
70
|
+
email:
|
71
|
+
- jaigouk@gmail.com, graham.siener@profitably.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .rvmrc
|
78
|
+
- Gemfile
|
79
|
+
- Guardfile
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- example/Gemfile
|
83
|
+
- example/config-example.yml
|
84
|
+
- example/config.ru
|
85
|
+
- example/views/auth.erb
|
86
|
+
- example/views/bye.erb
|
87
|
+
- lib/omniauth-intuit.rb
|
88
|
+
- lib/omniauth-intuit/version.rb
|
89
|
+
- lib/omniauth/strategies/intuit.rb
|
90
|
+
- omniauth-intuit.gemspec
|
91
|
+
- spec/omniauth/strategies/intuit_spec.rb
|
92
|
+
- spec/spec_helper.rb
|
93
|
+
homepage: https://github.com/profitably/omniauth-intuit
|
94
|
+
licenses: []
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ! '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 1.8.10
|
114
|
+
signing_key:
|
115
|
+
specification_version: 3
|
116
|
+
summary: Intuit strategy for OmniAuth.
|
117
|
+
test_files:
|
118
|
+
- spec/omniauth/strategies/intuit_spec.rb
|
119
|
+
- spec/spec_helper.rb
|