oauth 0.5.5 → 0.5.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +415 -0
  3. data/CODE_OF_CONDUCT.md +84 -0
  4. data/CONTRIBUTING.md +23 -0
  5. data/LICENSE +18 -17
  6. data/README.md +372 -0
  7. data/SECURITY.md +16 -0
  8. data/bin/oauth +2 -2
  9. data/lib/oauth/cli/authorize_command.rb +8 -10
  10. data/lib/oauth/cli/base_command.rb +9 -7
  11. data/lib/oauth/cli/query_command.rb +3 -3
  12. data/lib/oauth/cli/sign_command.rb +12 -15
  13. data/lib/oauth/cli.rb +19 -19
  14. data/lib/oauth/client/action_controller_request.rb +20 -21
  15. data/lib/oauth/client/em_http.rb +99 -99
  16. data/lib/oauth/client/helper.rb +33 -36
  17. data/lib/oauth/client/net_http.rb +30 -30
  18. data/lib/oauth/consumer.rb +90 -89
  19. data/lib/oauth/errors/unauthorized.rb +3 -1
  20. data/lib/oauth/errors.rb +3 -3
  21. data/lib/oauth/helper.rb +17 -13
  22. data/lib/oauth/oauth.rb +4 -4
  23. data/lib/oauth/oauth_test_helper.rb +4 -4
  24. data/lib/oauth/request_proxy/action_controller_request.rb +56 -53
  25. data/lib/oauth/request_proxy/action_dispatch_request.rb +8 -4
  26. data/lib/oauth/request_proxy/base.rb +136 -132
  27. data/lib/oauth/request_proxy/curb_request.rb +49 -43
  28. data/lib/oauth/request_proxy/em_http_request.rb +59 -49
  29. data/lib/oauth/request_proxy/jabber_request.rb +12 -9
  30. data/lib/oauth/request_proxy/mock_request.rb +4 -2
  31. data/lib/oauth/request_proxy/net_http.rb +63 -54
  32. data/lib/oauth/request_proxy/rack_request.rb +35 -31
  33. data/lib/oauth/request_proxy/rest_client_request.rb +53 -50
  34. data/lib/oauth/request_proxy/typhoeus_request.rb +51 -45
  35. data/lib/oauth/request_proxy.rb +3 -3
  36. data/lib/oauth/server.rb +10 -12
  37. data/lib/oauth/signature/base.rb +10 -9
  38. data/lib/oauth/signature/hmac/sha1.rb +4 -4
  39. data/lib/oauth/signature/hmac/sha256.rb +17 -0
  40. data/lib/oauth/signature/plaintext.rb +2 -2
  41. data/lib/oauth/signature/rsa/sha1.rb +5 -5
  42. data/lib/oauth/signature.rb +5 -5
  43. data/lib/oauth/token.rb +5 -5
  44. data/lib/oauth/tokens/access_token.rb +3 -3
  45. data/lib/oauth/tokens/consumer_token.rb +2 -2
  46. data/lib/oauth/tokens/request_token.rb +7 -8
  47. data/lib/oauth/tokens/server_token.rb +0 -1
  48. data/lib/oauth/version.rb +1 -1
  49. data/lib/oauth.rb +8 -6
  50. metadata +47 -99
  51. data/README.rdoc +0 -88
data/lib/oauth/token.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # this exists for backwards-compatibility
2
2
 
3
- require 'oauth/tokens/token'
4
- require 'oauth/tokens/server_token'
5
- require 'oauth/tokens/consumer_token'
6
- require 'oauth/tokens/request_token'
7
- require 'oauth/tokens/access_token'
3
+ require "oauth/tokens/token"
4
+ require "oauth/tokens/server_token"
5
+ require "oauth/tokens/consumer_token"
6
+ require "oauth/tokens/request_token"
7
+ require "oauth/tokens/access_token"
@@ -43,7 +43,7 @@ module OAuth
43
43
  # @response = @token.post('/people', nil, {'Accept' => 'application/xml' })
44
44
  # @response = @token.post('/people', @person.to_xml, { 'Accept'=>'application/xml', 'Content-Type' => 'application/xml' })
45
45
  #
46
- def post(path, body = '', headers = {})
46
+ def post(path, body = "", headers = {})
47
47
  request(:post, path, body, headers)
48
48
  end
49
49
 
@@ -55,7 +55,7 @@ module OAuth
55
55
  # @response = @token.put('/people/123', nil, { 'Accept' => 'application/xml' })
56
56
  # @response = @token.put('/people/123', @person.to_xml, { 'Accept' => 'application/xml', 'Content-Type' => 'application/xml' })
