asf-rest-adapter 0.4.3 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.DS_Store CHANGED
Binary file
@@ -1,7 +1,7 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- addressable (2.2.5)
4
+ addressable (2.2.4)
5
5
  builder (3.0.0)
6
6
  faraday (0.6.1)
7
7
  addressable (~> 2.2.4)
@@ -13,55 +13,54 @@ GEM
13
13
  git (>= 1.2.5)
14
14
  rake
15
15
  mime-types (1.16)
16
- multi_json (0.0.5)
17
- multipart-post (1.1.0)
18
- net-ldap (0.1.1)
16
+ multi_json (1.0.3)
17
+ multi_xml (0.2.2)
18
+ multipart-post (1.1.1)
19
+ net-ldap (0.2.2)
19
20
  nokogiri (1.4.4)
20
- oa-basic (0.2.2)
21
- multi_json (~> 0.0.2)
22
- nokogiri (~> 1.4.2)
23
- oa-core (= 0.2.2)
21
+ oa-basic (0.2.6)
22
+ oa-core (= 0.2.6)
24
23
  rest-client (~> 1.6.0)
25
- oa-core (0.2.2)
26
- rack (~> 1.1)
27
- oa-enterprise (0.2.2)
28
- net-ldap (~> 0.1.1)
24
+ oa-core (0.2.6)
25
+ oa-enterprise (0.2.6)
26
+ addressable (= 2.2.4)
27
+ net-ldap (~> 0.2.2)
29
28
  nokogiri (~> 1.4.2)
30
- oa-core (= 0.2.2)
29
+ oa-core (= 0.2.6)
31
30
  pyu-ruby-sasl (~> 0.0.3.1)
32
31
  rubyntlm (~> 0.1.1)
33
- oa-more (0.2.2)
34
- multi_json (~> 0.0.2)
35
- oa-core (= 0.2.2)
32
+ oa-more (0.2.6)
33
+ multi_json (~> 1.0.0)
34
+ oa-core (= 0.2.6)
36
35
  rest-client (~> 1.6.0)
37
- oa-oauth (0.2.2)
36
+ oa-oauth (0.2.6)
38
37
  faraday (~> 0.6.1)
39
- multi_json (~> 0.0.2)
40
- nokogiri (~> 1.4.2)
41
- oa-core (= 0.2.2)
38
+ multi_json (~> 1.0.0)
39
+ multi_xml (~> 0.2.2)
40
+ oa-core (= 0.2.6)
42
41
  oauth (~> 0.4.0)
43
- oauth2 (~> 0.3.0)
44
- oa-openid (0.2.2)
45
- oa-core (= 0.2.2)
46
- rack-openid (~> 1.2.0)
47
- ruby-openid-apps-discovery
42
+ oauth2 (~> 0.4.1)
43
+ oa-openid (0.2.6)
44
+ oa-core (= 0.2.6)
45
+ rack-openid (~> 1.3.1)
46
+ ruby-openid-apps-discovery (~> 1.2.0)
48
47
  oauth (0.4.4)
49
- oauth2 (0.3.0)
50
- faraday (~> 0.6.0)
51
- multi_json (~> 0.0.4)
52
- omniauth (0.2.2)
53
- oa-basic (= 0.2.2)
54
- oa-core (= 0.2.2)
55
- oa-enterprise (= 0.2.2)
56
- oa-more (= 0.2.2)
57
- oa-oauth (= 0.2.2)
58
- oa-openid (= 0.2.2)
48
+ oauth2 (0.4.1)
49
+ faraday (~> 0.6.1)
50
+ multi_json (>= 0.0.5)
51
+ omniauth (0.2.6)
52
+ oa-basic (= 0.2.6)
53
+ oa-core (= 0.2.6)
54
+ oa-enterprise (= 0.2.6)
55
+ oa-more (= 0.2.6)
56
+ oa-oauth (= 0.2.6)
57
+ oa-openid (= 0.2.6)
59
58
  pyu-ruby-sasl (0.0.3.2)
60
- rack (1.2.2)
61
- rack-openid (1.2.0)
59
+ rack (1.3.0)
60
+ rack-openid (1.3.1)
62
61
  rack (>= 1.1.0)
63
62
  ruby-openid (>= 2.1.8)
64
- rake (0.8.7)
63
+ rake (0.9.0)
65
64
  rest-client (1.6.1)
66
65
  mime-types (>= 1.16)
67
66
  rforce (0.7)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 0.4.4
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{asf-rest-adapter}
8
- s.version = "0.4.3"
8
+ s.version = "0.4.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Raymond Gao @ Are4Us Technologies"]
12
- s.date = %q{2011-05-05}
12
+ s.date = %q{2011-05-23}
13
13
  s.description = %q{REST based adapter for Salesforce}
14
14
  s.email = %q{raygao2000@yahoo.com}
