oauthenticator 0.1.4 → 1.0.0
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.
- checksums.yaml +4 -4
- data/.simplecov +1 -0
- data/README.md +118 -35
- data/Rakefile.rb +11 -0
- data/lib/oauthenticator.rb +5 -6
- data/lib/oauthenticator/config_methods.rb +62 -21
- data/lib/oauthenticator/faraday_signer.rb +66 -0
- data/lib/oauthenticator/parse_authorization.rb +81 -0
- data/lib/oauthenticator/{middleware.rb → rack_authenticator.rb} +37 -9
- data/lib/oauthenticator/signable_request.rb +340 -0
- data/lib/oauthenticator/signed_request.rb +123 -112
- data/lib/oauthenticator/version.rb +3 -1
- data/test/config_methods_test.rb +10 -7
- data/test/faraday_signer_test.rb +65 -0
- data/test/helper.rb +15 -3
- data/test/parse_authorization_test.rb +86 -0
- data/test/{oauthenticator_test.rb → rack_authenticator_test.rb} +264 -136
- data/test/signable_request_test.rb +653 -0
- data/test/signed_request_test.rb +12 -0
- data/test/test_config_methods.rb +67 -0
- metadata +26 -11
@@ -0,0 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
proc { |p| $:.unshift(p) unless $:.any? { |lp| File.expand_path(lp) == p } }.call(File.expand_path('.', File.dirname(__FILE__)))
|
3
|
+
require 'helper'
|
4
|
+
|
5
|
+
# most everything about this is tested via the middlware in oauthenticator_test, so not a lot here
|
6
|
+
describe OAuthenticator::SignedRequest do
|
7
|
+
describe '#initialize' do
|
8
|
+
it 'checks for unrecognized attributes' do
|
9
|
+
assert_raises(ArgumentError) { OAuthenticator::SignedRequest.new(:foo => 'bar') }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# config methods for testing OAuthenticator. simple
|
2
|
+
module OAuthenticatorTestConfigMethods
|
3
|
+
class << self
|
4
|
+
# a set of nonces
|
5
|
+
define_method(:nonces) { @nonces ||= Set.new }
|
6
|
+
# a Hash keyed by consumer keys with values of consumer secrets
|
7
|
+
define_method(:consumer_secrets) { @consumer_secrets ||= {} }
|
8
|
+
# a Hash keyed by tokens with values of token secrets
|
9
|
+
define_method(:token_secrets) { @token_secrets ||= {} }
|
10
|
+
# a Hash keyed by tokens with values of consumer keys
|
11
|
+
define_method(:token_consumers) { @token_consumers ||= {} }
|
12
|
+
end
|
13
|
+
|
14
|
+
def nonce_used?
|
15
|
+
OAuthenticatorTestConfigMethods.nonces.include?(nonce)
|
16
|
+
end
|
17
|
+
|
18
|
+
def use_nonce!
|
19
|
+
OAuthenticatorTestConfigMethods.nonces << nonce
|
20
|
+
end
|
21
|
+
|
22
|
+
def timestamp_valid_period
|
23
|
+
10
|
24
|
+
end
|
25
|
+
|
26
|
+
def allowed_signature_methods
|
27
|
+
%w(HMAC-SHA1 RSA-SHA1 PLAINTEXT)
|
28
|
+
end
|
29
|
+
|
30
|
+
def consumer_secret
|
31
|
+
OAuthenticatorTestConfigMethods.consumer_secrets[consumer_key]
|
32
|
+
end
|
33
|
+
|
34
|
+
def token_secret
|
35
|
+
OAuthenticatorTestConfigMethods.token_secrets[token]
|
36
|
+
end
|
37
|
+
|
38
|
+
def token_belongs_to_consumer?
|
39
|
+
OAuthenticatorTestConfigMethods.token_consumers[token] == consumer_key
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
module TestHelperMethods
|
44
|
+
def self.let(name, &block)
|
45
|
+
define_method(name) { |*args| (@lets ||= {}).key?(name) ? @lets[name] : (@lets[name] = instance_eval(*args, &block)) }
|
46
|
+
end
|
47
|
+
|
48
|
+
let(:simpleapp) { proc { |env| [200, {'Content-Type' => 'text/plain; charset=UTF-8'}, ['☺']] } }
|
49
|
+
let(:oapp) { OAuthenticator::RackAuthenticator.new(simpleapp, :config_methods => OAuthenticatorTestConfigMethods) }
|
50
|
+
|
51
|
+
let(:consumer) do
|
52
|
+
{:key => "test_client_app_key", :secret => "test_client_app_secret"}.tap do |consumer|
|
53
|
+
OAuthenticatorTestConfigMethods.consumer_secrets[consumer[:key]] = consumer[:secret]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
let(:consumer_key) { consumer[:key] }
|
57
|
+
let(:consumer_secret) { consumer[:secret] }
|
58
|
+
|
59
|
+
let(:token_hash) do
|
60
|
+
{:token => 'test_token', :secret => 'test_token_secret', :consumer_key => consumer_key}.tap do |hash|
|
61
|
+
OAuthenticatorTestConfigMethods.token_secrets[hash[:token]] = hash[:secret]
|
62
|
+
OAuthenticatorTestConfigMethods.token_consumers[hash[:token]] = hash[:consumer_key]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
let(:token) { token_hash[:token] }
|
66
|
+
let(:token_secret) { token_hash[:secret] }
|
67
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oauthenticator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: faraday
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -192,25 +192,34 @@ dependencies:
|
|
192
192
|
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: 3.9.0
|
195
|
-
description: OAuthenticator authenticates OAuth 1.0
|
196
|
-
a middleware, and forms useful error messages when authentication fails.
|
195
|
+
description: OAuthenticator signs and authenticates OAuth 1.0 requests
|
197
196
|
email:
|
198
197
|
- ethan@unth
|
199
198
|
executables: []
|
200
199
|
extensions: []
|
201
200
|
extra_rdoc_files: []
|
202
201
|
files:
|
202
|
+
- ".simplecov"
|
203
203
|
- ".yardopts"
|
204
204
|
- LICENSE.txt
|
205
205
|
- README.md
|
206
|
+
- Rakefile.rb
|
206
207
|
- lib/oauthenticator.rb
|
207
208
|
- lib/oauthenticator/config_methods.rb
|
208
|
-
- lib/oauthenticator/
|
209
|
+
- lib/oauthenticator/faraday_signer.rb
|
210
|
+
- lib/oauthenticator/parse_authorization.rb
|
211
|
+
- lib/oauthenticator/rack_authenticator.rb
|
212
|
+
- lib/oauthenticator/signable_request.rb
|
209
213
|
- lib/oauthenticator/signed_request.rb
|
210
214
|
- lib/oauthenticator/version.rb
|
211
215
|
- test/config_methods_test.rb
|
216
|
+
- test/faraday_signer_test.rb
|
212
217
|
- test/helper.rb
|
213
|
-
- test/
|
218
|
+
- test/parse_authorization_test.rb
|
219
|
+
- test/rack_authenticator_test.rb
|
220
|
+
- test/signable_request_test.rb
|
221
|
+
- test/signed_request_test.rb
|
222
|
+
- test/test_config_methods.rb
|
214
223
|
homepage: https://github.com/notEthan/oauthenticator
|
215
224
|
licenses:
|
216
225
|
- MIT
|
@@ -234,9 +243,15 @@ rubyforge_project:
|
|
234
243
|
rubygems_version: 2.2.2
|
235
244
|
signing_key:
|
236
245
|
specification_version: 4
|
237
|
-
summary: OAuth 1.0 request authentication
|
246
|
+
summary: OAuth 1.0 request signing and authentication
|
238
247
|
test_files:
|
239
|
-
- test/helper.rb
|
240
|
-
- test/oauthenticator_test.rb
|
241
248
|
- test/config_methods_test.rb
|
249
|
+
- test/faraday_signer_test.rb
|
250
|
+
- test/helper.rb
|
251
|
+
- test/parse_authorization_test.rb
|
252
|
+
- test/rack_authenticator_test.rb
|
253
|
+
- test/signable_request_test.rb
|
254
|
+
- test/signed_request_test.rb
|
255
|
+
- test/test_config_methods.rb
|
256
|
+
- ".simplecov"
|
242
257
|
has_rdoc:
|