57
57
  #
58
- def put(path, body = '', headers = {})
58
+ def put(path, body = "", headers = {})
59
59
  request(:put, path, body, headers)
60
60
  end
61
61
 
@@ -67,7 +67,7 @@ module OAuth
67
67
  # @response = @token.patch('/people/123', nil, { 'Accept' => 'application/xml' })
68
68
  # @response = @token.patch('/people/123', @person.to_xml, { 'Accept' => 'application/xml', 'Content-Type' => 'application/xml' })
69
69
  #
70
- def patch(path, body = '', headers = {})
70
+ def patch(path, body = "", headers = {})
71
71
  request(:patch, path, body, headers)
72
72
  end
73
73
 
@@ -5,12 +5,12 @@ module OAuth
5
5
  attr_reader :response
6
6
 
7
7
  def self.from_hash(consumer, hash)
8
- token = self.new(consumer, hash[:oauth_token], hash[:oauth_token_secret])
8
+ token = new(consumer, hash[:oauth_token], hash[:oauth_token_secret])
9
9
  token.params = hash
10
10
  token
11
11
  end
12
12
 
13
- def initialize(consumer, token="", secret="")
13
+ def initialize(consumer, token = "", secret = "")
14
14
  super(token, secret)
15
15
  @consumer = consumer
16
16
  @params = {}
@@ -2,19 +2,18 @@ module OAuth
2
2
  # The RequestToken is used for the initial Request.
3
3
  # This is normally created by the Consumer object.
4
4
  class RequestToken < ConsumerToken
5
-
6
5
  # Generate an authorization URL for user authorization
7
6
  def authorize_url(params = nil)
8
- return nil if self.token.nil?
7
+ return nil if token.nil?
9
8
 
10
- params = (params || {}).merge(:oauth_token => self.token)
9
+ params = (params || {}).merge(oauth_token: token)
11
10
  build_url(consumer.authorize_url, params)
12
11
  end
13
12
 
14
13
  def authenticate_url(params = nil)
15
- return nil if self.token.nil?
14
+ return nil if token.nil?
16
15
 
17
- params = (params || {}).merge(:oauth_token => self.token)
16
+ params = (params || {}).merge(oauth_token: token)
18
17
  build_url(consumer.authenticate_url, params)
19
18
  end
20
19
 
@@ -28,16 +27,16 @@ module OAuth
28
27
  OAuth::AccessToken.from_hash(consumer, response)
29
28
  end
30
29
 
31
- protected
30
+ protected
32
31
 
33
32
  # construct an authorization or authentication url
34
33
  def build_url(base_url, params)
35
34
  uri = URI.parse(base_url.to_s)
36
35
  queries = {}
37
36
  queries = Hash[URI.decode_www_form(uri.query)] if uri.query
38
- # TODO doesn't handle array values correctly
37
+ # TODO: doesn't handle array values correctly
39
38
  queries.merge!(params) if params
40
- uri.query = URI.encode_www_form(queries) if !queries.empty?
39
+ uri.query = URI.encode_www_form(queries) unless queries.empty?
41
40
  uri.to_s
42
41
  end
43
42
  end
@@ -1,7 +1,6 @@
1
1
  module OAuth
2
2
  # Used on the server for generating tokens
3
3
  class ServerToken < Token
4
-
5
4
  def initialize
6
5
  super(generate_key(16), generate_key)
7
6
  end
data/lib/oauth/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module OAuth
2
- VERSION = "0.5.5"
2
+ VERSION = "0.5.10".freeze
3
3
  end
data/lib/oauth.rb CHANGED
@@ -1,11 +1,13 @@
1
1
  root = File.dirname(__FILE__)
2
2
  $LOAD_PATH << root unless $LOAD_PATH.include?(root)
3
3
 
4
- require 'oauth/version'
4
+ require "oauth/version"
5
5
 
6
- require 'oauth/oauth'
6
+ require "oauth/oauth"
7
7
 
8
- require 'oauth/client/helper'
9
- require 'oauth/signature/hmac/sha1'
10
- require 'oauth/signature/rsa/sha1'
11
- require 'oauth/request_proxy/mock_request'
8
+ require "oauth/client/helper"
9
+ require "oauth/signature/plaintext"
10
+ require "oauth/signature/hmac/sha1"
11
+ require "oauth/signature/hmac/sha256"
12
+ require "oauth/signature/rsa/sha1"
13
+ require "oauth/request_proxy/mock_request"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pelle Braendgaard
@@ -12,13 +12,14 @@ authors:
12
12
  - Seth Fitzsimmons
