oauthenticator 1.3.2 → 1.3.3

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
2
  SHA1:
3
- metadata.gz: db80d67c9ca2a714efb0048d51559e1177f4189a
4
- data.tar.gz: 9e4d2a061109d621b67aa147ebaf9d3aee6f4e81
3
+ metadata.gz: a17268e39c4fe588fc52170f7e978a4a32f29c46
4
+ data.tar.gz: 1a494d30f16afa681d0966f7d3371e55eb1891c5
5
5
  SHA512:
6
- metadata.gz: 1e02a8108f52fc163c5c766121eecc78c120becff60cd42007b574cfc27912c225fd6a78e2e6af2a3673a253db233c2625709791509a4a91e4adc80d4ae1ffb9
7
- data.tar.gz: fff84c1346c81617b391facb3de890bd223ee304170afdbc16dd71f852f4cbe224c163bd70af5ae25828928e2fa099fef4d58c7d2b5cd0d80ab2f9480344f750
6
+ metadata.gz: d804e22e7df42027f7080dffce83f3a8bcc6a785c31a54ac35f87f3668c456dd354c0f0245664f7db40a465270d020dde929a7defdbf3af57e2ad42c8f4a44bb
7
+ data.tar.gz: 2558fd383699e41c3915d0c8b4d1e9cb85d79f4d6ddc4e7155c17ab7abe29dff60db55a9b39da41ef1c95b10027744db09bab8e371be23118427aeb70eb4a581
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # 1.3.3
2
+
3
+ - env["oauth.signed_request"] contains the signed request. this makes any helper methods from the implemented
4
+ config methods module available and helps avoid code duplication (and sometimes duplicated db queries -
5
+ depending on implementation)
6
+ - fix irrelevant warning with Hash#reject called on hash with a default proc
7
+
1
8
  # 1.3.2
2
9
 
3
10
  - loosen dependency to allow rack 2.0
data/README.md CHANGED
@@ -75,13 +75,13 @@ See the documentation for {OAuthenticator::SignableRequest} for more detailed in
75
75
 
76
76
  ### OAuth Request Body Hash
77
77
 