15
15
  s.extra_rdoc_files = [
@@ -26,6 +26,8 @@ Gem::Specification.new do |s|
26
26
  "Rakefile",
27
27
  "VERSION",
28
28
  "asf-rest-adapter.gemspec",
29
+ "lib/.DS_Store",
30
+ "lib/Salesforce/.DS_Store",
29
31
  "lib/Salesforce/oauth2/config_file/asf_rest_config.yml",
30
32
  "lib/Salesforce/oauth2/enviornments/environment.rb",
31
33
  "lib/Salesforce/oauth2/forcedotcom.rb",
Binary file
Binary file
@@ -1,41 +1,49 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
1
+ #require 'omniauth/oauth'
2
+ #require 'multi_json'
3
3
 
4
- # Omniauth strategy for using oauth2 and force.com
5
- # Author: qwall@salesforce.com
6
- #
4
+ require 'omniauth/strategies/oauth2'
7
5
  module OmniAuth
8
6
  module Strategies
9
- class Forcedotcom < OAuth2
10
- # Initialize the middleware
11
- #
12
- # @option options [Boolean, true] :sign_in When true, use a sign-in flow instead of the authorization flow.
13
- # @option options [Boolean, false] :mobile When true, use the mobile sign-in interface.
14
- def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
7
+ class Forcedotcom < OmniAuth::Strategies::OAuth2
8
+
9
+ def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
15
10
  client_options = {
16
- :site => "https://login.salesforce.com",
17
- :authorize_path => "/services/oauth2/authorize",
18
- :access_token_path => "/services/oauth2/token"
11
+ :site => 'https://login.salesforce.com',
12
+ :authorize_path => '/services/oauth2/authorize',
13
+ :access_token_path => '/services/oauth2/token'
19
14
  }
20
- super(app, :forcedotcom, client_id, client_secret, client_options, &block)
21
- end
22
15
 
23
- def request_phase
24
- options[:response_type] ||= 'code'
25
- super
26
- end
16
+ # 'code' locks you into one org; 'token' works across all orgs.
17
+ options.merge!(:response_type => 'token', :grant_type => 'authorization_code')
27
18
 
28
- def callback_phase
29
- options[:grant_type] ||= 'authorization_code'
30
- super
19
+ super(app, :forcedotcom, consumer_key, consumer_secret, client_options, options, &block)
31
20
  end
32
21
 
33
- def auth_hash
34
- OmniAuth::Utils.deep_merge(super, {
35
- 'instance_url' => @access_token['instance_url']
22
+ def auth_hash
23
+ data = user_data
24
+ OmniAuth::Utils.deep_merge(super, {
25
+ 'uid' => @access_token['id'],
26
+ 'credentials' => {
27
+ 'instance_url' => @access_token['instance_url']
28
+ },
29
+ 'extra' => {'user_hash' => data},
30
+ 'user_info' => {
31
+ 'email' => data['email'],
32
+ 'name' => data['display_name']
33
+ }
36
34
  })
37
- end
38
-
35
+ end
36
+
37
+ def user_data
38
+ @data ||= MultiJson.decode(@access_token.get(@access_token['id']))
39
+ rescue ::OAuth2::HTTPError => e
40
+ if e.response.status == 302
41
+ @data ||= MultiJson.decode(@access_token.get(e.response.headers['location']))
42
+ else
43
+ raise e
44
+ end
45
+ end
39
46
  end
47
+
40
48
  end
41
- end
49
+ end
@@ -1,26 +0,0 @@
1
- build=Build gem into pkg/
2
- clobber=
3
- clobber_rdoc=Remove rdoc products
4
- console[script]=Start IRB with all runtime dependencies loaded
5
- default=
6
- gemcutter\:release=Release gem to Gemcutter
7
- gemspec=Generate and validate gemspec
8
- gemspec\:debug=Display the gemspec for debugging purposes, as jeweler knows it (not from the filesystem)
9
- gemspec\:generate=Regenreate the gemspec on the filesystem
10
- gemspec\:release=Regenerate and validate gemspec, and then commits and pushes to git
11
- gemspec\:validate=Validates the gemspec on the filesystem
12
- gemspec_required=
13
- git\:release=Tag and push release to git. (happens by default with `rake release`)
14
- install=Build and install gem using `gem install`
15
- rcov=
16
- rdoc=Build the rdoc HTML Files
17
- rdoc/index.html=
18
- release=Release gem
19
- rerdoc=Force a rebuild of the RDOC files
20
- test=Run tests
21
- version=Displays the current version
22
- version\:bump\:major=Bump the major version by 1
23
- version\:bump\:minor=Bump the a minor version by 1
24
- version\:bump\:patch=Bump the patch version by 1
25
- version\:write=Writes out an explicit version. Respects the following environment variables, or defaults to 0: MAJOR, MINOR, PATCH. Also recognizes BUILD, which defaults to nil
26
- version_required=
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asf-rest-adapter
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 3
10
- version: 0.4.3
9
+ - 4
10
+ version: 0.4.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Raymond Gao @ Are4Us Technologies
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-05 00:00:00 -05:00
18
+ date: 2011-05-23 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -125,6 +125,8 @@ files:
125
125
  - Rakefile
126
126
  - VERSION
127
127
  - asf-rest-adapter.gemspec
128
+ - lib/.DS_Store
129
+ - lib/Salesforce/.DS_Store
128
130
  - lib/Salesforce/oauth2/config_file/asf_rest_config.yml
129
131
  - lib/Salesforce/oauth2/enviornments/environment.rb
130
132
  - lib/Salesforce/oauth2/forcedotcom.rb