13
13
  - Matt Sanford
14
14
  - Aaron Quint
15
- autorequire:
15
+ - Peter Boling
16
+ autorequire:
16
17
  bindir: bin
17
18
  cert_chain: []
18
- date: 2021-01-20 00:00:00.000000000 Z
19
+ date: 2022-05-04 00:00:00.000000000 Z
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- name: rake
22
+ name: curb
22
23
  requirement: !ruby/object:Gem::Requirement
23
24
  requirements:
24
25
  - - ">="
@@ -32,21 +33,21 @@ dependencies:
32
33
  - !ruby/object:Gem::Version
33
34
  version: '0'
34
35
  - !ruby/object:Gem::Dependency
35
- name: minitest
36
+ name: em-http-request
36
37
  requirement: !ruby/object:Gem::Requirement
37
38
  requirements:
38
- - - ">="
39
+ - - "~>"
39
40
  - !ruby/object:Gem::Version
40
- version: '0'
41
+ version: 1.1.7
41
42
  type: :development
42
43
  prerelease: false
43
44
  version_requirements: !ruby/object:Gem::Requirement
44
45
  requirements:
45
- - - ">="
46
+ - - "~>"
46
47
  - !ruby/object:Gem::Version
47
- version: '0'
48
+ version: 1.1.7
48
49
  - !ruby/object:Gem::Dependency
49
- name: byebug
50
+ name: iconv
50
51
  requirement: !ruby/object:Gem::Requirement
51
52
  requirements:
52
53
  - - ">="
@@ -60,21 +61,21 @@ dependencies:
60
61
  - !ruby/object:Gem::Version
61
62
  version: '0'
62
63
  - !ruby/object:Gem::Dependency
63
- name: actionpack
64
+ name: minitest
64
65
  requirement: !ruby/object:Gem::Requirement
65
66
  requirements:
66
67
  - - ">="
67
68
  - !ruby/object:Gem::Version
68
- version: '5.0'
69
+ version: '0'
69
70
  type: :development
70
71
  prerelease: false
71
72
  version_requirements: !ruby/object:Gem::Requirement
72
73
  requirements:
73
74
  - - ">="
74
75
  - !ruby/object:Gem::Version
75
- version: '5.0'
76
+ version: '0'
76
77
  - !ruby/object:Gem::Dependency
77
- name: iconv
78
+ name: mocha
78
79
  requirement: !ruby/object:Gem::Requirement
79
80
  requirements:
80
81
  - - ">="
@@ -89,20 +90,6 @@ dependencies:
89
90
  version: '0'
90
91
  - !ruby/object:Gem::Dependency
91
92
  name: rack
92
- requirement: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '2.0'
97
- type: :development
98
- prerelease: false
99
- version_requirements: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '2.0'
104
- - !ruby/object:Gem::Dependency
105
- name: rack-test
106
93
  requirement: !ruby/object:Gem::Requirement
107
94
  requirements:
108
95
  - - ">="
@@ -116,55 +103,21 @@ dependencies:
116
103
  - !ruby/object:Gem::Version
117
104
  version: '0'
118
105
  - !ruby/object:Gem::Dependency
119
- name: mocha
120
- requirement: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: 0.9.12
125
- - - "<="
126
- - !ruby/object:Gem::Version
127
- version: 1.1.0
128
- type: :development
129
- prerelease: false
130
- version_requirements: !ruby/object:Gem::Requirement
131
- requirements:
132
- - - ">="
133
- - !ruby/object:Gem::Version
134
- version: 0.9.12
135
- - - "<="
136
- - !ruby/object:Gem::Version
137
- version: 1.1.0
138
- - !ruby/object:Gem::Dependency
139
- name: typhoeus
106
+ name: rack-test
140
107
  requirement: !ruby/object:Gem::Requirement
141
108
  requirements:
142
109
  - - ">="
143
110
  - !ruby/object:Gem::Version
144
- version: 0.1.13
111
+ version: '0'
145
112
  type: :development
146
113
  prerelease: false
147
114
  version_requirements: !ruby/object:Gem::Requirement
148
115
  requirements:
149
116
  - - ">="
150
117
  - !ruby/object:Gem::Version
151
- version: 0.1.13
152
- - !ruby/object:Gem::Dependency
153
- name: em-http-request
154
- requirement: !ruby/object:Gem::Requirement
155
- requirements:
156
- - - '='
157
- - !ruby/object:Gem::Version
158
- version: 0.2.11
159
- type: :development
160
- prerelease: false
161
- version_requirements: !ruby/object:Gem::Requirement
162
- requirements:
163
- - - '='
164
- - !ruby/object:Gem::Version
165
- version: 0.2.11
118
+ version: '0'
166
119
  - !ruby/object:Gem::Dependency