78
- The [OAuth Request Body Hash](https://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html)
78
+ The [OAuth Request Body Hash](https://tools.ietf.org/html/draft-eaton-oauth-bodyhash-00)
79
79
  specification is supported. By default all signing of outgoing does include the body hash. This can be
80
80
  disabled by setting the `:hash_body?` / `'hash_body?'` attribute to false when instantiating an
81
81
  OAuthenticator::SignableRequest.
82
82
 
83
83
  For info on when to include the body hash, see
84
- [When to Include the Body Hash](https://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html#when_to_include).
84
+ [When to Include the Body Hash](https://tools.ietf.org/html/draft-eaton-oauth-bodyhash-00#section-4.1.1).
85
85
 
86
86
  ## Authenticating incoming requests
87
87
 
@@ -195,7 +195,7 @@ methods it needs to function.
195
195
 
196
196
  ### OAuth Request Body Hash
197
197
 
198
- The [OAuth Request Body Hash](https://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html)
198
+ The [OAuth Request Body Hash](https://tools.ietf.org/html/draft-eaton-oauth-bodyhash-00)
199
199
  specification is supported. Requests which include the oauth_body_hash parameter are authenticated according
200
200
  to the spec.
201
201
 
data/Rakefile.rb CHANGED
@@ -4,7 +4,8 @@ Rake::TestTask.new do |t|
4
4
  t.test_files = FileList['test/**/*_test.rb']
5
5
  t.verbose = true
6
6
  end
7
- task 'default' => 'test'
7
+ require 'wwtd/tasks'
8
+ task 'default' => 'wwtd'
8
9
 
9
10
  require 'yard'
10
11
  YARD::Rake::YardocTask.new do |t|
@@ -1,4 +1,5 @@
1
1
  require 'faraday'
2
+ require 'rack'
2
3
 
3
4
  if Faraday.respond_to?(:register_middleware)
4
5
  Faraday.register_middleware(:request, :oauthenticator_signer => proc { OAuthenticator::FaradaySigner })
@@ -53,10 +54,11 @@ module OAuthenticator
53
54
 
54
55
  # do the thing
55
56
  def call(request_env)
57
+ media_type = Rack::Request.new('CONTENT_TYPE' => request_env[:request_headers]['Content-Type']).media_type
56
58
  request_attributes = {
57
59
  :request_method => request_env[:method],
58
60
  :uri => request_env[:url],
59
- :media_type => request_env[:request_headers]['Content-Type'],
61
+ :media_type => media_type,
60
62
  :body => request_env[:body]
61
63
  }
62
64
  # the adapter will set the media type to form-encoded when not otherwise specified on
@@ -34,7 +34,7 @@ module OAuthenticator
34
34
  scanner = StringScanner.new(header)
35
35
  auth_parse_error = proc { |message| raise ParseError.new(message, {'Authorization' => [message]}) }
36
36
  scanner.scan(/OAuth\s*/i) || auth_parse_error.call("Authorization scheme is not OAuth - recieved: #{header}")
37
- attributes = Hash.new { |h,k| h[k] = [] }
37
+ attributes = {}
38
38
  while scanner.scan(/(\w+)="([^"]*)"\s*(,?)\s*/)
39
39
  key = scanner[1]
40
40
  value = scanner[2]
@@ -42,7 +42,7 @@ module OAuthenticator
42
42
  if !comma_follows && !scanner.eos?
43
43
  auth_parse_error.call("Could not parse Authorization header: #{header}\naround or after character #{scanner.pos}: #{scanner.rest}")
44
44
  end
45
- attributes[unescape(key)] << unescape(value)
45
+ (attributes[unescape(key)] ||= []) << unescape(value)
46
46
  end
47
47
  unless scanner.eos?
48
48
  auth_parse_error.call("Could not parse Authorization header: #{header}\naround or after character #{scanner.pos}: #{scanner.rest}")
@@ -48,6 +48,7 @@ module OAuthenticator
48
48
  unauthenticated_response(oauth_request.errors)
49
49
  else
50
50
  log_success(env, oauth_request)
51
+ env["oauth.signed_request"] = oauth_request
51
52
  env["oauth.consumer_key"] = oauth_request.consumer_key
52
53
  env["oauth.token"] = oauth_request.token
53
54
  env["oauth.authenticated"] = true
@@ -1,5 +1,5 @@
1
1
  # OAuthenticator
2
2
  module OAuthenticator
3
3
  # OAuthenticator::VERSION
4
- VERSION = "1.3.2"
4
+ VERSION = "1.3.3"
5
5
  end
@@ -46,6 +46,23 @@ describe OAuthenticator::FaradaySigner do
46
46
  assert_response 200, '☺', response
47
47
  end
48
48
 
49
+ it 'succeeds with charset' do
50
+ signing_options = {
51
+ :signature_method => 'HMAC-SHA1',
52
+ :consumer_key => consumer_key,
53
+ :consumer_secret => consumer_secret,
54
+ :token => token,
55
+ :token_secret => token_secret,
56
+ }
57
+
58
+ connection = Faraday.new(:url => 'http://example.com', :headers => {'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8'}) do |faraday|
59
+ faraday.request :oauthenticator_signer, signing_options
60
+ faraday.adapter :rack, oapp
61
+ end
62
+ response = connection.post('/', 'a=b')
63
+ assert_response 200, '☺', response
64
+ end
65
+
49
66
  it 'is unauthorized' do
50
67
  signing_options = {
51
68
  :signature_method => 'PLAINTEXT',
@@ -592,14 +592,16 @@ describe OAuthenticator::RackAuthenticator do
592
592
  end
593
593
  end
594
594
 
595
- it 'sets oauth.authenticated, oauth.token, oauth.consumer_key' do
595
+ it 'sets oauth.authenticated, oauth.token, oauth.consumer_key, oauth.signed_request' do
596
596
  oauth_authenticated = nil
597
597
  oauth_token = nil
598
598
  oauth_consumer_key = nil
599
+ oauth_signed_request = nil
599
600
  testapp = proc do |env|
600
601
  oauth_authenticated = env['oauth.authenticated']
601
602
  oauth_token = env['oauth.token']
602
603
  oauth_consumer_key = env['oauth.consumer_key']
604
+ oauth_signed_request = env['oauth.signed_request']
603
605
  [200, {}, ['☺']]
604
606
  end
605
607
  otestapp = OAuthenticator::RackAuthenticator.new(testapp, :config_methods => OAuthenticatorTestConfigMethods)
@@ -607,6 +609,7 @@ describe OAuthenticator::RackAuthenticator do
607
609
  assert_equal(token, oauth_token)
608
610
  assert_equal(consumer_key, oauth_consumer_key)
609
611
  assert_equal(true, oauth_authenticated)
612
+ assert_kind_of(OAuthenticator::SignedRequest, oauth_signed_request)
610
613
  end
611
614
  end
612
615
  end
metadata CHANGED
@@ -1,187 +1,187 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oauthenticator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-09 00:00:00.000000000 Z
11
+ date: 2016-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.4'
20
- - - <
20
+ - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '2.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - '>='
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: '1.4'
30
- - - <
30
+ - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '2.1'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: json
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ~>
37
+ - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '1.8'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ~>
44
+ - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '1.8'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: faraday
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ~>
51
+ - - "~>"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0.9'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ~>
58
+ - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0.9'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: addressable
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ~>
65
+ - - "~>"
66
66
  - !ruby/object:Gem::Version
67
67
  version: '2.3'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - ~>
72
+ - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '2.3'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rake
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - '>='
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - '>='
86
+ - - ">="
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: minitest
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - '>='
93
+ - - ">="
94
94
  - !ruby/object:Gem::Version
95
95
  version: '0'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - '>='
100
+ - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: minitest-reporters
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - '>='
107
+ - - ">="
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - '>='
114
+ - - ">="
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  - !ruby/object:Gem::Dependency
118
118
  name: rack-test
119
119
  requirement: !ruby/object:Gem::Requirement
120
120
  requirements:
121
- - - '>='
121
+ - - ">="
122
122
  - !ruby/object:Gem::Version
123
123
  version: '0'
124
124
  type: :development
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
- - - '>='
128
+ - - ">="
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: timecop
133
133
  requirement: !ruby/object:Gem::Requirement
134
134
  requirements:
135
- - - '>='
135
+ - - ">="
136
136
  - !ruby/object:Gem::Version
137
137
  version: '0'
138
138
  type: :development
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
141
141
  requirements:
142
- - - '>='
142
+ - - ">="
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: simplecov
147
147
  requirement: !ruby/object:Gem::Requirement
148
148
  requirements:
149
- - - '>='
149
+ - - ">="
150
150
  - !ruby/object:Gem::Version
151
151
  version: '0'
152
152
  type: :development
153
153
  prerelease: false
154
154
  version_requirements: !ruby/object:Gem::Requirement
155
155
  requirements:
156
- - - '>='
156
+ - - ">="
157
157
  - !ruby/object:Gem::Version
158
158
  version: '0'
159
159
  - !ruby/object:Gem::Dependency
160
160
  name: api_hammer
161
161
  requirement: !ruby/object:Gem::Requirement
162
162
  requirements:
163
- - - '>='
163
+ - - ">="
164
164
  - !ruby/object:Gem::Version
165
165
  version: '0'
166
166
  type: :development
167
167
  prerelease: false
168
168
  version_requirements: !ruby/object:Gem::Requirement
169
169
  requirements:
170
- - - '>='
170
+ - - ">="
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0'
173
173
  - !ruby/object:Gem::Dependency
174
174
  name: yard
175
175
  requirement: !ruby/object:Gem::Requirement
176
176
  requirements:
177
- - - '>='
177
+ - - ">="
178
178
  - !ruby/object:Gem::Version
179
179
  version: '0'
180
180
  type: :development
181
181
  prerelease: false
182
182
  version_requirements: !ruby/object:Gem::Requirement
183
183
  requirements:
184
- - - '>='
184
+ - - ">="
185
185
  - !ruby/object:Gem::Version
186
186
  version: '0'
187
187
  description: OAuthenticator signs and authenticates OAuth 1.0 requests
@@ -191,8 +191,8 @@ executables: []
191
191
  extensions: []
192
192
  extra_rdoc_files: []
193
193
  files:
194
- - .simplecov
195
- - .yardopts
194
+ - ".simplecov"
195
+ - ".yardopts"
196
196
  - CHANGELOG.md
197
197
  - LICENSE.txt
198
198
  - README.md
@@ -225,17 +225,17 @@ require_paths:
225
225
  - lib
226
226
  required_ruby_version: !ruby/object:Gem::Requirement
227
227
  requirements:
228
- - - '>='
228
+ - - ">="
229
229
  - !ruby/object:Gem::Version
230
230
  version: '0'
231
231
  required_rubygems_version: !ruby/object:Gem::Requirement
232
232
  requirements:
233
- - - '>='
233
+ - - ">="
234
234
  - !ruby/object:Gem::Version
235
235
  version: '0'
236
236
  requirements: []
237
237
  rubyforge_project:
238
- rubygems_version: 2.2.2
238
+ rubygems_version: 2.5.1
239
239
  signing_key:
240
240
  specification_version: 4
241
241
  summary: OAuth 1.0 request signing and authentication
@@ -249,5 +249,4 @@ test_files:
249
249
  - test/signable_request_test.rb
250
250
  - test/signed_request_test.rb
251
251
  - test/test_config_methods.rb
252
- - .simplecov
253
- has_rdoc:
252
+ - ".simplecov"