167
- name: curb
120
+ name: rake
168
121
  requirement: !ruby/object:Gem::Requirement
169
122
  requirements:
170
123
  - - ">="
@@ -178,21 +131,7 @@ dependencies:
178
131
  - !ruby/object:Gem::Version
179
132
  version: '0'
180
133
  - !ruby/object:Gem::Dependency
181
- name: webmock
182
- requirement: !ruby/object:Gem::Requirement
183
- requirements:
184
- - - "<"
185
- - !ruby/object:Gem::Version
186
- version: '2.0'
187
- type: :development
188
- prerelease: false
189
- version_requirements: !ruby/object:Gem::Requirement
190
- requirements:
191
- - - "<"
192
- - !ruby/object:Gem::Version
193
- version: '2.0'
194
- - !ruby/object:Gem::Dependency
195
- name: codeclimate-test-reporter
134
+ name: rest-client
196
135
  requirement: !ruby/object:Gem::Requirement
197
136
  requirements:
198
137
  - - ">="
@@ -206,45 +145,47 @@ dependencies:
206
145
  - !ruby/object:Gem::Version
207
146
  version: '0'
208
147
  - !ruby/object:Gem::Dependency
209
- name: simplecov
148
+ name: typhoeus
210
149
  requirement: !ruby/object:Gem::Requirement
211
150
  requirements:
212
151
  - - ">="
213
152
  - !ruby/object:Gem::Version
214
- version: '0'
153
+ version: 0.1.13
215
154
  type: :development
216
155
  prerelease: false
217
156
  version_requirements: !ruby/object:Gem::Requirement
218
157
  requirements:
219
158
  - - ">="
220
159
  - !ruby/object:Gem::Version
221
- version: '0'
160
+ version: 0.1.13
222
161
  - !ruby/object:Gem::Dependency
223
- name: rest-client
162
+ name: webmock
224
163
  requirement: !ruby/object:Gem::Requirement
225
164
  requirements:
226
- - - ">="
165
+ - - "<="
227
166
  - !ruby/object:Gem::Version
228
- version: '0'
167
+ version: 3.14.0
229
168
  type: :development
230
169
  prerelease: false
231
170
  version_requirements: !ruby/object:Gem::Requirement
232
171
  requirements:
233
- - - ">="
172
+ - - "<="
234
173
  - !ruby/object:Gem::Version
235
- version: '0'
236
- description:
237
- email: oauth-ruby@googlegroupspec.com
174
+ version: 3.14.0
175
+ description:
176
+ email: oauth-ruby@googlegroups.com
238
177
  executables:
239
178
  - oauth
240
179
  extensions: []
241
180
  extra_rdoc_files:
242
- - LICENSE
243
- - README.rdoc
244
181
  - TODO
245
182
  files:
183
+ - CHANGELOG.md
184
+ - CODE_OF_CONDUCT.md
185
+ - CONTRIBUTING.md
246
186
  - LICENSE
247
- - README.rdoc
187
+ - README.md
188
+ - SECURITY.md
248
189
  - TODO
249
190
  - bin/oauth
250
191
  - lib/oauth.rb
@@ -284,6 +225,7 @@ files:
284
225
  - lib/oauth/signature.rb
285
226
  - lib/oauth/signature/base.rb
286
227
  - lib/oauth/signature/hmac/sha1.rb
228
+ - lib/oauth/signature/hmac/sha256.rb
287
229
  - lib/oauth/signature/plaintext.rb
288
230
  - lib/oauth/signature/rsa/sha1.rb
289
231
  - lib/oauth/token.rb
@@ -293,11 +235,17 @@ files:
293
235
  - lib/oauth/tokens/server_token.rb
294
236
  - lib/oauth/tokens/token.rb
295
237
  - lib/oauth/version.rb
296
- homepage:
238
+ homepage: https://github.com/oauth-xx/oauth-ruby
297
239
  licenses:
298
240
  - MIT
299
- metadata: {}
300
- post_install_message:
241
+ metadata:
242
+ bug_tracker_uri: https://github.com/oauth-xx/oauth-ruby/issues
243
+ changelog_uri: https://github.com/oauth-xx/oauth-ruby/blob/master/CHANGELOG.md
244
+ documentation_uri: https://rubydoc.info/github/oauth-xx/oauth-ruby/master
245
+ homepage_uri: https://github.com/oauth-xx/oauth-ruby
246
+ source_code_uri: https://github.com/oauth-xx/oauth-ruby
247
+ rubygems_mfa_required: 'true'
248
+ post_install_message:
301
249
  rdoc_options: []
302
250
  require_paths:
303
251
  - lib
@@ -312,8 +260,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
312
260
  - !ruby/object:Gem::Version
313
261
  version: '0'
314
262
  requirements: []
315
- rubygems_version: 3.0.8
316
- signing_key:
263
+ rubygems_version: 3.0.3.1
264
+ signing_key:
317
265
  specification_version: 4
318
266
  summary: OAuth Core Ruby implementation
319
267
  test_files: []
data/README.rdoc DELETED
@@ -1,88 +0,0 @@
1
- = Ruby OAuth
2
-
3
- == Status
4
-
5
- {<img src="https://travis-ci.org/oauth-xx/oauth-ruby.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/oauth-xx/oauth-ruby]
6
-
7
-
8
-
9
- == What
10
-
11
- This is a RubyGem for implementing both OAuth clients and servers in Ruby applications.
12
-
13
- See the OAuth specs http://oauth.net/core/1.0/
14
-
15
- == Installing
16
-
17
- sudo gem install oauth
18
-
19
- The source code is now hosted on the OAuth GitHub Project http://github.com/oauth-xx/oauth-ruby
20
-
21
- == The basics
22
-
23
- This is a ruby library which is intended to be used in creating Ruby Consumer and Service Provider applications. It is NOT a Rails plugin, but could easily be used for the foundation for such a Rails plugin.
24
-
25
- As a matter of fact it has been pulled out from an OAuth Rails GEM (https://rubygems.org/gems/oauth-plugin https://github.com/pelle/oauth-plugin) which now uses this gem as a dependency.
26
-
27
- == Demonstration of usage
28
-
29
- We need to specify the oauth_callback url explicitly, otherwise it defaults to "oob" (Out of Band)
30
-
31
- callback_url = "http://127.0.0.1:3000/oauth/callback"
32
-
33
- Create a new `OAuth::Consumer` instance by passing it a configuration hash:
34
-
35
- oauth_consumer = OAuth::Consumer.new("key", "secret", :site => "https://agree2")
36
-
37
- Start the process by requesting a token
38
-
39
- request_token = oauth_consumer.get_request_token(:oauth_callback => callback_url)
40
-
41
- session[:token] = request_token.token
42
- session[:token_secret] = request_token.secret
43
- redirect_to request_token.authorize_url(:oauth_callback => callback_url)
44
-
45
- When user returns create an access_token
46
-
47
- hash = { oauth_token: session[:token], oauth_token_secret: session[:token_secret]}
48
- request_token = OAuth::RequestToken.from_hash(oauth_consumer, hash)
49
- access_token = request_token.get_access_token
50
- # For 3-legged authorization, flow oauth_verifier is passed as param in callback
51
- # access_token = request_token.get_access_token(oauth_verifier: params[:oauth_verifier])
52
- @photos = access_token.get('/photos.xml')
53
-
54
- Now that you have an access token, you can use Typhoeus to interact with the OAuth provider if you choose.
55
-
56
- require 'typhoeus'
57
- require 'oauth/request_proxy/typhoeus_request'
58
- oauth_params = {:consumer => oauth_consumer, :token => access_token}
59
- hydra = Typhoeus::Hydra.new
60
- req = Typhoeus::Request.new(uri, options) # :method needs to be specified in options
61
- oauth_helper = OAuth::Client::Helper.new(req, oauth_params.merge(:request_uri => uri))
62
- req.options[:headers].merge!({"Authorization" => oauth_helper.header}) # Signs the request
63
- hydra.queue(req)
64
- hydra.run
65
- @response = req.response
66
-
67
-
68
- == More Information
69
-
70
- * RDoc: http://rdoc.info/github/oauth-xx/oauth-ruby/master/frames
71
- * Mailing List/Google Group: http://groups.google.com/group/oauth-ruby
72
-
73
- == How to submit patches
74
-
75
- The source code is now hosted on the OAuth GitHub Project http://github.com/oauth-xx/oauth-ruby
76
-
77
- To submit a patch, please fork the oauth project and create a patch with tests. Once you're happy with it send a pull request and post a message to the google group.
78
-
79
- == License
80
-
81
- This code is free to use under the terms of the MIT license.
82
-
83
- == Contact
84
-
85
- OAuth Ruby has been created and maintained by a large number of talented individuals.
86
- The current maintainer is Aaron Quint (quirkey).
87
-
88
- Comments are welcome. Send an email to via the OAuth Ruby mailing list http://groups.google.com/group/oauth-ruby